VB Migration Partner

KNOWLEDGE BASE - Forms and controls


Previous | Index | Next 

[PRB] Shape and Line controls aren’t updated correctly

IMPORTANT: this article is only relevant for Shape and Line controls generated by VB Migration Partner 1.33 or earlier versions.

Under VB6, Shape and Line controls are updated immediately after you change one of their properties. To optimize refresh operations and minimize flickering in converted VB.NET applications, however, changing a property of a Shape or Line control simply invalidates its container, so that all the Shape and Line controls it contains are updated at once as soon as the entire form is refreshed, which in turn happens when the application enters the idle state.

This behavior is fine in most circumstances, but at times you might want the Shape or Line control to be updated immediately. For example, you might be implementing a rubber-banding technique and you want immediate feedback, yet the VB.NET Line or Shape control would be drawn only when the user releases the mouse button and the when the application enters the idle state.

There are two ways you can achieve immediate redrawing with Line and Shape controls. The first technique requires that you just set the Line or Shape control’s ImmediateUpdate property to True. This property – which is exposed by the VB6Line and VB6Shape controls – determines what happens when a property of the control is changed. If its value is False (the default), the control’s container is invalidated and therefore it will be refreshed at the first occasion; if you set it to True, the container is refreshed immediately. Therefore, the simplest way to achieve immediate feedback is setting this property, either via code or at design time, for example by means of a WriteProperty pragma:

        '## Shape1.WriteProperty ImmediateUpdate, True
        '## Line1.WriteProperty ImmediateUpdate, True

The problem with this approach is that it isn’t granular and in most cases it causes a lot of flickering, especially if you often modify many properties and if the container contains several Line and Shape controls. You can reduce such a flickering by leaving the ImmediateUpdate property to False and manually refreshing the containers after modifying a bunch of properties, as in this code:

        ' update many properties, possibly of several Line and Shape controls
        Shape1.Left = Shape1.Left + 10
        Shape1.Top = Shape1.Top + 10
        ' …
        ' refresh the container form only once, at the end of the operation
        '## InsertStatement Me.Refresh()
Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers