SetWindowPos can also hide/show a control:
Code:Private Const SWP_NOSIZE As Long = &H1 'Retains the current size (ignores the cx and cy parameters) Private Const SWP_NOMOVE As Long = &H2 'Retains the current position (ignores X and Y parameters) Private Const SWP_NOZORDER As Long = &H4 'Retains the current Z order (ignores the hWndInsertAfter parameter) Private Const SWP_SHOWWINDOW As Long = &H40 'Displays the window Private Const SWP_HIDEWINDOW As Long = &H80 'Hides the window Private Declare Function SetWindowPos Lib "user32.dll" ( _ ByVal hWnd As Long, _ Optional ByVal hWndInsertAfter As Long, _ Optional ByVal X As Long, Optional ByVal Y As Long, _ Optional ByVal cx As Long, Optional ByVal cy As Long, _ Optional ByVal uFlags As Long _ ) As Long Public Sub HideOrShowControl(ByRef Ctrl As Control, Optional ByVal Show As Boolean) Const SWP_FLAGS = SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER On Error Resume Next If Show Then SetWindowPos Ctrl.hWnd, uFlags:=SWP_FLAGS Or SWP_SHOWWINDOW Else SetWindowPos Ctrl.hWnd, uFlags:=SWP_FLAGS Or SWP_HIDEWINDOW End If End Sub




Reply With Quote