Skip to main content
GameDev.net gamedev.net
🔒 Locked

Windows Wrapper class problem

Started by dragonknightx Oct 11, 2004 at 11:56 PM 1 replies 550+ views
Original Post
dragonknightx
dragonknightx
I'm working on a Windows wrapper class, and I have almost everything in it working (I think), but I also have a major problem: when building the class (before calling RegisterClass), I can't seem to get it to set lpfnWndProc to my WndProc. The essential parts:


LRESULT CWindow::WindowProc(UINT Msg, WPARAM wParam, LPARAM lParam)
{
// Function body
}

bool CWindow::BuildWindow()
{ WNDCLASSEX WndCls;
	WndCls.cbSize = sizeof(WndCls);
	WndCls.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	WndCls.lpfnWndProc = CWindow::WindowProc; // This is causing the problem.
	WndCls.cbClsExtra = 0;
	WndCls.cbWndExtra = 0;
	WndCls.hInstance = CWindow::m_hInstance;
	WndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	WndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
	WndCls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	WndCls.lpszMenuName = NULL;
	WndCls.lpszClassName = "MainWindowClass";
	WndCls.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
}

(Never used the tags before, so I hope they work - a 'Preview' option would be nice...) I've tried all manner of solutions, but I apparently haven't tried the right one yet. Any tips?
--------------------------It's called a changeover. The movie goes on, and nobody in the audience has any idea.
Oluseyi
Oluseyi
It's a signature mismatch. The window procedure needs to be __stdcall, but your CWindow::WindowProc is of the __thiscall convention. You need to make it a static method to convert it, but that dissociates it from the CWindow instance.

Since I'm sure none of that made sense to you (which means that you need to read a lot more), read this article. And get into the habit of searching before posting; the web is littered with window class wrapper examples and tutorials.
dragonknightx
dragonknightx
Thanks for the reply. I ran across that error a few times in my many trials, and while I could make a bit of sense out of it (I knew it was specifying THIS call, which was somehow different from the STANDARD call), I didn't have a clue how to fix it, so I moved on.

BTW, how do I get to that page (through the site - I obviously have the URL, and it looks like exactly what I need); something tells me I'm hardly using this site to its fullest, and I'd like to change that.
--------------------------It's called a changeover. The movie goes on, and nobody in the audience has any idea.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.