HWND Problems ... Embbeding Windows into others
HWND Problems ... Embbeding Windows into others
I'm using PB to make a dll for Game Maker by Mark Overmars.
I need to embed a PB created into the Game Maker window.
Game Maker provides the handle to the drawing window using the window_handle() function. I need to store this value in a variable of HWND type. Then I need to use the SetParent_() API to embed the PB window into the Game Maker one. This is not happening! As Pure Basic complains if I use gmhwnd.Hwnd i declared it as a long. I then used a MessageBox_() call to see
whether it would embed correctly into the Game Maker window. This does NOT happen. So how would I go on to make a variable of HWND type in PB so its value can be passed to API functions??
Please Help, and thanks in advance!
I need to embed a PB created into the Game Maker window.
Game Maker provides the handle to the drawing window using the window_handle() function. I need to store this value in a variable of HWND type. Then I need to use the SetParent_() API to embed the PB window into the Game Maker one. This is not happening! As Pure Basic complains if I use gmhwnd.Hwnd i declared it as a long. I then used a MessageBox_() call to see
whether it would embed correctly into the Game Maker window. This does NOT happen. So how would I go on to make a variable of HWND type in PB so its value can be passed to API functions??
Please Help, and thanks in advance!
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Oh sure...
This is the code of the MessageBox_() API problem as explained above.
The Message Box should embed on to the window with the specified HWND in the first argument. But when I run this as a dll from Game Maker , it does not!
The Message Box is displayed all right but its not displayed as part of the window ie, its got its own taskbar icon which it should not have!
The Message Box should embed on to the window with the specified HWND in the first argument. But when I run this as a dll from Game Maker , it does not!
Code: Select all
;Pure Basic code compiled as DLL
ProcedureDLL.l Message(gm_hwnd.l)
messageBox_(gm_hwnd,"Test","test",1)
ProcedureReturn 1
EndProcedure
Code: Select all
//Game Maker code which calls the dll
f = external_define("Test.dll","Message",dll_stdcall,ty_real,1,ty_real)
external_call(f,window_handle())
Your game maker code doesn´t have a window
You could test it with this PB-Code :

You could test it with this PB-Code :
Code: Select all
;Pure Basic code compiled as DLL
ProcedureDLL.l Message(gm_hwnd.l)
MessageBox_(gm_hwnd,"Test","Window-Handle :"+Str(gm_hwnd),1)
ProcedureReturn 1
EndProcedure
ABBKlaus , there's no need for me to create a window in GM like in PB. A window is auto- created render the game graphics.
The Game Maker help manual States - That's from the GM- Help file.
srod - I'm trying it.
Its not working despite the fact that i set it up properly.
I just remembered that when ever GM returns the handle its a double. Any way to convert it into a HWND ?
Trond has used Game Maker , can you help me Trond ?
The Game Maker help manual States -
Code: Select all
In some rare cases your DLL might need to know the handle of the main graphics window for the game. This can be obtained with the following function and can then be passed to the DLL:
window_handle() Returns the window handle for the main window.
srod - I'm trying it.
Its not working despite the fact that i set it up properly.
I just remembered that when ever GM returns the handle its a double. Any way to convert it into a HWND ?
Trond has used Game Maker , can you help me Trond ?
PB doesn't have a Trunc().
How to do it:
All numbers in GM are type.d in PB.
How to do it:
Code: Select all
;Pure Basic code compiled as DLL
ProcedureDLL.d Message(gm_hwnd_d.d)
gm_hwnd_l.l = gm_hwnd_d
messageBox_(gm_hwnd_d,"Test","test",1)
ProcedureReturn 1
EndProcedure