DOCUMENT:Q185637 18-MAY-1998 [vbwin] TITLE :HOWTO: Use APIs to Check, Enable, or Disable Full Window Drag PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:4.0,5.0 OPER/SYS:WINDOWS KEYWORDS: ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Control Creation, Learning, Professional, and Enterprise Editions for Windows, version 5.0 - Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0 --------------------------------------------------------------------- SUMMARY ======= Normally, when a window is moved or sized, the operating system informs the window by posting the appropriate messages at the end of the move or size operation. These messages include WM_MOVE, WM_WINDOWPOSCHANGED, WM_PAINT, and WM_SIZE among others. Windows NT 4.0 and Windows 95 (with the Microsoft Plus! add-in) offer the ability to show the entire contents of a window as it is moved or resized. The operating system accomplishes this by continuously sending these messages to the window during moving or resizing, not just at the end of the operation. This causes the window to redraw itself multiple times during one resize or move operation. At times, you may want to disable this feature to avoid possible flickering of the screen or to prevent code in an event like the ReSize event from occurring multiple times during one resize operation. Using the SystemParametersInfo API function, the status of this feature can be checked, enabled, or disabled as needed. This technique is demonstrated in the sample code below for both the 16- and 32-bit Visual Basic development environments. MORE INFORMATION ================ Steps to Create Sample 32-Bit Project ------------------------------------- 1. Create a new Visual Basic project. Form1 is created by default. 2. Paste the following code into the code module for Form1: Option Explicit Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, _ ByVal uParam As Long, ByRef lpvParam As Any, _ ByVal fuWinIni As Long) As Long Private Const SPI_GETDRAGFULLWINDOWS = 38 Private Const SPI_SETDRAGFULLWINDOWS = 37 Private Const SPIF_SENDWININICHANGE = 2 Private Function IsFullWindowDragOn() As Boolean Dim result As Long 'Call API and check for successful call. If SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0&, result, 0&) _ <> 0 Then 'Feature supported now check value of result. If result = 0 Then IsFullWindowDragOn = False Else IsFullWindowDragOn = True End If 'Call failed, feature not supported. Else IsFullWindowDragOn = False End If End Function Private Sub Form_Click() Dim result As Long 'Toggle the setting. If IsFullWindowDragOn Then 'Turn full window drag off. result = SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0&, _ ByVal vbNullString, SPIF_SENDWININICHANGE) Else 'Turn full window drag on. result = SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1&, _ ByVal vbNullString, SPIF_SENDWININICHANGE) End If End Sub 3. Save and run the project. 4. Click the form. This toggles full window dragging. 5. Move or resize the window to test the full window dragging state. RESULT: Full window dragging is toggled on and off with each click of the form. Steps to Create Sample 16-Bit Project ------------------------------------- Repeat steps 1-5 above but replace the code in step 2 with the following code: Option Explicit Private Declare Function SystemParametersInfo Lib "user" ( _ ByVal uAction As Integer, ByVal uParam As Integer, _ ByRef lpvParam As Any, ByVal fuWinIni As Integer) As Integer Private Const SPI_GETDRAGFULLWINDOWS = 38 Private Const SPI_SETDRAGFULLWINDOWS = 37 Private Const SPIF_SENDWININICHANGE = 2 Private Function IsFullWindowDragOn() As Boolean Dim result As Integer 'Call API and check for successful call. If SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, result, 0) _ <> 0 Then 'Feature supported now check value of result. If result = 0 Then IsFullWindowDragOn = False Else IsFullWindowDragOn = True End If 'Call failed, feature not supported. Else IsFullWindowDragOn = False End If End Function Private Sub Form_Click() Dim result As Integer 'Toggle the setting. If IsFullWindowDragOn Then 'Turn full window drag off. result = SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0, _ ByVal vbNullString, SPIF_SENDWININICHANGE) Else 'Turn full window drag on. result = SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1, _ ByVal vbNullString, SPIF_SENDWININICHANGE) End If End Sub Additional query words: kbSDKWin32 kbAPI ====================================================================== Version : WINDOWS:4.0,5.0 Platform : WINDOWS Issue type : kbhowto ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1998.