Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > Windows Forms

Windows Forms Discussion related to Winforms application development

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-28-2008, 2:17 PM
ALX ALX is offline
VB.NET Forum Fanatic
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Nov 2005
Location: Columbia, SC
Posts: 135
Reputation: 57
ALX is on a distinguished programming path ahead
Default Repeating Events

In several forms I use an event handler for the resize event. When a particular form is minimized, I need to do a quick clean up of related forms, also displayed, to clear the screen. When the same form is then maximized, I run a process to restore those related forms. I've noticed that 'some' of the (maximize) resize events get called twice (sequentially) by the system's "external code" and others do not. This runs my restoration code twice and is a bit distracting for the user. The various forms are almost identical in their properties and code layout and yet some get maximized twice. Are there any insights out there on what causes these resize events to pop up sequentially like that and is there any way to prevent it?

Code:
Private Sub Me_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

        '  "Me" is a mostly transparent form overlying the main form "Frm"

        If Me.WindowState <> FormWindowState.Minimized And Frm IsNot Nothing Then
            Frm.Show()      '   This is the main underlying form.
            RefreshPages()  '   This is my restoration process for other related forms.
        End If
    End Sub
Attached Images
File Type: jpg Page0.jpg (16.3 KB, 18 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-28-2008, 4:37 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,318
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Why don't you use the Owner forms feature? Makes owned forms minimize/restore/close and overlay with the owner automatically.

Of curiosity I also checked Resize event when maximizing a form, and it does happen twice, but only once for WindowState Maximized. If you need to know that a regular resize event is not followed by a maximized/minimize/restore resize event you can use the ResizeBegin and ResizeEnd events, they don't occur for min/max/restore.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-28-2008, 10:16 PM
ALX ALX is offline
VB.NET Forum Fanatic
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Nov 2005
Location: Columbia, SC
Posts: 135
Reputation: 57
ALX is on a distinguished programming path ahead
Default

I seem to have problems controling the "z-order" of forms when I use the "Owner" and "Owned" forms properties. Invariably, the form I need on top is hidden below all other forms and the ones I need in between are in the wrong order when the screen is restored. Of course I can use the "Topmost" property for the top form but that doesn't help with the intermediate forms and sits on top of any other apps that get restored without minimizing my app.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 3:10 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.