Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to avoid form flashing when resized

Posted on 2004-04-16
4
Medium Priority
?
195 Views
Last Modified: 2013-12-25
Hello,
I want a form to always keep the same Width/Height ratio when it is resized by the end-user, for example twice as wide as height.

Here is what I have written :
Private Sub Form_Resize()
    Dim H&, W&
    Static OldWidth&, OldHeight&, DoNoChange As Boolean
    'DoNoChange is used to avoid recurse process called from inside the Form_Load event
    If DoNoChange Then Exit Sub
    W = Width: H = Height
    If W <> OldWidth Then
        H = W /2: If Height <> H Then DoNoChange = True: Height = H: DoNoChange = False
    ElseIf H <> OldHeight Then
        W = H *2:  If Width <> W Then DoNoChange = True: Width = W: DoNoChange = False
        End If
    End If
    OldWidth = Width
    OldHeight = Height
End Sub

1> It works well when the form is resized by dragging its left border but not well when one drags the bottom border
2> The form "flashes" as long as the dragging process is not completed
How to specify that the resizing is still in process (telling the form "do not change the other dimension) or completed ("Do change the other dimension") ?

Thank you very much.
Philippe
Philippe.
0
Comment
Question by:MSelect
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 10844636
You cannot accomplish that without subclassing the form and trapping events for the window.

You could modify Ark's code here:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_20413753.html

Regards,

Idle_Mind
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 10844686
But you could cheat with a Timer control.

Private Sub Form_Resize()
Timer1.Enabled = True
Timer1.Interval = 500 'Adjust interval to suit
End Sub

Private Sub Timer1_Timer()
    Dim H&, W&
    Static OldWidth&, OldHeight&, DoNoChange As Boolean
    'DoNoChange is used to avoid recurse process called from inside the Form_Load event
    If DoNoChange Then Exit Sub
    W = Width: H = Height
    If W <> OldWidth Then
        H = W / 2: If Height <> H Then DoNoChange = True: Height = H: DoNoChange = False
    ElseIf H <> OldHeight Then
        W = H * 2: If Width <> W Then DoNoChange = True: Width = W: DoNoChange = False
        'End If
    End If
    OldWidth = Width
    OldHeight = Height
    Debug.Print Now
    Timer1.Enabled = False
End Sub


0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 10844705
Also take a look a this post: http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_10121021.html

It discusses the events you need to trap to determine when the form has stopped being resized.

Idle_Mind
0
 

Author Comment

by:MSelect
ID: 10849445
I well thought that a solution was in subclassing the window  ... but
1> I didn't know which WM_ messages I had to use
2> I hoped that there would be a "pure" VB solution

Thank you very much for your effort ...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question