By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,053 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,053 IT Pros & Developers. It's quick & easy.

Flashing when switching mdi forms

P: n/a
I have a parent form which contains a toolbar. The toolbar controls the
loading and switching to of MDI child forms.

The code for the toolbar click event and one of the subroutines that loads
and shows a child form is:

Private Sub tbMenu_ButtonClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbMenu.ButtonClick
Dim btn As System.Windows.Forms.ToolBarButton
For Each btn In Me.tbMenu.Buttons
If Me.Tag = e.Button.Tag Then
btn.Pushed = True
Else
btn.Pushed = False
End If
Next
Select Case e.Button.Tag
Case "0"
AccountEnquiry()
Case "1"
PostInvoice()
Case "99"
Me.Close()
End Select
End Sub
Private Sub AccountEnquiry()
' Account Enuiry
Static frm As New frmPurchaseLedgerAccount
Try
If IsNothing(frm) Then frm = New frmPurchaseLedgerAccount
With frm
..SuspendLayout()
..MdiParent = Me
..WindowState = Windows.Forms.FormWindowState.Maximized
..BringToFront()
..Show()
..ResumeLayout()
End With
Catch
frm = Nothing
AccountEnquiry()
End Try
End Sub
This works fine when the toolbar button is first clicked. The form just
loads and displays.

However, if you then click to another child form and then click back, you
can see the form display and then expand to maximised within the parent form
which flickers and is annoying. I tried inserting the suspendlayout and
resume layouts to see if that helps but it doesn't. Can anybody suggest a
way to stop the flickering?

Thanks in advance
Simon
--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD

Tel: 0870 080 2300
Fax: 0870 735 0011
Mar 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Simon, I am clear what you mean. Why do you not post the lines (and
only the lines) that show your problem, so that we can replicate the
problem and suggest a solution?

It may just be a matter of use activate() instead of bring to front...
(?)

-tom
Simon Verona ha scritto:
I have a parent form which contains a toolbar. The toolbar controls the
loading and switching to of MDI child forms.

The code for the toolbar click event and one of the subroutines that loads
and shows a child form is:

Private Sub tbMenu_ButtonClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbMenu.ButtonClick
Dim btn As System.Windows.Forms.ToolBarButton
For Each btn In Me.tbMenu.Buttons
If Me.Tag = e.Button.Tag Then
btn.Pushed = True
Else
btn.Pushed = False
End If
Next
Select Case e.Button.Tag
Case "0"
AccountEnquiry()
Case "1"
PostInvoice()
Case "99"
Me.Close()
End Select
End Sub
Private Sub AccountEnquiry()
' Account Enuiry
Static frm As New frmPurchaseLedgerAccount
Try
If IsNothing(frm) Then frm = New frmPurchaseLedgerAccount
With frm
.SuspendLayout()
.MdiParent = Me
.WindowState = Windows.Forms.FormWindowState.Maximized
.BringToFront()
.Show()
.ResumeLayout()
End With
Catch
frm = Nothing
AccountEnquiry()
End Try
End Sub
This works fine when the toolbar button is first clicked. The form just
loads and displays.

However, if you then click to another child form and then click back, you
can see the form display and then expand to maximised within the parent form
which flickers and is annoying. I tried inserting the suspendlayout and
resume layouts to see if that helps but it doesn't. Can anybody suggest a
way to stop the flickering?

Thanks in advance
Simon
--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD

Tel: 0870 080 2300
Fax: 0870 735 0011


Mar 21 '06 #2

P: n/a


<to**************@uniroma1.it> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Hi Simon, I am clear what you mean. Why do you not post the lines (and
only the lines) that show your problem, so that we can replicate the
problem and suggest a solution?

It may just be a matter of use activate() instead of bring to front...
(?)

-tom
Simon Verona ha scritto:
I have a parent form which contains a toolbar. The toolbar controls the
loading and switching to of MDI child forms.

The code for the toolbar click event and one of the subroutines that
loads
and shows a child form is:

Private Sub tbMenu_ButtonClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
tbMenu.ButtonClick
Dim btn As System.Windows.Forms.ToolBarButton
For Each btn In Me.tbMenu.Buttons
If Me.Tag = e.Button.Tag Then
btn.Pushed = True
Else
btn.Pushed = False
End If
Next
Select Case e.Button.Tag
Case "0"
AccountEnquiry()
Case "1"
PostInvoice()
Case "99"
Me.Close()
End Select
End Sub
Private Sub AccountEnquiry()
' Account Enuiry
Static frm As New frmPurchaseLedgerAccount
Try
If IsNothing(frm) Then frm = New frmPurchaseLedgerAccount
With frm
.SuspendLayout()
.MdiParent = Me
.WindowState = Windows.Forms.FormWindowState.Maximized
.BringToFront()
.Show()
.ResumeLayout()
End With
Catch
frm = Nothing
AccountEnquiry()
End Try
End Sub
This works fine when the toolbar button is first clicked. The form just
loads and displays.

However, if you then click to another child form and then click back, you
can see the form display and then expand to maximised within the parent
form
which flickers and is annoying. I tried inserting the suspendlayout and
resume layouts to see if that helps but it doesn't. Can anybody suggest
a
way to stop the flickering?

Thanks in advance
Simon
--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD

Tel: 0870 080 2300
Fax: 0870 735 0011


Ok.

It's hard to tell exactly which line causes the problem.

What I'm trying to do is manage MDI forms in code using a toolstrip with
buttons on.

Each time a button on the toolstrip is clicked, the mdi child form for that
button will be created is it doesn't exist and then maximised to fill the
parent mdi form space.

The code I use to instantiate the child form and then display it is :

Private Sub AccountEnquiry()
' Account Enuiry
Static frm As New frmPurchaseLedgerAccount
Try
If IsNothing(frm) Then frm = New frmPurchaseLedgerAccount
With frm
.SuspendLayout()
.MdiParent = Me ' Makes sure the child form is a mdi child
.WindowState = Windows.Forms.FormWindowState.Maximized ' this
maximises it to fill the window
.BringToFront() ' This makes sure it is the front mdi child
.Show() ' Shows the form
.ResumeLayout()
End With
Catch
' It hits here if the child form has been previously displayed and then
closed - it's then disposed so just needs setting to nothing and then
redisplaying
frm = Nothing
AccountEnquiry()
End Try
End Sub

On first instantiation the form just "shows" - already maximised in the
parent.

However, if the form already is instantiated and the user is simply
switching back to it, then the form will display in "normal" size (ie not
maximised) and will then "expand" to fill the window. This gives a
noticeable and annoying flickering.

Does that clarify?

Regards
Simon
Mar 22 '06 #3

P: n/a

"Simon Verona" <no****@nomail.zzz> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...


<to**************@uniroma1.it> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Hi Simon, I am clear what you mean. Why do you not post the lines (and
only the lines) that show your problem, so that we can replicate the
problem and suggest a solution?

It may just be a matter of use activate() instead of bring to front...
(?)

-tom
Simon Verona ha scritto:
I have a parent form which contains a toolbar. The toolbar controls the
loading and switching to of MDI child forms.

The code for the toolbar click event and one of the subroutines that
loads
and shows a child form is:

Private Sub tbMenu_ButtonClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
tbMenu.ButtonClick
Dim btn As System.Windows.Forms.ToolBarButton
For Each btn In Me.tbMenu.Buttons
If Me.Tag = e.Button.Tag Then
btn.Pushed = True
Else
btn.Pushed = False
End If
Next
Select Case e.Button.Tag
Case "0"
AccountEnquiry()
Case "1"
PostInvoice()
Case "99"
Me.Close()
End Select
End Sub
Private Sub AccountEnquiry()
' Account Enuiry
Static frm As New frmPurchaseLedgerAccount
Try
If IsNothing(frm) Then frm = New frmPurchaseLedgerAccount
With frm
.SuspendLayout()
.MdiParent = Me
.WindowState = Windows.Forms.FormWindowState.Maximized
.BringToFront()
.Show()
.ResumeLayout()
End With
Catch
frm = Nothing
AccountEnquiry()
End Try
End Sub
This works fine when the toolbar button is first clicked. The form just
loads and displays.

However, if you then click to another child form and then click back,
you
can see the form display and then expand to maximised within the parent
form
which flickers and is annoying. I tried inserting the suspendlayout and
resume layouts to see if that helps but it doesn't. Can anybody suggest
a
way to stop the flickering?

Thanks in advance
Simon
--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD

Tel: 0870 080 2300
Fax: 0870 735 0011


Ok.

It's hard to tell exactly which line causes the problem.

What I'm trying to do is manage MDI forms in code using a toolstrip with
buttons on.

Each time a button on the toolstrip is clicked, the mdi child form for
that button will be created is it doesn't exist and then maximised to fill
the parent mdi form space.

The code I use to instantiate the child form and then display it is :

Private Sub AccountEnquiry()
' Account Enuiry
Static frm As New frmPurchaseLedgerAccount
Try
If IsNothing(frm) Then frm = New frmPurchaseLedgerAccount
With frm
.SuspendLayout()
.MdiParent = Me ' Makes sure the child form is a mdi child
.WindowState = Windows.Forms.FormWindowState.Maximized ' this
maximises it to fill the window
.BringToFront() ' This makes sure it is the front mdi child
.Show() ' Shows the form
.ResumeLayout()
End With
Catch
' It hits here if the child form has been previously displayed and then
closed - it's then disposed so just needs setting to nothing and then
redisplaying
frm = Nothing
AccountEnquiry()
End Try
End Sub

On first instantiation the form just "shows" - already maximised in the
parent.

However, if the form already is instantiated and the user is simply
switching back to it, then the form will display in "normal" size (ie not
maximised) and will then "expand" to fill the window. This gives a
noticeable and annoying flickering.

Does that clarify?

Regards
Simon

Typical

A eureka moment just after I post !

If you put a frm.hide statement before the maximise statement in the code,
it then works with no flickering.

Regards
Simon

--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD

Tel: 0870 080 2300
Fax: 0870 735 0011
Mar 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.