resize other form after form resize

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
I can get hung up on the simplest stuff. I've got a base form class that contains one of many other form classes that are added to the base form's controls collection and anchored to the boarders of the base form. When the base form is resized, the child form resizes along with the base form nicely. The child form also handles the resize event by resizing all of its controls to accommodate the new size. There is also one more modal form class that acts as a Help page. In the base form's resize event handler, the base form raises an event to also resize the Help form. It seems that this event is being called before the base form's child has been redrawn to the new size, and the help form needs to know the new sizes of the underlying form and controls in order to display properly. I've tried variations on the base form's resize event handler to try to force the base form's contained child form to update before raising the event for the Help page without success. I realize I could raise another event in the child form to update the Help form, but I'm trying to keep the code as simple and compact as possible as there are many different form classes that could be the child form (but only one at a time).

'A simplified version below...

Private Sub Me_Resize(ByVal sender As Object, ByVal e As System.EventArgs)

If Me.WindowState <> FormWindowState.Minimized Then

Me.Refresh ' Also tried Me.Invalidate, Me.Update...

Application.DoEvents() ' I thought this might force the repaint of the Child form... Nope !

RaiseEvent HelpResize() ' This event is raised before the base form's child has resized. I need to force
' all forms and controls to complete the resizing before this event is raised.

End If

End Sub

What I need is a statement like "Me.ChildForm.Refresh" or "Me.OwnedForms.Update" which, of course, is not an option. 'Any ideas ???
 
I'm not entirely sure I understand what all you have going on with the child form(s), is the "base form" an MDI Parent?
Or do all these "child forms" each inherit the "base form"?
 
The base form is basically a main menu. When the user selects a menu option, a new boarderless form class is instantiated, its "TopLevel" property is set to false and it is added to the main form's controls and anchored so that it will resize along with the main form. The app is Minimized, Maximized and Closed with the Main form's TitleBar controls. This is not an MDI arrangement. When the base form is resized, it raises an event to update the size & position of the help form. The problem is that the help page event is called before the base form's child has resized, which will change how the help page is displayed. new-2.jpg
 
I'm at work when I realize that I should be using the ResizeEND event in the main page instead of the resize event. 'Will try that when I get home. Sorry to waste bandwidth over me being an air head.
 
There is ResizeEnd event that you can try to use instead. Otherwise if you do Control.BeginInvoke in Resize event the method is called after Resize is finished processing.
 
Back
Top