VB Migration Partner

KNOWLEDGE BASE - Language


Previous | Index | Next 

[HOWTO] Get rid of warnings related to Screen.MousePointer property

VB Migration Partner partially supports the Screen.MousePointer property, by mapping it to the MousePointer property of the Screen6 object, defined in the support library. This property internally delegates to the MousePointer property of the active form, because there is no easy way to affect the global screen pointer under the .NET Framework.

The Screen6.MousePointer property is marked as obsolete, which causes both a migration warning to be issued and a compiler warning that is listed inside Visual Studio’s Error List. With dozens or hundreds of such warnings, you might easily want to suppress them.

Suppressing the migration warning is simple: you just issue a DisableMessage pragma for message 80F4. Suppressing the compilation warning requires that you transforms the reference to Screen6.MousePointer into a reference to Screen6.ActiveForm.MousePointer:

 	'## project:DisableMessage 80F4
	'## project:PostProcess "\bScreen6\.MousePointer\b", "Screen6.ActiveForm.MousePointer"

The pragmas used when converting to C# are slightly different:

 	'## project:DisableMessage 80F4
	'## project:PostProcess "\bScreen6\.MousePointer\b", "Screen6.ActiveForm.MousePointer"

If you are inside a form, you can transform the Screen6.MousePointer reference into Me.MousePointer, which delivers more concise code. A typical VB6 project contains more forms than modules or classes, therefore you’d better form having a project-level pragma that transforms into Me.MousePointer and then one pragma in each module or class that transforms into Screen6.ActiveForm.MousePointer:

 	' use these pragmas at the project-level...
	'## project:DisableMessage 80F4
	'## project:PostProcess "\bScreen6\.MousePointer\b", "Me.MousePointer"

	' ...but use this pragma in each module or class that references Screen.MousePointer
	'## PostProcess "\bScreen6\.MousePointer\b", "Screen6.ActiveForm.MousePointer"

This are the pragmas to be used when converting to C#

	' use these pragmas at the project-level...
	'## project:DisableMessage 80F8
	'## project:PostProcess "\bVB6Project\.Screen\.MousePointer\b", "this.MousePointer"

	' ...but use this pragma in each module or class that references Screen.MousePointer
	'## PostProcess "\bVB6Project.Screen.MousePointer\b", 
	"VB6Project.Screen.ActiveForm.MousePointer"

You can easily apply these pragmas to all the projects you plan to convert by saving it into the VBMigrationPartner.pragmas file.

A completely different – and more effective – approach can be used when the Screen.MousePointer property is used to display the “wait” cursor (the hourglass) during a lengthy operation and to later restore the mouse pointer to its default when the operation is completed. In this cases you really want to change the global cursor, not just the cursor of the current form. In .NET this is possible by means of the Application.UseWaitCursor property. The following two pragmas do the trick:

  '## project:PostProcess "\bScreen6\.MousePointer = 
      (11|13|VBRUN\.MousePointerConstants\.vbHourglass|
      VBRUN\.MousePointerConstants\.vbArrowHourglass)\b", "Application.UseWaitCursor = True" 

  '## project:PostProcess "\bScreen6\.MousePointer = (0|1|VBRUN\.MousePointerConstants\.vbDefault|
      VBRUN\.MousePointerConstants\.vbArrow)\b", "Application.UseWaitCursor = False"

Use these pragmas when converting to C#:

  '## project:PostProcess "\bVB6Project.Screen\.MousePointer = (11|13|VBRUN\
  .MousePointerConstants\.vbHourglass|VBRUN\.MousePointerConstants\.vbArrowHourglass)\b", 
  "Application.UseWaitCursor = true"
  '## project:PostProcess "\bVB6Project.Screen\.MousePointer = (0|1|VBRUN\
  .MousePointerConstants\.vbDefault|VBRUN\.MousePointerConstants\.vbArrow)\b", 
  "Application.UseWaitCursor = false"
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