In a few Windows applications I expand the functionality by positioning own windows on the application window.
On these windows gadgets with the desired functions are placed. That works for me, but when the main window is
moved, the additional windows stay where they are.
Then I had the idea, to use the optional parameter ParentWindowID in OpenWindow(), but there was no change.
But when I use the API function SetParent(), it works. My own windows are moved with the program window.
Now I wonder which function performs the ParentWindowID parameter in OpenWindow().
ParentWindowID in OpenWindow()
Re: ParentWindowID in OpenWindow()
Have you given the parameter with WindowID() function? The submitted parent window id of PureBasic must get used together with WindowID(). The WindowID() function seems to return the Windows-API handle of the window.
Re: ParentWindowID in OpenWindow()
I prefer to use Parentwindowid over SetParent_() for many reasons
Control the movement with Windows CallBack or BindEvent()
Believe me
Control the movement with Windows CallBack or BindEvent()
Believe me

Egypt my love
Re: ParentWindowID in OpenWindow()
@Kukulkan
the parent window is not a PB window. I had to use the API function FindWindow() to get the handle.
the parent window is not a PB window. I had to use the API function FindWindow() to get the handle.
Last edited by drahneir on Fri Jan 09, 2015 8:52 am, edited 2 times in total.
Re: ParentWindowID in OpenWindow()
@RASHAD
The use of Window callback makes my simple program too complicated.
The use of Window callback makes my simple program too complicated.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: ParentWindowID in OpenWindow()
The parent parameter in the OpenWindow command doesn't set a parent-child relationship like SetParent does. It's about zorder and what gets drawn in front of what. Try this little test:
1. We begin by creating two windows in different locations. We did not use the ParentID parameter.
2. Drag the larger window to the top corner of the screen. Note that it draws over top of the second window.
3. Close the program and move the comment to the other OpenWindow command. Now we are using ParentID.
4. Drag the larger window to the top corner of the screen. Note that it draws behind the second window now.
That's a demonstration of all of everything that the ParentID parameter is designed for. If you need to create a true child window, you must use SetParent.
Code: Select all
OpenWindow(0,0,0,640,480,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
;OpenWindow(1,0,0,320,240,"",0, WindowID(0))
OpenWindow(1,0,0,320,240,"")
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
2. Drag the larger window to the top corner of the screen. Note that it draws over top of the second window.
3. Close the program and move the comment to the other OpenWindow command. Now we are using ParentID.
4. Drag the larger window to the top corner of the screen. Note that it draws behind the second window now.
That's a demonstration of all of everything that the ParentID parameter is designed for. If you need to create a true child window, you must use SetParent.
BERESHEIT
Re: ParentWindowID in OpenWindow()
Or in other words: SetParent() set the parent for a child window, ParentWindowID set the owner of the window you are about to open.
So yes the name can be confusing.
So yes the name can be confusing.
msdn wrote: An owned window is always above its owner in the z-order.
The system automatically destroys an owned window when its owner is destroyed.
An owned window is hidden when its owner is minimized.
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: ParentWindowID in OpenWindow()
Maybe Fred would be open to changing the name to 'OwnerWindowID' because this 'parent' misconception happens regularly.
BERESHEIT
Re: ParentWindowID in OpenWindow()
ParentWindowID is exactly as
SetWindowLongPtr_( WindowID(2), #GWL_HWNDPARENT,WindowID(1))
Unfortunately no guaranty that both SetParent_() or ParentWindoID can do the job between external window created by external application and a window created by PB
Try with NotePad.exe for example
drahneir mentioned that later on
SetWindowLongPtr_( WindowID(2), #GWL_HWNDPARENT,WindowID(1))
Unfortunately no guaranty that both SetParent_() or ParentWindoID can do the job between external window created by external application and a window created by PB
Try with NotePad.exe for example
drahneir mentioned that later on
Egypt my love
Re: ParentWindowID in OpenWindow()
OK gentlemen, thanks for your explanations.
@netmaestro
That was an impressive demonstration.
@netmaestro
That was an impressive demonstration.