losing my hInstance
In my main.cpp I declare
HWND hWnd;
HINSTANCE hInstance;
I get the instance and they window is made just fine.
In a .h file declare externs to them. When I try to use them hWnd works fine but hInstance is always NULL.
Any ideas? Thanks.
InFerN0
Not all who wander are lost...
InFerN0Not all who wander are lost...
I take it you are saving the value of hInstance passed by WinMain in your global hInstance. Coz if you create your window from the winmain function directly (e.g. no function calls) you will use the passed hInstance fine only within winmain itself.
Remember: If you have your source file like this:
WinMain''s hInstance is in scope, not the global hInstance. So the window creation will work fine, but if you try to access hInstance from another function, it will equal whatever value it was initialised to (e.g. NULL).
Waassaap!!
Remember: If you have your source file like this:
HWND hWnd;
HINSTANCE hInstance;
int APIENTRY
WinMain( HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nCmdShow)
{
//Window creation code
}
WinMain''s hInstance is in scope, not the global hInstance. So the window creation will work fine, but if you try to access hInstance from another function, it will equal whatever value it was initialised to (e.g. NULL).
Waassaap!!
Waassaap!!
basically,
in the first one, you''re simply assigning the hInstance from the parameter list to itself, because it''s in scope.. the second one will work fine..
------------------------
IUnknown *pUnkOuter
HINSTANCE hInstance;int WINAPI WinMain(HINSTANCE hInstance,/*etc...*/){ hInstance = hInstance;}/////////////////////////////////////////HINSTANCE hInstance;int WINAPI WinMain(HINSTANCE hInst,/*etc...*/){ hInstance = hInst;
in the first one, you''re simply assigning the hInstance from the parameter list to itself, because it''s in scope.. the second one will work fine..
------------------------
IUnknown *pUnkOuter
------------------------IUnknown *pUnkOuter"Try the best you cantry the best you canthe best you can is good enough" --Radiohead
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement