Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

Rajkumar R

@Rajkumar R
About
Posts
1.1k
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • firing a http url in c
    R Rajkumar R

    [libcurl has HTTP support along several other protocols^] BTW, here is [linux forum^]

    C / C++ / MFC c++ linux tutorial question

  • How to get the handles of all the windows opened in wince?
    R Rajkumar R

    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);
    }

    C / C++ / MFC tutorial question

  • How to clean up an object of CMapStringtoString
    R Rajkumar R

    you 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^]

    C / C++ / MFC tutorial

  • WinCe Screen shot of windows
    R Rajkumar R

    you may use [Windows CE Remote Tools - Remote Zoom-in^] available with SDKs, if you have platform builder you can use [CETK tool - Print Screen ^]

    C / C++ / MFC graphics help

  • How to get the handles of all the windows opened in wince?
    R Rajkumar R

    have a look into [EnumWindows^] and [GetWindowText^] and search CP for ListView

    C / C++ / MFC tutorial question

  • DirectShow Blues
    R Rajkumar R

    ICaptureGraphBuilder2 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)

    C / C++ / MFC announcement visual-studio graphics game-dev windows-admin

  • Is there any function similiar to CopyImage () (in Visual C++) that is supported in Embedded Visual C++?
    R Rajkumar R

    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.

    C / C++ / MFC c++ com hardware algorithms tutorial

  • Preview window closes when print button is clicked in print preview
    R Rajkumar R

    Not 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.

    C / C++ / MFC help tutorial

  • Get text from the focused control in another window
    R Rajkumar R

    consider [GetWindowThreadProcessId^] also for getting the processid of the foreground window and thread id needed for GetGUIThreadInfo

    C / C++ / MFC help tutorial question

  • Template parameter interpreted as base, not derived
    R Rajkumar R

    Member 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 say typeid(*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

    C / C++ / MFC question

  • limiting print margins
    R Rajkumar R

    If 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^]

    C / C++ / MFC collaboration

  • Preview window closes when print button is clicked in print preview
    R Rajkumar R

    You 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)

    C / C++ / MFC help tutorial

  • Problems with sending UPD Packets over sendto
    R Rajkumar R

    Check the return value of sendto API

    C / C++ / MFC help question

  • AcceptEx parameter type question
    R Rajkumar R

    because 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.

    C / C++ / MFC delphi question

  • Exception problem
    R Rajkumar R

    rrrado 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.

    C / C++ / MFC question c++ debugging performance help

  • How to limit cin to string?
    R Rajkumar R

    std::cin.get(str, sizeof(str), '\n'); or std::cin >> std::setw(sizeof(str)) >>str;

    C / C++ / MFC help tutorial question

  • Hide and show Dialog Application
    R Rajkumar R

    Also Leave some thing to user to unhide the application like [System Tray Icon^]

    C / C++ / MFC question

  • Using CWebBrowser2 control with CString?
    R Rajkumar R

    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.

    C / C++ / MFC help html question

  • How to invoke Microsoft Outlook create new profile dialog from MFC/C++ code
    R Rajkumar R

    See [here^] for the APIs MAPILogonEx and LaunchWizard

    C / C++ / MFC c++ tutorial question

  • VC++ code to read and write to an INI file
    R Rajkumar R

    [here^]

    C / C++ / MFC c++ tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups