Jump to content
  • Advertisement
Sign in to follow this  
pex22

Window::WNDPROC?

This topic is 4919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how can i use a WndProc from a class (for use in WNDCLASSEX)? i have tried to use a static (global) SWndProc and it will return ActiveWindow->WndProc() (ActiveWindow is the current active Window class) but it doesn't seems to work. SWndProc:
static LRESULT CALLBACK SWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
    {
	case WM_SYSCOMMAND:
	case WM_PAINT:
    case WM_CLOSE:
    case WM_DESTROY:
		break;
    default:
        return DefWindowProc(hwnd, msg, wParam, lParam);
    }
	if (&ActiveWindow)
		return ActiveWindow->WndProc(hwnd,msg,wParam,lParam);
	return 0;
}
RegisterClassEx:
	wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = SWndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = title.c_str();
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
	if (!RegisterClassEx(&wc))
	{
		r=0;
		goto RETURN;
	}
and i get an access violation and error code 2(GetLastError(), 2 means: "The system cannot find the file specified.")..its probably because SWndProc. i remember that in past, i changed many things (in switch(msg)) and i didnt get access violation.. how can i handle more than one WndProc for using multiple windows and each window will have a different 'main loop', or it is done in an other way? thanks, pex.

Share this post


Link to post
Share on other sites
Advertisement
I don't think you can. The way it is set up, it cannot be part of a class or structure. (I could be wrong, so lets see what others have to say [smile]).

Share this post


Link to post
Share on other sites
using WndProc inside the window creation function doesn't work because it is a part of a class, so you right about that.
but why SWndProc doesn't work, i dont understand.
am i just wasting time at this and it is not important?

Share this post


Link to post
Share on other sites
You only have one main loop in your program. However, each window / dialog box has it's own callback procedure. An example can be found in this topic.

If you want to know how to create a class wrapper then try here or here.

[Edit: Fixed one of your links.]

C++ is a mixed paradigm language - do you need to have the callback procedures encapsulated in a class?


HTH,
Jim.

Edit : beaten again...

[Edited by - Oluseyi on December 30, 2004 11:15:01 AM]

Share this post


Link to post
Share on other sites
hmm..i get a bit confused. sorry, i haven't seen the previous threads on this topic (i didnt knew its called wrapper class. it means i dont know what im coding. ahh!).
thanks guys!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!