Thread: my wndProc is out of scope

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    133

    my wndProc is out of scope

    After reading this great article on simple window c++ class at foosyerdoos , i decided to write my window class.

    However, i encounter this:

    Code:
    --------------------Configuration: skeleton - Win32 Debug--------------------
    Compiling...
    mainFrame.cpp
    C:\Documents and Settings\Edmund\My Documents\My eBooks\My expt files\windows workspace\skeleton\mainFrame.cpp(24) : error C2440: 'type cast' : cannot convert from '' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
            None of the functions with this name in scope match the target type
    Error executing cl.exe.
    
    skeleton.exe - 1 error(s), 0 warning(s)
    I think my wndProc is out of scope. Can someone tell me why? What can i do? I dont want to have a global wndProc that calls the window class object's wndProc like what the website did. Here are part of my code(mainFrame.cpp(line 24) is provide at bottom):
    Code:
    //--------winMain()-------------//
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
    {
    	MSG msg;
    	mainFrame mainframe(hInstance, IDR_MAIN,IDS_MAINTITLE,nCmdShow);
    
    	// instance initialization
    	if(!(mainframe.initInstance()))
    		return 0;
    
    	// GetMessage() :
    	// first parameter stores the message obtained from message loop
    	// second parameter specify the window handle for which to retrieve a msg
    	// if second parameter is NULL, the next message belonging to the application is obtained
    	// 3rd and 4th specify the range of message to obtain
    	// GetMessage() return 0 when WM_QUIT is retrieved
    
    	
    	while(GetMessage(&msg,NULL,0,0))
    	{TranslateMessage(&msg); // translate the virtual keys for WinProc to intepret
    	 DispatchMessage(&msg); // send message to WinProc
    	}
    
    	return msg.wParam;
    
    }
     
    
    //---------------skeleton.h---------------------------//
    // abstract class for any windows
    class skeleton
    {
    public:
    	// 1. constructor
    	skeleton(HINSTANCE hInst, UINT name, UINT wndTitle, int nCmdShow);
    	// 2. destructor
    	virtual ~skeleton(){};
    	// 3. function to register window class
    	virtual bool registerWindowClass(HINSTANCE hinst, UINT resPoolID) = 0;
    	// 4. function to create window
    	virtual HWND createWindow(HINSTANCE hinst, int nCmdShow, UINT resPoolID, UINT title) = 0;
    	// 5. window processing window
    	virtual LRESULT CALLBACK wndProc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam) = 0;
    	//6. initiliaze the window
    	bool  initInstance();
    
    private:
    	HINSTANCE hInstance; // instance handle of application
    	UINT classname;		// class name
    	UINT title;			// title of window
    	int nWinMode;		// default height of window
    
    };
    
    #endif
    
    //----------------mainFrame.h------------------------//
    class mainFrame:public skeleton // skeleton as base class
    {
    public:
    	mainFrame(HINSTANCE hInst, UINT name, UINT wndTitle, int nCmdShow);
    	~mainFrame(){};
    	
    	// function to register window class
    	virtual bool registerWindowClass(HINSTANCE hinst, UINT resPoolID);
    	// function to create window
    	virtual HWND createWindow(HINSTANCE hinst, int nCmdShow, UINT resPoolID, UINT title);
    	// window processing window
    	virtual LRESULT CALLBACK wndProc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam);
    
    private:
    	void mainWindow_onDestroy(HWND hwnd);
    	void mainWindow_onCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
    };
    
    //-----------------------mainFrame.cpp---------------------------//
    // NOTE: I believe this is where the problem is. My wndProc that i registered is in the scope of the mainFrame class. 
    
    // function to register window class
    bool mainFrame::registerWindowClass(HINSTANCE hinst, UINT resPoolID) 
    {
    	WNDCLASSEX wc; // window class structure
    	TCHAR ClassName[MAX_RESOURCESTRING+1]; // string to load classname
    
    	// load class name into ClassName
    	LoadString(hinst,resPoolID,ClassName,DIM(ClassName));
    
    	// fill in window classs structure with parameters that describe the window
    	wc.cbSize = sizeof(WNDCLASSEX); // specify size of window class structure
    	wc.style = CS_HREDRAW | CS_VREDRAW ; // window class style
    
    
    // THIS IS WHERE mainFrame.cpp(line 24) IS
    //---------------------------------------------------------------------------
    	wc.lpfnWndProc = (WNDPROC) wndProc;  // window process function
    //---------------------------------------------------------------------------
    
    
    	wc.cbClsExtra = 0; // extra byte(s) to store additional information about a class, 
    					   //shared by all windows of the class
    	wc.cbWndExtra = 0; // extra byte(s) for each window to store additional window data 
    	wc.hInstance = hinst; // instance handler of applcation
    	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // large icon for window , NULL for default
    	wc.hCursor = LoadCursor(NULL, IDC_ARROW); // cursor for mouse
    	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); // handle of brush for window background
    	wc.lpszMenuName = MAKEINTRESOURCE(resPoolID); // menu for window, NULL if no menu
    	wc.lpszClassName = ClassName; // window class name
    	wc.hIconSm = LoadIcon(NULL,IDI_WINLOGO); // small icon for window
    
    	// register class into Windows and return the ATOM result
    	// 0 if fail
    	if(!RegisterClassEx(&wc))
    	 return false;
    
    	return true;
    }

    Thanks for reading this post!

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    The wndproc cannot be a non-static member function.

    This older thread might be of help.

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    one problem is that you're passing the virtual wndProc function into the RegisterClass. You can not pass a C++ virtual function into a windows API. It must be a C style function (global or static). Yes, unfortunately this means you do not have a "this" pointer inside that Wndproc but that can be obtained from the hwnd. SetWindowLongPtr and GetWindowLongPtr allow you to store a pointer in the HWND. Look up the GWLP_USERDATA variable. You can store the pointer to your class in that.

    edit:
    beat me to it.

    Well I explained it a little bit anyway.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    thanks all for the reply....didnt realise there have been so many threads bout this problem...i didnt know the right keyword to look for this problem...anyway i have read some of the threds and i'm still cracking my brain on how to solve the problem as i have lotsa of virtual function which complicates the matter...

    What i am trying to do is to write a base class which all types of window class (child,popup,overlapped) can be derived from.

    I will update my code ASAP for more advice and comment.

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    Sigh! Although the threads i read did make me understand much better of the problem, i didnt quite grasp the method of passing the "this" pointer into CreateWindow() and use SetWindowLong and GetWindowLong to redirect the message.

    I tried to implement a similar method using my way, but i dont understand why it didnt work.

    There are basically two problem i encountered:
    Before this, you might need the header for classes
    Code:
    class mainFrame:public skeleton // skeleton as base class
    {
    public:
    	mainFrame(HINSTANCE hInst, UINT name, UINT wndTitle, int nCmdShow,TCHAR* str);
    	~mainFrame(){};
    	
    	// function to register window class
    	virtual bool registerWindowClass(HINSTANCE hinst, UINT resPoolID);
    	// function to create window
    	virtual HWND createWindow(HINSTANCE hinst, int nCmdShow, UINT resPoolID, UINT title);
    	// window processing window
    	virtual LRESULT CALLBACK wndProc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam);
    
    
    private:
    	void mainWindow_onDestroy(HWND hwnd);
    	void mainWindow_onCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
    
    };
    
    // abstract class for any windows
    class skeleton
    {
    public:
    	// 1. constructor
    	skeleton(HINSTANCE hInst, UINT name, UINT wndTitle, int nCmdShow, TCHAR* str);
    	// 2. destructor
    	virtual ~skeleton(){};
    	// 3. function to register window class
    	virtual bool registerWindowClass(HINSTANCE hinst, UINT resPoolID) = 0;
    	// 4. function to create window
    	virtual HWND createWindow(HINSTANCE hinst, int nCmdShow, UINT resPoolID, UINT title) = 0;
    	// 5. window processing window
        virtual LRESULT CALLBACK wndProc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam) = 0;
    	// 6. static window proc
    	static LRESULT CALLBACK staticWndproc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam);
    	//7. initiliaze the window
    	bool initInstance();
    	//8. set ATOM for window properties
    	static void setWndProcname(TCHAR* str){wndProcname = GlobalAddAtom(str);}
    
    private:
    	static ATOM getWndProcname(){return wndProcname;}
    	static ATOM wndProcname;
    	HINSTANCE hInstance; // instance handle of application
    	UINT classname;		// class name
    	UINT title;			// title of window
    	int nWinMode;		// default height of window
    	
    };
    PROBLEM 1. why doesnt setProp,GetProp and RemoveProp accept the string parametter as an ATOM
    Code:
    // this is my static wndProc
    LRESULT CALLBACK skeleton::staticWndproc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam)
    {
    // it didnt accept what getWndProc() returned,e.g.
    //	WNDPROC wndProc= (WNDPROC)GetProp(hwnd,getWndProcname());
    // i had to hard code this to :
    WNDPROC wndProc= (WNDPROC)GetProp(hwnd,"mainFrame.wndProc");
    
    	return CallWindowProc(wndProc,hwnd,message,wParam,lParam);
    
    }
    
    Here is what my compiler said:
    C:\Documents and Settings\Edmund\My Documents\My eBooks\My expt files\windows workspace\skeleton\skeleton.cpp(40) : error C2664: 'GetPropA' : cannot convert parameter 2 from 'unsigned short' to 'const char *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    PROBLEM 2. I think my compiler think i gave it a void handler. Line 72 is the SetProp() function in the wndProc.

    Code:
    Error message:
    C:\Documents and Settings\Edmund\My Documents\My eBooks\My expt files\windows workspace\skeleton\mainFrame.cpp(72) : error C2440: 'type cast' : cannot convert from 'long (__stdcall mainFrame::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'v
    oid *'
    
    Code:
    // function to create window
    HWND mainFrame::createWindow(HINSTANCE hinst, int nCmdShow, UINT resPoolID, UINT title)
    {
    	HWND hwnd; // handler for window to be created
    	TCHAR ClassName[MAX_RESOURCESTRING+1]; // window class name
    	TCHAR wndTitle[MAX_RESOURCESTRING+1]; // window title
    
    	// load class name into ClassName
    	LoadString(hinst,resPoolID,ClassName,DIM(ClassName));
    	// load title name into title
    	LoadString(hinst,title,wndTitle,DIM(wndTitle));
    
    	hwnd = CreateWindowEx(0,			// extended window style
    						  ClassName,	// class name
    						  wndTitle,		// title
    						  WS_OVERLAPPEDWINDOW,	// window style
    						  CW_USEDEFAULT,		// default x-pos of window			
    						  0,	// y-pos of window, set 0 and use showWindow() to determine later
    						  400,	// width of window	
    						  400,	// height of window
    						  NULL, // parent of window
    						  LoadMenu(hinst, MAKEINTRESOURCE(resPoolID)),	// handle of menu
    						  hinst,	//handle of application
    						  NULL);	// user defined parameters, hardly any use for it
    	if(!hwnd)
    		return NULL;
    
    	// add wndProc handle to window properties
    	SetProp(hwnd,"mainFrame.wndProc",(HANDLE)wndProc);
    	
    	// make window appear
    	ShowWindow(hwnd,nCmdShow);
    	// force window to update
    	UpdateWindow(hwnd);
    
    	return hwnd;
    
    }

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I don't usually use SetProp and GetProp. I use SetWindowLongPtr and GetWindowLongPtr. Whichever makes you happy though

    What needs to happen is that you have to pass in the "this" pointer into the CreateWindow. Then you are to fish it out in the WM_CREATE message's CREATESTRUCT.

    Your original code was fine. All that needed to be changed I believe was the this pointer needed to be stored. The wndProc Pointer is already assigned to the window via the RegisterClass call
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #7
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    ok, i have temporarily abandon my SetProp/GetProp approach to try the conventional SetWindowLong/GetWindowLong method.

    Except i avoided the use of createStruct and i got some error. Here's the problem:
    Code:
    --------------------Configuration: skeleton - Win32 Debug--------------------
    Compiling...
    mainFrame.cpp
    C:\Documents and Settings\Edmund\My Documents\My eBooks\My expt files\windows workspace\skeleton\mainFrame.cpp(72) : error C2664: 'SetWindowLongA' : cannot convert parameter 3 from 'class mainFrame *const ' to 'long'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    skeleton.cpp
    C:\Documents and Settings\Edmund\My Documents\My eBooks\My expt files\windows workspace\skeleton\skeleton.cpp(46) : error C2664: 'CallWindowProcA' : cannot convert parameter 1 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__
    stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
            None of the functions with this name in scope match the target type
    Error executing cl.exe.
    
    skeleton.exe - 2 error(s), 0 warning(s)
    
    
    
    //IN THIS FUNCTION U WILL SEE THAT I ATTACHED THE THIS POINTER TO THE GWL_DATA RIGHT AFTER THE WINDOW IS CREATED WITH SETWINDOWLONG
    // function to create window
    HWND mainFrame::createWindow(HINSTANCE hinst, int nCmdShow, UINT resPoolID, UINT title)
    {
    	HWND hwnd; // handler for window to be created
    	TCHAR ClassName[MAX_RESOURCESTRING+1]; // window class name
    	TCHAR wndTitle[MAX_RESOURCESTRING+1]; // window title
    
    	// load class name into ClassName
    	LoadString(hinst,resPoolID,ClassName,DIM(ClassName));
    	// load title name into title
    	LoadString(hinst,title,wndTitle,DIM(wndTitle));
    
    	hwnd = CreateWindowEx(0,			// extended window style
    						  ClassName,	// class name
    						  wndTitle,		// title
    						  WS_OVERLAPPEDWINDOW,	// window style
    						  CW_USEDEFAULT,		// default x-pos of window			
    						  0,	// y-pos of window, set 0 and use showWindow() to determine later
    						  400,	// width of window	
    						  400,	// height of window
    						  NULL, // parent of window
    						  LoadMenu(hinst, MAKEINTRESOURCE(resPoolID)),	// handle of menu
    						  hinst,	//handle of application
    						  NULL);	// user defined parameters, hardly any use for it
    	if(!hwnd)
    		return NULL;
    
    	// add wndProc handle to window properties
    	SetWindowLong(hwnd,GWL_USERDATA,this);
    	
    	// make window appear
    	ShowWindow(hwnd,nCmdShow);
    	// force window to update
    	UpdateWindow(hwnd);
    
    	return hwnd;
    
    }
    
    // this is my static wndProc which always call the non static wndproc
    LRESULT CALLBACK skeleton::staticWndproc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam)
    {
    	mainFrame *mf = (mainFrame*)GetWindowLong(hwnd,GWL_USERDATA);
    
    	
    	return CallWindowProc(mf->wndProc,hwnd,message,wParam,lParam);
    
    
    }
    I tried to amend which the staticWndproc as below(which solved the second error), but i think it's not really the right way.

    Code:
    // this is my static wndProc which always call the non static wndproc
    LRESULT CALLBACK skeleton::staticWndproc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam)
    {
    	mainFrame *mf = (mainFrame*)GetWindowLong(hwnd,GWL_USERDATA);
    
    	
    	return mf->wndProc(hwnd,message,wParam,lParam);
    
    }

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    //IN THIS FUNCTION U WILL SEE THAT I ATTACHED THE THIS POINTER TO THE GWL_DATA RIGHT AFTER THE WINDOW IS CREATED WITH SETWINDOWLONG
    This is effectively subclassing the window and it will probably die a horrible death if you used your static window procedure (skeleton::staticWndproc) as the window procedure when you registered your window class. If you you do want to 'avoid the CREATESTRUCT' approach and stick with window subclassing then use DefWindowProc when you register your window class; that way the system will provide default handling for window creation messages.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    one thing that's wrong is that you are not checking the return value of GetWindowLong. It will be NULL at least a couple times because the static wndProc gets called for a couple things before CreateWindow returns.

    Why do you want to avoid the CREATESTRUCT again?

    Doesn't matter I suppose, but the cast i think it is looking for is

    CallWindowProc((WNDPROC)mf->wndProc,hwnd,message,wParam,lParam);
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  10. #10
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    This is effectively subclassing the window and it will probably die a horrible death if you used your static window procedure (skeleton::staticWndproc) as the window procedure when you registered your window class.
    The whole idea of using SetWindowLong n GWL_USERDATA is to subclass so that i can use my non-static wndProc as the window processing function. All msg to handled by the non-static wndProc is directed to it by staticWndProc,else DefWindowProc handles it. But why is it not good to use my static window procedure (skeleton::staticWndproc) as the window procedure when i registered my window class. Sorry, i am a slow learner. Could u explain more about what u mean?

    Code:
    CallWindowProc((WNDPROC)mf->wndProc,hwnd,message,wParam,lParam);
    Even if i typecast it, it still give me error.
    Code:
    --------------------Configuration: basicWrite - Win32 Debug--------------------
    Compiling...
    skeleton.cpp
    C:\Documents and Settings\Edmund\My Documents\My eBooks\My expt files\windows workspace\skeleton\skeleton.cpp(48) : error C2440: 'type cast' : cannot convert from '' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
            None of the functions with this name in scope match the target type
    Error executing cl.exe.

  11. #11
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I'm sorry, I screwed up there

    what you actually want to do is call the function directly as you had done. After that you need to call DefWindowProc to get the default action for messages you don't handle.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  12. #12
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    one thing that's wrong is that you are not checking the return value of GetWindowLong. It will be NULL at least a couple times because the static wndProc gets called for a couple things before CreateWindow returns
    Why do you want to avoid the CREATESTRUCT again?.
    i sort of solved the problem. Hence, i didnt have to use CreateStruct. I am avoiding it to shorten the code. I tot it would be a good idea to avoid some steps if possible. I wonder if this is a good idea. Is it more efficient(probably not a big difference)?

    Code:
    // initiliaze the window
    bool skeleton::initInstance()
    {
    	// register window class
    	if(!registerWindowClass(hInstance,classname))
    		return false;
    		
    	// create the application's window
    	hAppWnd = createWindow(hInstance,nWinMode,classname,title);
    	
    	if(!hAppWnd)
    	return false;
    	else
    	return true;
    }
    
    // function to register window class
    bool mainFrame::registerWindowClass(HINSTANCE hinst, UINT resPoolID) 
    {
    	WNDCLASSEX wc; // window class structure
    	TCHAR ClassName[MAX_RESOURCESTRING+1]; // string to load classname
    
    	// load class name into ClassName
    	LoadString(hinst,resPoolID,ClassName,DIM(ClassName));
    
    	// fill in window classs structure with parameters that describe the window
    	wc.cbSize = sizeof(WNDCLASSEX); // specify size of window class structure
    	wc.style = CS_HREDRAW | CS_VREDRAW ; // window class style
    	wc.lpfnWndProc = (WNDPROC) staticWndproc;  // window process function
    	wc.cbClsExtra = 0; // extra byte(s) to store additional information about a class, 
    					   //shared by all windows of the class
    	wc.cbWndExtra = 0; // extra byte(s) for each window to store additional window data 
    	wc.hInstance = hinst; // instance handler of applcation
    	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // large icon for window , NULL for default
    	wc.hCursor = LoadCursor(NULL, IDC_ARROW); // cursor for mouse
    	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); // handle of brush for window background
    	wc.lpszMenuName = MAKEINTRESOURCE(resPoolID); // menu for window, NULL if no menu
    	wc.lpszClassName = ClassName; // window class name
    	wc.hIconSm = LoadIcon(NULL,IDI_WINLOGO); // small icon for window
    
    	// register class into Windows and return the ATOM result
    	// 0 if fail
    	if(!RegisterClassEx(&wc))
    	 return false;
    
    	return true;
    }
    
    // function to create window
    HWND mainFrame::createWindow(HINSTANCE hinst, int nCmdShow, UINT resPoolID, UINT title)
    {
    	HWND hwnd; // handler for window to be created
    	TCHAR ClassName[MAX_RESOURCESTRING+1]; // window class name
    	TCHAR wndTitle[MAX_RESOURCESTRING+1]; // window title
    	HDC hDC;
    
    	// load class name into ClassName
    	LoadString(hinst,resPoolID,ClassName,DIM(ClassName));
    	// load title name into title
    	LoadString(hinst,title,wndTitle,DIM(wndTitle));
    
    	hwnd = CreateWindowEx(0,			// extended window style
    						  ClassName,	// class name
    						  wndTitle,		// title
    						  WS_OVERLAPPEDWINDOW,	// window style
    						  CW_USEDEFAULT,		// default x-pos of window			
    						  0,	// y-pos of window, set 0 and use showWindow() to determine later
    						  400,	// width of window	
    						  400,	// height of window
    						  NULL, // parent of window
    						  LoadMenu(hinst, MAKEINTRESOURCE(resPoolID)),	// handle of menu
    						  hinst,	//handle of application
    						  this);	// user defined parameters, hardly any use for it
    	if(!hwnd)
    		return NULL;
    
    	SetWindowLong(hwnd,GWL_USERDATA,(long)this);
    
    	// make window appear
    	ShowWindow(hwnd,nCmdShow);
    
    	// force window to update
    	UpdateWindow(hwnd);
    
    	return hwnd;
    
    }
    LRESULT CALLBACK skeleton::staticWndproc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam)
    {
    	mainFrame *mf = NULL;
    		 // pass all msg to non static wndProc once address of class is received
    			 mf = (mainFrame*)GetWindowLong(hwnd,GWL_USERDATA);	
    		     if(mf)
    			 return mf->wndProc(hwnd,message,wParam,lParam);
    			 else
    			 return DefWindowProc(hwnd, message, wParam, lParam);
    	
    
    }

  13. #13
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    Sorry just read this after my last post.

    what you actually want to do is call the function directly as you had done. After that you need to call DefWindowProc to get the default action for messages you don't handle.
    I read it in a book that i should not call the window function directly (e.g. return mf->wndProc(hwnd,message,wParam,lParam); ) because

    This is because a message may require additional processing as it is sent to a window procedure. It also accounts for the fact that only on some platforms, or under some conditions, there may be additional processing required to call a window procedure. In win32, this may involve Unicode translations.

  14. #14
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    >> this); // user defined parameters, hardly any use for it

    You're already doing half of the work there!
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  15. #15
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    sorry hehe...i forgot to set it to NULL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM
  5. Putting WndProc into a class?
    By Eber Kain in forum Windows Programming
    Replies: 3
    Last Post: 12-13-2001, 06:46 PM