[libcurl has HTTP support along several other protocols^] BTW, here is [linux forum^]
Rajkumar R
Posts
-
firing a http url in c -
How to get the handles of all the windows opened in wince?Well, well try, If that API was supposed to work as per your understanding there are possible risks being caught in an infinite loop or referencing a destroyed window handle. Call Back functions of an Windows API are not that supposed to be called by you.
struct MYLISTVIEW
{
};BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
#define MAX_TEXT_LEN 256
MYLISTVIEW *plvData = (MYLISTVIEW *)lParam;
if (plvData)
{
TCHAR szWndText[MAX_TEXT_LEN] = _T("");LONG lStyle = GetWindowLong(hwnd, GWL\_STYLE); LONG lExStyle = GetWindowLong(hwnd, GWL\_EXSTYLE); // filter the window handles depending on your need if (IsWindowVisible(hwnd) && !GetParent(hwnd) && hwnd != GetDesktopWindow() && ( /\*lExStyle & WS\_EX\_APPWINDOW || \*/ !(lExStyle & WS\_EX\_NOACTIVATE || lExStyle & WS\_EX\_TOOLWINDOW))) { RECT rc = {0}; GetWindowRect(hwnd, &rc); if (rc.bottom - rc.top && rc.right - rc.left) { GetWindowText(hwnd, szWndText, MAX\_TEXT\_LEN); // add the text to your view AddWndTextToListView(plvData, szWndText); } } } return TRUE;
}
MYLISTVIEW g_lvData;
void AddOpenedWindowsToListView()
{
EnumWindows(EnumWindowsProc, (LPARAM)&g_lvData);
} -
How to clean up an object of CMapStringtoStringyou may call CMapStringtoString::RemoveAll, but CMapStringtoString destructor does this. you don't want to delete individual elements in this collection. For reference you may check [COLLECT Sample: Illustrates MFC Collection Classes^]
-
WinCe Screen shot of windowsyou may use [Windows CE Remote Tools - Remote Zoom-in^] available with SDKs, if you have platform builder you can use [CETK tool - Print Screen ^]
-
How to get the handles of all the windows opened in wince?have a look into [EnumWindows^] and [GetWindowText^] and search CP for ListView
-
DirectShow BluesICaptureGraphBuilder2 is an interface not the object, shall be refered as IID_ICaptureGraphBuilder2 as in ,
CoCreateInstance( CLSID_CaptureGraphBuilder,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2,
(void**) &pCaptureGraphBuilder)ICaptureGraphBuilder2 is exposed by CaptureGraphBuilder (There is no CLSID_CaptureGraphBuilder2)
-
Is there any function similiar to CopyImage () (in Visual C++) that is supported in Embedded Visual C++?have a look at [SHLoadImageFile^], [SHLoadImageResource^] this is supported from Windows CE .NET 4.0 and later so you must be able to use in evc++, if you are planning to use higher version (WCE 5.0) try using Imaging API there is a sample in SDK path.
-
Preview window closes when print button is clicked in print previewNot Sure, I don't have time to debug. BTW, in my application, the preview window is not closing when the print dialog cancel button is pressed. You have the complete MFC source code in Visual Studio SDK folder, you can find the reason by debugging them.
-
Get text from the focused control in another windowconsider [GetWindowThreadProcessId^] also for getting the processid of the foreground window and thread id needed for GetGUIThreadInfo
-
Template parameter interpreted as base, not derivedMember 2603772 wrote:
T* pTemplate = NULL; //Why is pTemplate Base* and not Derived1* when passing a Derived1 to template parameter?
nope, you confused with the result, check by printing
std::cout << typeid(pTemplate).name()
I think you expected the result as true and you got false (bIsDerived = true you expected, as the pointer you passed is derived). to get what inside the pointer you can dereference it saytypeid(*pBaseRaw)
so your code can be,template<class T> bool CheckType(boost::shared_ptr<Base> pBase)
{
Base* pBaseRaw = pBase.get();
if(typeid(*pBaseRaw) == typeid(T)) {
return true;
}
return false;
}modified on Friday, January 23, 2009 1:13 PM
-
limiting print marginsIf you are discussing about the page Setup dialog that you use in your own application, i also think so, you may need to subclass the dialog. First of all, obviously, if the margins are overbound it messes up, that is known to the user, do you need to correct it? If you want to disable the margin fields, simply use PSD_DISABLEMARGINS flags in [PageSetupDlg Function^]. Or you can validate the margin data entry, by subclassing it. That is setting the hook procedure.
PAGESETUPDLG psd; // common dialog box structure
// Initialize PAGESETUPDLG
ZeroMemory(&psd, sizeof(psd));
psd.lStructSize = sizeof(psd);
psd.hwndOwner =
....
psd.Flags = PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS |
PSD_ENABLEPAGESETUPHOOK
;
psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)PageSetupHook;if (PageSetupDlg(&psd)==TRUE) {
And in the hook procedure you can validate the text entry,
BOOL CALLBACK PageSetupHook(HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{switch (uMsg)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;case WM\_COMMAND: if ((LOWORD(wParam) == 1155 // ID of LEFT MARGIN EDIT CTRL (from PrnSetup.Dlg) && HIWORD(wParam) == EN\_CHANGE) { // write the validation code
You can completely customise the page setup dialog with your own dialog by create a dialog template resource by modifying the default template available in VC\PlatformSDK\Include\PrnSetup.Dlg by specifying the flags,
psd.Flags = PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS |
PSD_ENABLEPAGESETUPHOOK |PSD_ENABLEPAGESETUPTEMPLATE
;
....
psd.lpPageSetupTemplateName = MAKEINTRESOURCE(IDD_PAGESETUP); // your dialog template
psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)PageSetupHook;
psd.hInstance = hInstance;see also [Customizing the Page Setup Dialog Box^]
-
Preview window closes when print button is clicked in print previewYou may need to create custom preview class. Have a look at [TN030: Customizing Printing and Print Preview^] I tried some thing now, sorry i don't have easy solution, create a new class CMyPreviewView derived from CPreviewView use #include <afxpriv.h> in stdafx.h overide the Print command handler in the preview view,
BEGIN_MESSAGE_MAP(CMyPreviewView, CPreviewView)
ON_COMMAND(AFX_ID_PREVIEW_PRINT, &CMyPreviewView::OnPreviewPrint) // this called when print button is pressed
END_MESSAGE_MAP()so that you have the control of print button in CMyPreviewView::OnPreviewPrint and here you won't close the preview window
void CMyPreviewView::OnPreviewPrint()
{
// assuming you want to print the view
m_pOrigView->SendMessage(WM_COMMAND, ID_FILE_PRINT);
}make your custom preview class as Document preview class by calling DoPrintPreview,
void CMyViewToBePrinted::OnFilePrintPreview()
{
// In derived classes, implement special window handling here
// Be sure to Unhook Frame Window close if hooked.// must not create this on the frame. Must outlive this function CPrintPreviewState\* pState = new CPrintPreviewState; TRY { // DoPrintPreview's return value does not necessarily indicate that // Print preview succeeded or failed, but rather what actions are necessary // at this point. If DoPrintPreview returns TRUE, it means that // OnEndPrintPreview will be (or has already been) called and the // pState structure will be/has been deleted. // If DoPrintPreview returns FALSE, it means that OnEndPrintPreview // WILL NOT be called and that cleanup, including deleting pState // must be done here. if (!DoPrintPreview(AFX\_IDD\_PREVIEW\_TOOLBAR, this, RUNTIME\_CLASS(CMyPreviewView), pState)) { // In derived classes, reverse special window handling here for // Preview failure case TRACE(traceAppMsg, 0, "Error: DoPrintPreview failed.\\n"); AfxMessageBox(AFX\_IDP\_COMMAND\_FAILURE); delete pState; // preview failed to initialize, delete State now } } CATCH\_ALL(e) { delete pState; THROW\_LAST(); } END\_CATCH\_ALL
}
modify the View message maps as,
BEGIN_MESSAGE_MAP(CMyViewToBePrinted, CView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) -
Problems with sending UPD Packets over sendtoCheck the return value of sendto API
-
AcceptEx parameter type questionbecause the second parameter is not a return value. In AcceptEx,You need to have accept socket opened already unlike the accept API in which the socket is returned. from msdn,
Another key difference between the AcceptEx function and the accept function is that AcceptEx requires the caller to already have two sockets:
One that specifies the socket on which to listen.
One that specifies the socket on which to accept the connection.The sAcceptSocket parameter must be an open socket that is neither bound nor connected.
-
Exception problemrrrado wrote:
I wonder why debug mode caught the exception
Might be because you set the "Enable C++ Exception=> YES with Structured exception (/EHa)" for debug configuration settings but not for release configuration.
-
How to limit cin to string?std::cin.get(str, sizeof(str), '\n'); or std::cin >> std::setw(sizeof(str)) >>str;
-
Hide and show Dialog ApplicationAlso Leave some thing to user to unhide the application like [System Tray Icon^]
-
Using CWebBrowser2 control with CString?Some thing like this,
CComPtr<IDispatch> pDispDoc; CComVariant spVar(\_T("about:blank")); m\_Explorer.Navigate2(&spVar, 0, 0, 0, 0); // Just to initialise a blank doc **pDispDoc = m\_Explorer.get\_Document();** CComQIPtr<IHTMLDocument2> spDoc(pDispDoc); VARIANT \*param; **CComBSTR spbStrHtmlText(OLESTR("<html><body>some very large text</body></html>"));** SAFEARRAY \* psfArray = SafeArrayCreateVector(VT\_VARIANT, 0, 1); SafeArrayAccessData(psfArray,(LPVOID\*) & param); param->vt = VT\_BSTR; param->bstrVal = spbStrHtmlText; SafeArrayUnaccessData(psfArray); **spDoc->write(psfArray);** SafeArrayDestroy(psfArray);
See also [IHTMLElement::innerHTML ^] And have a look at IHTMLDom objects to have more controls over internal html nodes.
-
How to invoke Microsoft Outlook create new profile dialog from MFC/C++ codeSee [here^] for the APIs MAPILogonEx and LaunchWizard
-
VC++ code to read and write to an INI file[here^]