![]() |
|
Quick Question: HINSTANCE of Allegro |
Kris Asick
Member #1,424
July 2001
|
Under Windows, with Allegro, I know how to get the HWND property of the Allegro window, I know how to get the HDC property of Allegro bitmaps... ...but how do I get the HINSTANCE property of the application while using Allegro's magic main? I know, it's probably a stupid question, but every so often they come up... --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
CGamesPlay
Member #2,559
July 2002
![]() |
Google! "get hinstance from hwnd" http://cboard.cprogramming.com/archive/index.php/t-60642.html Quote: Use GetModuleHandle() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getmodulehandle.asp) to get a handle to the process (GetModuleHandle() returns a HMODULE, but it's the same as HINSTANCE on 32 bit windows). [append] Another Google result says (HINSTANCE)GetWindowLongA(hWnd, GWL_HINSTANCE), 0L); -- Ryan Patterson - <http://cgamesplay.com/> |
Kris Asick
Member #1,424
July 2001
|
I think the GetWindowLong() approach will work best, seeing as how in the future, HMODULE and HINSTANCE may not be the same thing. Thanks! --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
DanielH
Member #934
January 2001
![]() |
HWND hWnd = NULL; HWND hParent = NULL; HINSTANCE hInstance = NULL; hWnd = win_get_window(); hInstance = (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE ); hParent = (HWND)GetWindowLong( hWnd, GWL_HWNDPARENT );
|
Kris Asick
Member #1,424
July 2001
|
Yep. Figured that out as I looked up GetWindowLong in the MSDN libraries. I'm writing my own input handler to override the Allegro one, since I ran into a barricade trying to fix the one in Allegro under the Windows build without breaking Allegro in the process and couldn't do it. To access DirectInput though, I needed a handle to the application instance, which Allegro didn't have a built-in command for, but didn't want to switch from the magic main to WinMain. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
|