|
-
May 26th, 2005, 01:21 PM
#1
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
__________________
-
May 26th, 2005, 01:35 PM
#2
Re: WndProc in wrapped class problem
In C, you merely shoot yourself in the foot.
In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."
-
May 26th, 2005, 01:56 PM
#3
Re: WndProc in wrapped class problem
 Originally Posted by barrensoul
Right, I will read through that,
Thanks,
RyanJ
-
May 26th, 2005, 05:28 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|