Click here to Skip to main content
16,011,680 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: couldn't install vc++ 2008? Pin
Mark Salsbery12-Jun-08 6:11
Mark Salsbery12-Jun-08 6:11 
GeneralRe: couldn't install vc++ 2008? Pin
led mike12-Jun-08 6:48
led mike12-Jun-08 6:48 
QuestionHow to search and delete a file Pin
Shirani12-Jun-08 1:18
Shirani12-Jun-08 1:18 
AnswerRe: How to search and delete a file Pin
_AnsHUMAN_ 12-Jun-08 1:44
_AnsHUMAN_ 12-Jun-08 1:44 
AnswerRe: How to search and delete a file Pin
vijay_aroli12-Jun-08 2:36
vijay_aroli12-Jun-08 2:36 
GeneralRe: How to search and delete a file Pin
Shirani12-Jun-08 6:39
Shirani12-Jun-08 6:39 
GeneralRe: How to search and delete a file Pin
Eytukan12-Jun-08 7:52
Eytukan12-Jun-08 7:52 
QuestionAfxCallWndProc and custom control development Pin
sawerr12-Jun-08 1:11
sawerr12-Jun-08 1:11 
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 simplification
LRESULT AfxWndProc(HWND hwnd, UINT msg, ...)
{
CWnd* pWnd = CWnd::FromHandle(hwnd);
switch (msg) {
case WM_CREATE:
pWnd->OnCreate(...);
return 0;
case WM_SETFOCUS:
pWnd->OnSetFocus(...);
return 0;
.
.
.
// etc.
}
return 0L;
}


If AfxWndProc routes WM_XXX messages to window class's OnXXX handler functions, why didn't Ultimate toolbox use it?
If i derive a class from any MFC wnd class(CWnd, CFrameWnd, CEdit etc...) haven't it got all the default wndproc for messages(because i derived it from CWnd class)? So why do we need to call AfxWndProc?
QuestionHow can I get byte pointers to give CString values ? Pin
SherTeks12-Jun-08 0:56
SherTeks12-Jun-08 0:56 
AnswerRe: How can I get byte pointers to give CString values ? Pin
SandipG 12-Jun-08 2:09
SandipG 12-Jun-08 2:09 
GeneralRe: How can I get byte pointers to give CString values ? Pin
RockyJames12-Jun-08 2:12
RockyJames12-Jun-08 2:12 
GeneralRe: How can I get byte pointers to give CString values ? Pin
SandipG 12-Jun-08 2:16
SandipG 12-Jun-08 2:16 
GeneralRe: How can I get byte pointers to give CString values ? Pin
RockyJames12-Jun-08 3:11
RockyJames12-Jun-08 3:11 
AnswerRe: How can I get byte pointers to give CString values ? Pin
SherTeks12-Jun-08 21:26
SherTeks12-Jun-08 21:26 
QuestionLogin& Logout Time Pin
leonigah12-Jun-08 0:53
leonigah12-Jun-08 0:53 
AnswerRe: Login& Logout Time Pin
Nibu babu thomas12-Jun-08 3:04
Nibu babu thomas12-Jun-08 3:04 
GeneralRe: Login& Logout Time Pin
leonigah12-Jun-08 20:28
leonigah12-Jun-08 20:28 
GeneralRe: Login& Logout Time Pin
leonigah12-Jun-08 20:28
leonigah12-Jun-08 20:28 
QuestionRe: Login& Logout Time Pin
Nibu babu thomas12-Jun-08 20:49
Nibu babu thomas12-Jun-08 20:49 
AnswerRe: Login& Logout Time Pin
David Crow12-Jun-08 4:03
David Crow12-Jun-08 4:03 
AnswerRe: Login& Logout Time Pin
leonigah12-Jun-08 23:51
leonigah12-Jun-08 23:51 
QuestionHow can get value of keyboard pressed key? Pin
Le@rner11-Jun-08 23:59
Le@rner11-Jun-08 23:59 
AnswerRe: How can get value of keyboard pressed key? Pin
CPallini12-Jun-08 0:24
mveCPallini12-Jun-08 0:24 
QuestionRe: How can get value of keyboard pressed key? Pin
Rajesh R Subramanian12-Jun-08 0:27
professionalRajesh R Subramanian12-Jun-08 0:27 
AnswerRe: How can get value of keyboard pressed key? Pin
Le@rner12-Jun-08 0:40
Le@rner12-Jun-08 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.