Jump to content
  • Advertisement
Sign in to follow this  
brwarner

Classes And Controls (WinAPI)

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

Hello, For one of my Controls I wanted to use a class to represent the control that would work like this:
#include "MyControl.h"

MyControl::MyControl(HWND hWnd)
{
WNDCLASSEX wc;
//Do stuff with wc
//Set wc WndProc to ControlProc ClassName="Contr"
RegisterClassEx(&wc);
CreateWindoxEx(/*Blah Blah Blah set parent = hWnd ClassName="Contr"*/);
}
LRESULT CALLBACK MyControl::ControlProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
//Cases
}
}

The compiler does not accept ControlProc and gives me an error. Says that I cannot convert CongtrolProc to something else

Share this post


Link to post
Share on other sites
Advertisement
You can't assign a pointer to a non-static member function to a pointer to a normal function. The usual method to handle this is to assign a static or normal function to the windows procedure and use GetWindowLong() or GetWindowLongPtr() to a pointer from the GWL_USERDATA of the windows class. When you do this, pass the pointer to the class instance as the lpParam argument in the CreateWindowEx() call.

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!