Fixing groupbox sizing Win/Mac

I set up my groupboxes under macOS, and they and their content (checkboxes, radio buttons, etc) look as I want them to. Under Windows, it seems that the top 8 pixels or so of the groupbox is not used (or perhaps is used for the caption). Either way this resulted in the layout looking bad as the groupboxes were not tall enough.

A simple fix seemed to be that in the Open event I move Top up by 8px and increase Height by 8px. This restores the right size but controls contained within the groupbox get dragged upwards by 8px, so I have to add Open events for each control that add 8px to Height. And then the groupbox and its content look good.

Simple enough, but tedious if one has many groupboxes, so I’m wondering if there is a tidier or better way to do this. I develop under macOS and then, for Windows, test in W7 and W10 VMs, which are good enough for testing but a bit slow for development.

Any clues appreciated.

Maybe something like this in the Window’s Open event (replace GroupBox1 with the name of your group box control):

[code] 'handle differences in the group box control under win32
#If TargetWin32 Then
Dim count, i As Int32
Dim theControl As RectControl

'move the group box up and increase it's height as the groupbox margin is different under win32
GroupBox1.Top = GroupBox1.Top - 5
GroupBox1.Height = GroupBox1.Height + 5

'move all controls down as the groupbox margin is different under win32
count = Self.ControlCount - 1
For i = 0 To count
  theControl = RectControl(Self.Control(i))
  
  If theControl.Parent = GroupBox1 Then
    theControl.Top = theControl.Top + 5
  End If
Next

#EndIf[/code]

or better yet… make that a method and PASS the groupbox reference to it… this way you can just call it for ANY groupbox in you app

Yes, that worked nicely as a method - thanks guys.

The LR Says:

http://documentation.xojo.com/api/deprecated/targetwin32.html:

This item has been deprecated since version 2018r1 and should no longer be used.
Please use TargetWindows as a replacement.

Another options is a subclass of groupbox. Implement its open event to do this adjustment for all its child controls and then re-raise the open event so any instances on a layout can do custom stuff in their open events.