Dynamic hierarchy
Posted
#1
(In Topic #720)
Regular

Posted
Guru

Technopeasant said
I am wondering if there is any way to change the hierarchy of controls in code. The only way I know how is to generate the objects in code in the order you want them to be placed. This is annoying when you would want a control created from within the IDE to be above a control generated from within the program (i.e. the HUD elements in my new game Bring Them On). I could just generate the labels in code, but that does not seem like the optimum solution.
MyControlName.Raise() will bring it to the top. .Lower() to the bottom for your base objects
Posted
Guru

<IMG src="https://www.cogier.com/gambas/Heirarchy.png">
</IMG>
Posted
Regular

Thanks Bruce!
Would be kinda nice to be able to re-order controls in relation to each other and not just the parent, but it does the job.
EDIT: I am now curious about the Hide method. How is it different than changing the visibility?
Posted
Expert

I use something similar to set tool buttons in a horizontal panel - This example is set for a vertical sequence.
{As per your example}
If you want to centre them in the panel, you can use
Code (gambas)
- Ctrl.X = (InPanel/2) - (InW/2)
Because you are using the 'For Each' in the subroutine, it will use the sequence set in the hierarchy to process.
Code (gambas)
- Ctrl.Height = InH
- Ctrl.Width = InW
- Ctrl.X = Buffer
- Ctrl.Y = TmpPos
- TmpPos += (InH + Buffer)
Cheers - Quin.
I code therefore I am
I code therefore I am
1 guest and 0 members have just viewed this.

