Microsoft KB Archive/185637

= How To Use APIs to Check, Enable, or Disable Full Window Drag =

Article ID: 185637

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Control Creation Edition
 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q185637



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 2000, Windows NT 4.0, and Windows 95 (with the Microsoft Plus! add-in), Windows 98, and Windows Me 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.



Steps to Create Sample 32-Bit Project
 Create a new Visual Basic project. Form1 is created by default.  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

 Save and run the project. Click the form. This toggles full window dragging. 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

Keywords: kbhowto kbapi KB185637

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.