Skip to main content
gamedev.net
🔒 Locked

WinApi

Started by Songoku 3 replies 400+ views
Original Post
Songoku
Songoku
Hi there, i have a real problem. I am improving my base code and i want to do it very well. So i first made a few design choices and got a problem. I want to create a window class which holds a function LRESULT CALLBACK WndProc(HWND....). But it does not work. Is there a way to get the windows callback funtion into a class. I want the function to be really inside the class and not to be outside the class and then to use a function pointer to the outer global windows callback funtion inside my class. Thanks for help and sorry for my bad english.
Daaark
Daaark
There is an article on this site about doing just that. I forget what it's called, but I think it's fairly recent.
SiCrane
SiCrane
Due to calling convention limitations, you can't assign a normal member function as the window procedure, but you can assign a static member function. That function, in turn, can call a member function after extracting a pointer from the window procedure, usually through the GWL_USERDATA flag with GetWindowLongPtr(). This data is usually assigned when handling the WM_NCCREATE message, from the LPCREATESTRUCT that is passed during window creation.

For more information, you might want to read this article.
Songoku
Songoku
should i look up under the link articles???
Songoku
Songoku
thanks i am reading the article.

Topic Locked

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

Sign in to reply to this topic.