Jump to content
  • Advertisement
Sign in to follow this  
GDMichael

Window Message Problem

This topic is 4748 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

Hi I try to develop a CWinApp Class, but I found there has a problem about WINDCLASSEX: m_wcex.cbSize = sizeof(WNDCLASSEX); m_wcex.style = CS_CLASSDC; m_wcex.lpfnWndProc = AppWindowProc; m_wcex.cbClsExtra = 0; m_wcex.cbWndExtra = 0; m_wcex.hInstance = m_hInst; m_wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION); m_wcex.hCursor = LoadCursor(NULL, IDC_ARROW); m_wcex.hbrBackground = NULL; m_wcex.lpszMenuName = NULL; m_wcex.lpszClassName = m_Class; m_wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION); m_wcex.lpfnWndProc = AppWindowProc; <-- I need to set the window proc name from the main.cpp. On the other words, I have a class member that is used to handle window message, but I cannot assign this member function to the lpfnWndProc. Why?

Share this post


Link to post
Share on other sites
Advertisement
Member function pointers are not equivalent to normal function pointers. Member functions in particular need to be bound to a particular object in order to be called, either with ->* or .*, but Windows doesn't know how to deal with that. You need to assign a normal function or a static class function as the WndProc.

For more information you might want to try this article.

Share this post


Link to post
Share on other sites
But If I have a main.cpp, CWinApp.cpp, CWinApp.h

main.cpp contains the window message:
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)


CWinApp.cpp contains WNDCLASSEX. So, how can I refer like that:
m_wcex.lpfnWndProc = WindowProc;

??

Share this post


Link to post
Share on other sites
yes michael, that should work.

alternatively you can try:

class WndClass
{
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
};

and assign that function (WndClass::WindowProc)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!