HWND Problems ... Embbeding Windows into others

Just starting out? Need help? Post your questions and find answers here.
Yourself
User
User
Posts: 17
Joined: Fri Jan 18, 2008 2:47 pm

HWND Problems ... Embbeding Windows into others

Post by Yourself »

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!
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Code please.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Yourself
User
User
Posts: 17
Joined: Fri Jan 18, 2008 2:47 pm

Oh sure...

Post by Yourself »

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!

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())
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!
Yourself
User
User
Posts: 17
Joined: Fri Jan 18, 2008 2:47 pm

Bump

Post by Yourself »

This is bump. C'mon please help me!
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Your game maker code doesn´t have a window :shock:

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 
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Throw in a IsWindow_() into the message box to be absolutely certain.
I may look like a mule, but I'm not a complete ass.
Yourself
User
User
Posts: 17
Joined: Fri Jan 18, 2008 2:47 pm

Post by Yourself »

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 -

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.

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 ?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

A double? You don't mean a 64-bit floating point value do you?

Do you mean a quad value?
I may look like a mule, but I'm not a complete ass.
Yourself
User
User
Posts: 17
Joined: Fri Jan 18, 2008 2:47 pm

Post by Yourself »

Never mind! I found the Trunc() function which does this for me.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

PB doesn't have a Trunc().
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
All numbers in GM are type.d in PB.
Post Reply