Results 1 to 3 of 3

Thread: Hiding all windows on a desktop using window handles!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    9

    Exclamation

    I came across this problem in a recent project I was working on....Does anyone know how to do it?
    blah

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    There should be good samples on my homepage, i'm not sure i put up that one with hiding and showing, but you put this in the same module
    Code:
    Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    
    Property Get Windowvisible(hwnd&) As Boolean
        clockvisible = IsWindowVisible(hwnd)
    End Property
    Property Let Windowvisible(hwnd&,newvalue As Boolean)
        ShowWindow hwnd, newvalue * -5
    End Property
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest
    Here's a good code I used for my program:

    Code:
    Declare Function findwindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Declare Function showWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Public Const SW_HIDE = 0
    Public Const SW_SHOW = 5
    Private Const WM_COMMAND As Long = &H111
    Private Const MIN_ALL As Long = 419
    Private Const MIN_ALL_UNDO As Long = 416
    'Hide
    
    Dim progman&
    Dim shelldlldefview&
    Dim syslistview&
    progman& = FindWindow("progman", vbNullString)
    shelldlldefview& = FindWindowEx(progman&, 0&, "shelldll_defview", vbNullString)
    syslistview& = FindWindowEx(shelldlldefview&, 0&, "syslistview32", vbNullString)
    tray& = findwindow("Shell_TrayWnd")
    X = showWindow(syslistview&, SW_HIDE)
    Y = showWindow(tray&, SW_HIDE)
    
    -----
    
    'Show
    
    
    Dim progman&
    Dim shelldlldefview&
    Dim syslistview&
    progman& = FindWindow("progman", vbNullString)
    shelldlldefview& = FindWindowEx(progman&, 0&, "shelldll_defview", vbNullString)
    syslistview& = FindWindowEx(shelldlldefview&, 0&, "syslistview32", vbNullString)
    tray& = findwindow("Shell_TrayWnd")
    Y = showWindow(syslistview&, SW_SHOW)
    X = showWindow(tray&, SW_SHOW)
    
    'To minimize any window that remains..:
    
    Public Sub MinimizeAll()
    On Error Resume Next
        Dim lngHwnd As Long
           lngHwnd = findwindow("Shell_TrayWnd", vbNullString)
        Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL, 0&)
      
    End Sub
      
    'Restore all windows:
    
    Public Sub RestoreAll()
      
        Dim lngHwnd As Long
       
        lngHwnd = findwindow("Shell_TrayWnd", vbNullString)
        Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL_UNDO, 0&)
      
    End Sub
    
    'Restore your program only:
    
    Public Sub RestoreMe()
      Dim i
      Dim lngHwnd As Long
      i = hWnd 'form's hWnd
      lngHwnd = findwindow(i, vbNullString)
      Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL_UNDO, 0&)
      
    End Sub
    Hope that helps.



    [Edited by Matthew Gates on 06-11-2000 at 10:42 PM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width