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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. AfxCallWndProc and custom control development

AfxCallWndProc and custom control development

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpwpftutoriallearning
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sawerr
    wrote on last edited by
    #1

    Hi In Programming with Microsoft Visual C++.NET book, author shows a custom control dll. In his code:

    LRESULT CALLBACK AFX_EXPORT
    RygWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    CWnd\* pWnd;
    
    pWnd = CWnd::FromHandlePermanent(hWnd);
    if (pWnd == NULL) {
        // Assume that client created a CRygWnd window
        pWnd = new CRygWnd();
        pWnd->Attach(hWnd);
    }
    ASSERT(pWnd->m\_hWnd == hWnd);
    ASSERT(pWnd == CWnd::FromHandlePermanent(hWnd));
    LRESULT lResult = AfxCallWndProc(pWnd, hWnd, message,
                                     wParam, lParam);
    return lResult;
    

    }

    I downloaded The Ultimate Toolbox code, there is no call to AfxCallWndProc For example:

    BOOL COXTabViewContainer::Create(CWnd* pParentWnd, CRect rect/*=CRect(0,0,0,0)*/,
    DWORD dwStyle/*=WS_CHILD|WS_VISIBLE*/,
    UINT nID/*=AFX_IDW_PANE_FIRST*/)
    {
    ASSERT(pParentWnd != NULL);
    ASSERT(dwStyle & WS_CHILD);
    ASSERT(nID != 0);

    // the Windows scroll bar styles bits turn on the smart scrollbars
    DWORD dwCreateStyle=dwStyle&~(WS\_HSCROLL|WS\_VSCROLL);
    dwCreateStyle&=~WS\_BORDER;
    
    dwCreateStyle|=WS\_CHILD;
    
    // define our own window class 
    WNDCLASS wndClass;
    wndClass.style=CS\_DBLCLKS; 
    wndClass.lpfnWndProc=AfxWndProc; 
    wndClass.cbClsExtra=0; 
    wndClass.cbWndExtra=0; 
    wndClass.hInstance=AfxGetInstanceHandle(); 
    wndClass.hIcon=0; 
    wndClass.hCursor=::LoadCursor(NULL,IDC\_ARROW); 
    wndClass.hbrBackground=(HBRUSH)(COLOR\_BTNFACE+1); 
    wndClass.lpszMenuName=NULL; 
    wndClass.lpszClassName=\_T("TabViewContainer");
    
    if(!AfxRegisterClass(&wndClass))
    	return FALSE;
    
    if (!CreateEx(WS\_EX\_CLIENTEDGE,wndClass.lpszClassName,NULL,
    	dwCreateStyle,rect.left,rect.top,rect.Width(),rect.Height(),
    	pParentWnd->m\_hWnd,(HMENU)(INT\_PTR)nID,NULL))
    {
    	return FALSE;       // create invisible
    }
    
    // remove WS\_EX\_CLIENTEDGE style from parent window
    pParentWnd->ModifyStyleEx(WS\_EX\_CLIENTEDGE, 0, SWP\_DRAWFRAME);
    
    // sign 
    ::SetWindowLongPtr(GetSafeHwnd(),GWL\_USERDATA,ID\_TABVIEWCONTAINER\_SIGN);
    
    SetScrollStyle(0,TRUE);
    
    CalcLayout();
    
    return TRUE;
    

    }

    In MSJ for AfxCallWndProc: You can think of AfxWndProc as a function with a big switch statement that routes WM_XXX messages to your window class's OnXXX handler functions. This is a first-order approximation of how AfxWndProc works: // This is a gross simplificat

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

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