WndProc in wrapped class problem
I have wrapped up a window in a class, but WndProc has to be a static function of the class. But what if I want to make use of a variable from that class in the function.
Example. I have a member varaible called hInst. It is the HINSTANCE you get when you start a win application. but since WndProc is static I can't use normal member variables. So I thought I had to make the member variable static too. But that didn't help (Well it is probably my fault, because I am pretty sure it whould work. Here is a snapshot of the code. I guess I am messing up the function definition or something? Or any other advice?
.h file
Code:
class Device{
public:
Device();
~Device();
private:
static LRESULT WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
static HINSTANCE hInst; // Hinstance to our window
};
.c file
Code:
LRESULT CALLBACK Device::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
static PAINTSTRUCT paintstruct;
switch (message){
//This is sent following WM_NCCREATE -- we can assume our window is up
//If it gets this far
case WM_CREATE:{
CreateWndControls(hwnd, hInst);
FillControls();
break;
}
Cheers,
RyanJ
__________________
Re: WndProc in wrapped class problem
Re: WndProc in wrapped class problem
Quote:
Originally Posted by barrensoul
Right, I will read through that,
Thanks,
RyanJ
Re: WndProc in wrapped class problem
And you are sure your compiler takes the C file and treats its contents as C++ source? I think this might also be a problem. If you have changed that behaviour you should better go and rename it to .cc or .cpp instead because it is more segnificant either for you and the other programms and for the compiler which language it contains.