Ken you're a saviour when it comes to windows programming.
Just a quick question:
Sets a new address for the window procedure.
As far as my reading goes, wouldn't that mean you can change the WNDPROC from your static, to your non-static after creation?
Where MessageProc() is the non-static message handler.
SetWindowLongPtr(hWnd, GWLP_WNDPROC, &MessageProc);
Although, a quick test of that after the creation of my hWnd object yielded the error:
Which makes me think that it can't be that simple.
error C2276: '&' : illegal operation on bound member function expression
So, back on topic.
I've switched my GetWindowLong() and SetWindowLong() to their superceding counterparts (though none of the parameters change, which makes me wonder why these were ever available in the first place...were the Ptrs added after?)
And it is indeed the (LPCREATESTRUCT) that is causing the problem (the MessageBox is popping up).
Another quick question:
Is that the equivalent typecast of:
Is one C, and the other C++ related?
And back to the main problem:
lpCreateParams is failing.
Just to show I'm researching and really trying to figure this out on my own...MSDN says:
However, lpCreateParams doesn't take any parameters, so it can't really be blamed for anything. I'm assuming the lpParam being referred to is the one in the CreateWindow() function.
Contains additional data which may be used to create the window. If the window is being created as a result of a call to the CreateWindow or CreateWindowEx function, this member contains the value of the lpParam parameter specified in the function call.
Looks like I'm setting it to NULL...so, off I go to find a value to set here...hmm...what would be appropriate? (It is now 11:02PM)
//CREATE OUR WINDOW
hWnd = CreateWindow(
ClassName, //OUR CLASS NAME
"Game", //THE TITLE FOR OUR WINDOW
WindowStyles, //APPLY OUR STYLES
(GetSystemMetrics(SM_CXSCREEN) / 2) - (Width / 2), //PLACE IN THE HORIZONTAL CENTRE
(GetSystemMetrics(SM_CYSCREEN) / 2) - (Height / 2), //PLACE IN THE VERTICAL CENTRE
Width, //WIDTH OF THE WINDOW
Height, //HEIGHT OF THE WINDOW
*hInstance, //OUR HINSTANCE
NULL); //OUR lpParam!!!
My first logical guess is to pass this as the lpParam...no dice...
I'll throw the question out there: what do I add? I'll keep on tossing in random variable names until somebody helps me out in hopes of getting lucky
Thanks for reading/skimming.
Whoa, whoa whoa.
CREATESTRUCT??? Jeez. Okay, I'm gonna go make one and see what happens. (11:41)
[in] Pointer to a value to be passed to the window through the CREATESTRUCT structure passed in the lpParam parameter of the WM_CREATE message. If an application calls CreateWindow to create a multiple-document interface (MDI) client window, lpParam must point to a CLIENTCREATESTRUCT structure.
No! No! No!
lpCreateParams is a parameter of the CREATESTRUCT? It's one big vicious circle! I'm gonna go watch Saturday Night Live in hopes that it'll be funny finally.
It WAS this
Turns out I misread the code before and wrote:
Note the position of the last else. Meaning the TempWindow->MessageProc() would never fire. The else has to be nested one level deeper in that chunk of code.
long __stdcall cWindow::SMessageProc(HWND hWnd, unsigned int Msg, WPARAM wParam, LPARAM lParam)
cWindow *TempWindow = (cWindow*)GetWindowLong(hWnd, GWL_USERDATA);
if(Msg == WM_NCCREATE)
LPCREATESTRUCT LPC = (LPCREATESTRUCT)lParam;
TempWindow = (cWindow*)LPC->lpCreateParams;
SetWindowLong(hWnd, GWL_USERDATA, (LONG)TempWindow);
MessageBox(NULL, "WM_NCCREATE Failed", "Error", MB_OK);
return DefWindowProc(hWnd, Msg, wParam, lParam);
return TempWindow->MessageProc(hWnd, Msg, wParam, lParam);
Hooray! Thanks for the point in the right direction Ken