Quote:
> Is there a way to freeze the screen display so the user never sees the
> dialogs opening and closing and is only presented with the end result?
The following may help you out. Call HideDesktop to freeze the
current display, and UnhideDesktop to restore the display. This
should work assuming none of the windows that get created are OnTop
windows.
'-----------------------------------------------
' Make the following part of a standard module
Public Const HWND_DESKTOP = 0
Public Const HWND_TOPMOST = -1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
Public Const SRCCOPY = &HCC0020
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc _
As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As _
Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
ByVal hObject As Long) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal _
hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Sub HideDesktop()
Load frmHideDesktop
Dim RemoteDC As Long
Dim RemoteBitmap As Long
Dim DeskDC As Long
DeskDC = GetDC(HWND_DESKTOP)
RemoteDC = CreateCompatibleDC(DeskDC)
RemoteBitmap = CreateCompatibleBitmap(DeskDC, _
Screen.Width / Screen.TwipsPerPixelX, _
Screen.Height / Screen.TwipsPerPixelY)
SelectObject RemoteDC, RemoteBitmap
BitBlt RemoteDC, 0, 0, Screen.Width / Screen.TwipsPerPixelX, _
Screen.Height / Screen.TwipsPerPixelY, _
DeskDC, 0, 0, SRCCOPY
ReleaseDC HWND_DESKTOP, DeskDC
frmHideDesktop.RemoteDC = RemoteDC
frmHideDesktop.RemoteBitmap = RemoteBitmap
frmHideDesktop.RemoteDCInit = True
SetWindowPos frmHideDesktop.hwnd, HWND_TOPMOST, 0, 0, _
Screen.Width / Screen.TwipsPerPixelX, _
Screen.Height / Screen.TwipsPerPixelY, _
SWP_NOACTIVATE
BitBlt frmHideDesktop.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, _
Screen.Height / Screen.TwipsPerPixelY, RemoteDC, 0, 0, SRCCOPY
SetWindowPos frmHideDesktop.hwnd, HWND_TOPMOST, 0, 0, _
Screen.Width / Screen.TwipsPerPixelX, _
Screen.Height / Screen.TwipsPerPixelY, _
SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub
Public Sub UnhideDesktop()
Unload frmHideDesktop
End Sub
'-----------------------------------------------
'-----------------------------------------------
' Make the following part of a form, named frmHideDesktop, with the
' following properties:
'
' Appearance: Flat
' AutoRedraw: True
' Border Style: None
' Caption: "" (blank)
' Control box: False
Public RemoteDC As Long
Public RemoteDCInit As Boolean
Public RemoteBitmap As Long
Private Sub Form_DblClick()
Unload Me
End Sub
Private Sub Form_Initialize()
RemoteDCInit = False
End Sub
Private Sub Form_Paint()
If RemoteDCInit Then
BitBlt Me.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, _
Screen.Height / Screen.TwipsPerPixelY, RemoteDC, 0, 0, SRCCOPY
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If RemoteDCInit Then
DeleteObject RemoteBitmap
DeleteDC RemoteDC
RemoteDCInit = False
End If
End Sub
'-----------------------------------------------
--
-- Scott Seligman will hack perl for knowledge