Click here to Skip to main content
15,868,164 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Minimize 3 forms pressing the minimize button on main form Pin
dilkonika2-Apr-14 12:00
dilkonika2-Apr-14 12:00 
GeneralRe: Minimize 3 forms pressing the minimize button on main form Pin
Dave Kreskowiak2-Apr-14 13:04
mveDave Kreskowiak2-Apr-14 13:04 
GeneralRe: Minimize 3 forms pressing the minimize button on main form Pin
dilkonika2-Apr-14 13:30
dilkonika2-Apr-14 13:30 
GeneralRe: Minimize 3 forms pressing the minimize button on main form Pin
Dave Kreskowiak2-Apr-14 14:05
mveDave Kreskowiak2-Apr-14 14:05 
GeneralRe: Minimize 3 forms pressing the minimize button on main form Pin
dilkonika2-Apr-14 14:24
dilkonika2-Apr-14 14:24 
GeneralRe: Minimize 3 forms pressing the minimize button on main form Pin
Dave Kreskowiak2-Apr-14 17:27
mveDave Kreskowiak2-Apr-14 17:27 
AnswerRe: Minimize 3 forms pressing the minimize button on main form Pin
Bernhard Hiller2-Apr-14 21:09
Bernhard Hiller2-Apr-14 21:09 
AnswerRe: Minimize 3 forms pressing the minimize button on main form Pin
Alan N3-Apr-14 2:53
Alan N3-Apr-14 2:53 
This is quite an interesting problem. To get the desired Z-order then the main form must own Form2 and Form2 must own Form3. Having set that up we find that Form3 is unaffected by minimization of the MainForm/Form2 pair.

Form3 needs to be linked to Form2 in some way, but how? My first guess was to try the SizeChanged event but found that Form2 does not raise SizeChanged when MainForm is minimized. Next guess was the LocationChanged event but it's not that either. However VisibleChanged is raised by Form2 when MainForm minimizes or restores. So Form2 is hidden when MainForm is minimized and the solution to the problem becomes clear.

Form3 could subscribe to the VisibleChanged event of Form2 and set it's visibility but I chose to do it in a different way. In the test code Form2 hides/shows all the forms in it's OwnedForms collection in response to the VisibleChanged event.

Test code
=========
VB
Private Sub CreatePopups()
  Dim f2 As New Form()
  f2.Text = "First Popup"
  AddHandler f2.VisibleChanged, AddressOf Form_VisibleChanged
  REM owner is the main form
  f2.Show(Me)

  Dim f3 As New Form()
  f3.Text = "Second Popup"
  f3.Show(f2)
End Sub

Private Sub Form_VisibleChanged(sender As Object, e As EventArgs)
  Dim f As Form = DirectCast(sender, Form)
  For Each ownedForm As Form In f.OwnedForms
    ownedForm.Visible = f.Visible
  Next
End Sub

Alan.
GeneralRe: Minimize 3 forms pressing the minimize button on main form Pin
dilkonika3-Apr-14 7:51
dilkonika3-Apr-14 7:51 
QuestionFile system window in VB.net 2008 Express? Pin
Member 1071375231-Mar-14 10:48
Member 1071375231-Mar-14 10:48 
AnswerRe: File system window in VB.net 2008 Express? Pin
Dave Kreskowiak31-Mar-14 10:58
mveDave Kreskowiak31-Mar-14 10:58 
GeneralRe: File system window in VB.net 2008 Express? Pin
Member 107137521-Apr-14 4:48
Member 107137521-Apr-14 4:48 
QuestionError writing to windows Registry Pin
dilkonika31-Mar-14 8:06
dilkonika31-Mar-14 8:06 
AnswerRe: Error writing to windows Registry Pin
Richard Deeming31-Mar-14 8:34
mveRichard Deeming31-Mar-14 8:34 
GeneralRe: Error writing to windows Registry Pin
dilkonika31-Mar-14 8:55
dilkonika31-Mar-14 8:55 
GeneralRe: Error writing to windows Registry Pin
Richard Deeming31-Mar-14 9:05
mveRichard Deeming31-Mar-14 9:05 
GeneralRe: Error writing to windows Registry Pin
dilkonika31-Mar-14 9:12
dilkonika31-Mar-14 9:12 
GeneralRe: Error writing to windows Registry Pin
Richard Deeming31-Mar-14 9:17
mveRichard Deeming31-Mar-14 9:17 
GeneralRe: Error writing to windows Registry Pin
dilkonika31-Mar-14 9:25
dilkonika31-Mar-14 9:25 
GeneralRe: Error writing to windows Registry Pin
Richard Deeming31-Mar-14 9:33
mveRichard Deeming31-Mar-14 9:33 
GeneralRe: Error writing to windows Registry Pin
dilkonika31-Mar-14 9:45
dilkonika31-Mar-14 9:45 
GeneralRe: Error writing to windows Registry Pin
Richard Deeming31-Mar-14 9:49
mveRichard Deeming31-Mar-14 9:49 
GeneralRe: Error writing to windows Registry Pin
dilkonika31-Mar-14 10:08
dilkonika31-Mar-14 10:08 
GeneralRe: Error writing to windows Registry Pin
Richard Andrew x6431-Mar-14 10:42
professionalRichard Andrew x6431-Mar-14 10:42 
QuestionCompare databases structure Pin
dilkonika29-Mar-14 2:42
dilkonika29-Mar-14 2:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.