Microsoft KB Archive/110542

From BetaArchive Wiki

Article ID: 110542

Article Last Modified on 12/9/2003



APPLIES TO

  • Microsoft Visual Basic 2.0 Standard Edition
  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft Visual Basic 2.0 Professional Edition
  • Microsoft Visual Basic 3.0 Professional Edition



This article was previously published under Q110542

SUMMARY

You can have a Visual Basic application program set the mouse pointer (cursor) to an hour glass shape and wait. However, if the user moves the mouse over another application's window, the cursor will return to a mouse pointer. To force the cursor to maintain the hourglass shape even while over other windows, make the window a system modal window by using the SetSysModalWindow Windows API function.

MORE INFORMATION

Step-by-Step Instructions for Making a System Modal Window

  1. Start Visual Basic, or if Visual Basic is already running, choose New Project from the File menu (ALT, F, N). Form1 is created by default.
  2. Add the following code to the General Declarations section of Form1:

       Declare Function SetSysModalWindow% Lib "User" (ByVal hwnd%)
       Const HourGlass = 11
    
                            
  3. Add the following code to the Form_Load event of Form1:

       Sub Form1_Load ()
          Me.Show
          Screen.MousePointer = HourGlass
          ' Remove the following line to see how the mouse behaves without it
          result% = SetSysModalWindow%(form1.hWnd)
       End Sub
    
                            
  4. Add the following code to the Form_Click event of Form1:

       Sub Form1_Click ()
          Unload Form1
       End Sub
    
                            
  5. Run the program. Click the form to end it. Notice that the cursor remains an hourglass even when you move the mouse pointer over other windows.

For more information about the SetSysModalWindow Windows API function, see the Windows version 3.1 SDK help file that ships with the Professional Edition of Visual Basic for Windows.


Additional query words: 2.00 3.00

Keywords: KB110542