Wrapper for OpenGL, can't user member function WndProc
I suggest you move PostQuitMessage to WM_NCDESTROY handler. You also don''t need to use break after return in switches.
quote:Original post by IndirectX
I suggest you move PostQuitMessage to WM_NCDESTROY handler. You also don''t need to use break after return in switches.
If I move the PostQuitMessage(0); call to WM_NCDESTROY, then it is impossible to close the window. Have to end it in the task manager.
How did you get your code to work? "this" is the lpCreateParams of CREATESTRUCT. I meant the following:
Am I missing something very obvious here?
SetWindowLong(hwnd, GWL_USERDATA, LPCREATESTRUCT(lparam)->lpCreateParams);
Am I missing something very obvious here?
Well, it compiled with no errors.
If I put the line in that you just specified, I get this error:
error C2664: ''SetWindowLongA'' : cannot convert parameter 3 from ''LPVOID'' to ''LONG''
I suppose I have to cast a LONG to it or something.
If I put the line in that you just specified, I get this error:
error C2664: ''SetWindowLongA'' : cannot convert parameter 3 from ''LPVOID'' to ''LONG''
I suppose I have to cast a LONG to it or something.
The proper way of closing the window is using DestroyWindow(hwnd) is WM_CLOSE and PostQuitMessage in WM_DESTROY, or WM_NCDESTROY.
If you click the close button or press Alt+F4, you get WM_CLOSE. However, to close a window from a program you call DestroyWindow(hwnd). Your method won''t work for DestroyWindow call.
If you click the close button or press Alt+F4, you get WM_CLOSE. However, to close a window from a program you call DestroyWindow(hwnd). Your method won''t work for DestroyWindow call.
Indeed.
I still don''t understand how your code works. As I see it, you are passing a pointer to this rather than this itself to SetWindowLong.
SetWindowLong(hwnd, GWL_USERDATA, long(LPCREATESTRUCT(lparam)->lpCreateParams));
I still don''t understand how your code works. As I see it, you are passing a pointer to this rather than this itself to SetWindowLong.
Well, I casted it to long and now it works.
As for how it worked before, I have no idea. I am using Microsoft VC++, so maybe that explains something...
As for how it worked before, I have no idea. I am using Microsoft VC++, so maybe that explains something...
Hmm, I do get 3 warnings however:
The first one is just WinMain returning the wparam.
The second one is when I use SetWindowLong:
and the last one is when I obtain a pointer to a CWindow:
[edited by - Wheaty on March 24, 2002 4:57:41 PM]
winmain.cpp(33) : warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of datacwindow.cppcwindow.cpp(92) : warning C4311: 'type cast' : pointer truncation from 'LPVOID' to 'long'cwindow.cpp(94) : warning C4312: 'type cast' : conversion from 'LONG' to 'CWindow *' of greater size
The first one is just WinMain returning the wparam.
The second one is when I use SetWindowLong:
SetWindowLong(hwnd, GWL_USERDATA, long(LPCREATESTRUCT(lparam)->lpCreateParams));
and the last one is when I obtain a pointer to a CWindow:
CWindow *pWindow = (CWindow*)GetWindowLong(hwnd, GWL_USERDATA);
[edited by - Wheaty on March 24, 2002 4:57:41 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement