Hi everyone - I figured I would broaden my audience on this forum topic from earlier today. Does anyone happen to have windows Declares to attach a window to a parent window so when you move the parent window the child window moves with it? Its what Christian has for OS X NSWindowMBS.AddChildWindow().
I think this would have to be done at the time the window is created (which is before you see any events / constructors in Xojo code)
The method CreateWindowEXW like
creates a new window with the supplied parent window as a child. Thereās no way to access this directly from Xojo
The closest I could find it the SetParent which seems like it will make a window be a child of an existing window
However this still doesnt seem to be quite the same as macOS where children move as a group with their parents
You might have to use calls to TileWindows
to do this āautomaticallyā as the parent window is moved
Update on SetParent - It was an easy declare to make, but it didnāt glue the child to the parent.
TileWindows:
What do you normally do when Win32API calls for an array (Integer Type) but we canāt pass that to an external function using a declare (I get this message and Iām new to declares on Win32API)?
Type: const HWND*
An array of handles to the child windows to arrange. If a specified child window is a top-level window with the style WS_EX_TOPMOST or WS_EX_TOOLWINDOW , the child window is not arranged. If this parameter is NULL , all child windows of the specified parent window (or of the desktop window) are arranged.
How would i pass this array to an external function? ā I found this answer in @eugenedakinās Declare eBook (http://scispec.ca/) Thanks Eugene!
Iām getting a failed code 0 - Ill keep at it and post working code then.
Oh no need Eugene ā I was saying that i answered my own question by reading your Declare book!
To pass an array to an external source you need to create a memory block and pass it as a pointer Thank you for writing that book! Now getting that function to work is my next challenge
Hope you are doing well @eugenedakin
Chuckle, Norm, you soooo know how this works I canāt tell you how many times I have been asked a ārushā question that quickly suffers from scope creep.
Its good - I canāt see the forest for the trees - literally
Google maps says that I am near the Alberta Saskatchewan border, about 1.5 hours from nowhereā¦ chuckleā¦ I just have to make sure that my truck is full of fuel and my power cords can charge my portable equipment. Roads? I donāt need any roads where I am ā¦ lolā¦
Ok this took a few declares to attach a child window to a parent window (Move the parent and the child follows seamlessly). Here is the sample project I built.
The View code is in ChildWindow.Open and the controller code is in the WindowsAPI module.
// SET PARENT OF THIS WINDOW TO MAIN WINDOW
Var setParentResultInt as Integer = WindowsAPI.setParent(Self.Handle, ParentWindow.Handle)
// SET CHILD BIT ON WINDOW STYLE
Var childStyle as Integer = WS_CHILDWINDOW
Var setWinStyleResultInt as Integer = WindowsAPI.SetWindowLong(Self.Handle, GWL_STYLE, childStyle)
// SET BORDER AROUND CHILD WINDOW
Var borderStyle as Integer = WS_BORDER
Var borderResultInt as Integer = WindowsAPI.SetWindowLong(Self.Handle, GWL_STYLE, borderStyle)
// SET CHILD X/Y POS VARIABLES
Var newXpos as Integer = (ParentWindow.Width/2 - self.Width/2)
Var newYpos as Integer = (ParentWindow.Height/2 - self.Height/2)
Var newW as Integer = Self.Width
Var newH as Integer = Self.Height
Var moveWinResultInt as Integer = WindowsAPI.MoveWindow(Self.Handle, newXpos, newYpos, newW, newH, True)
// UPDATE PARENT
Var updateWinResultInt as Integer = WindowsAPI.UpdateWindow(ParentWindow.Handle)