Page 1 of 1

Question: Parent and Child Windows?

Posted: Thu Oct 27, 2005 11:31 am
by neomlsra
I have an application in mind where I want there to be a main window with a series of views or child windows in it. Each view would contain separate distinct data elements that could be arranged to different locations within the parent window. I also want the views (child windows) to have the ability to be loaded and viewed as distinct separate windows themselves outside of the parent window where each view becomes its own parent if displayed on the desktop this way.

The question is can PureBasic handle this type of development in terms of having a master window with many childs that can be shifted around and the childs each becoming their own masters that can be turned on or off?

Concept explained differently:
  • Parent Window A contains child windows B, C, D and E.
    Child windows can be displayed as B,C,D and E or E,D,C and B or just B and C, etc.
    Child windows become parents that can be displayed or not. Example would be display just B and D on the desktop.
I am trying to understand Pure Basic's limits for this project before beginning this project as the overall project will be involved and take time to develop. I have learned my lessons over time concerning the homework to understand if an environment is the correct on for a particular project. This is especially true in terms of the world of mobile (PDAs). and less so on the desktop.

Thanks!

Posted: Fri Nov 25, 2005 1:02 am
by Randy Walker
Two things to keep in mind here. First, I'm not a programmer so consequently I've been known to come up with some really bad code and practices. Secondly, I'm not sure I understand exactly what you're trying to do but this may help.

Create main window and all your "independant" child windows.

Code: Select all

HWND_A = OpenWindow(#Window_A, etc...
HWND_B = OpenWindow(#Window_B, etc...
HWND_C = OpenWindow(#Window_C, etc...
HWND_D = OpenWindow(#Window_D, etc...
HWND_E = OpenWindow(#Window_E, etc... 
Then use SetParent_() to have the main window adopt those child windows.

Code: Select all

SetParent_(HWND_A,HWND_B)
SetParent_(HWND_A,HWND_C)
SetParent_(HWND_A,HWND_D)
SetParent_(HWND_A,HWND_E) 
You can use HideWindow() to hide or expose childen independantly as desired.
Hiding or minimizing the main window will always affect the children as well.

If you get the handle of the desktop you can use SetParent_(HWND_DeskTop,HWND_B) to make the desktop the parent of #Window_B if you want. The previous SetParent assignment here for HWND_B would automatically be cancelled. In other words, disregard previous custody and use SetParent freely thoughout your code whenever you want to change the parent of a window.

SetParent_() can also be used on external apps so you could make NotePad the child of your own app window. (Probably not wise to make the desktop a "Child" of one of your own windows so I wont recommend it.)