Home All Groups Group Topic Archive Search About
Author
11 Nov 2005 5:36 PM
blaine67
This has been probably asked before, but, since I can't find anything
relevant in a search, Is there a way in VB code to minimize all windows to
show the desk top??

Author
11 Nov 2005 6:08 PM
Jeff Johnson [MVP: VB]
"blaine67" <blain***@discussions.microsoft.com> wrote in message
news:EEF88587-4837-4BF8-BE42-E7227BFCA04A@microsoft.com...

> This has been probably asked before, but, since I can't find anything
> relevant in a search, Is there a way in VB code to minimize all windows to
> show the desk top??

Hmmm, good question. Here's my thoughts: since this feature has been
available since Windows 95, I wonder if maybe there's an API function in,
say, Shell32.dll that you can call to make this happen. Might be worth a
look.
Author
11 Nov 2005 6:21 PM
Matt Williamson
Blaine-

You can use Findwindow to get the handle to shell_traywnd and then send it a
message with sendmessage/postmessage using WM_COMMAND as the wMsg and 419 as
the wParam.

HTH

Matt

Show quoteHide quote
"blaine67" <blain***@discussions.microsoft.com> wrote in message
news:EEF88587-4837-4BF8-BE42-E7227BFCA04A@microsoft.com...
> This has been probably asked before, but, since I can't find anything
> relevant in a search, Is there a way in VB code to minimize all windows to
> show the desk top??
Author
11 Nov 2005 6:29 PM
Ken Halter
"blaine67" <blain***@discussions.microsoft.com> wrote in message
news:EEF88587-4837-4BF8-BE42-E7227BFCA04A@microsoft.com...
> This has been probably asked before, but, since I can't find anything
> relevant in a search, Is there a way in VB code to minimize all windows to
> show the desk top??

This works "almost" like the ShowDesktop button....

How To Minimize All Windows From Visual Basic
http://support.microsoft.com/kb/q194914/


Cleaned up slightly.....
'========
Option Explicit

Private Declare Sub keybd_event Lib "user32" ( _
   ByVal bVk As Byte, _
   ByVal bScan As Byte, _
   ByVal dwFlags As Long, _
   ByVal dwExtraInfo As Long)

Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_LWIN = &H5B

Private Sub Command1_Click()
   Call ShowDesktop
End Sub

Private Sub ShowDesktop()
   Call keybd_event(VK_LWIN, 0, 0, 0)
   Call keybd_event(vbKeyM, 0, 0, 0)
   Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub
'========

I didn't try this one but it's probably better....

!Show Desktop via API!
http://groups.google.com.my/group/microsoft.public.vb.winapi/browse_frm/thread/25dfe3d6584c4980



--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..
Author
11 Nov 2005 7:23 PM
Jeff Johnson [MVP: VB]
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:uIXhn3u5FHA.1000@tk2msftngp13.phx.gbl...

> I didn't try this one but it's probably better....
>
> !Show Desktop via API!
> http://groups.google.com.my/group/microsoft.public.vb.winapi/browse_frm/thread/25dfe3d6584c4980

Whatever happened to old Joe?
Author
11 Nov 2005 8:22 PM
Ken Halter
"Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message
news:O44ycVv5FHA.2956@TK2MSFTNGP12.phx.gbl...
>
>
> Whatever happened to old Joe?

Well? <g> Here's his site. Looks like he's moved on to "greener pastures"
<g>

LeVasseur_Net  Welcome to LeVasseur_Net
http://www.levasseur.net/page1.aspx

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..
Author
11 Nov 2005 8:00 PM
Jim Edgar
"blaine67" <blain***@discussions.microsoft.com> wrote in message
news:EEF88587-4837-4BF8-BE42-E7227BFCA04A@microsoft.com...
> This has been probably asked before, but, since I can't find anything
> relevant in a search, Is there a way in VB code to minimize all windows to
> show the desk top??

Not sure if this is a good way to do it but it works on XP.

Private Sub ToggleDesktop()
    Dim oShell As Object
    Set oShell = CreateObject("Shell.Application")
    Call oShell.ToggleDesktop
    Set oShell = Nothing
End Sub

Jim Edgar
Author
11 Nov 2005 10:46 PM
MikeD
Show quote Hide quote
"Jim Edgar @cox.net>" <djedgar<removethis> wrote in message
news:%23V3heqv5FHA.444@TK2MSFTNGP11.phx.gbl...
>
> "blaine67" <blain***@discussions.microsoft.com> wrote in message
> news:EEF88587-4837-4BF8-BE42-E7227BFCA04A@microsoft.com...
>> This has been probably asked before, but, since I can't find anything
>> relevant in a search, Is there a way in VB code to minimize all windows
>> to
>> show the desk top??
>
> Not sure if this is a good way to do it but it works on XP.
>
> Private Sub ToggleDesktop()
>    Dim oShell As Object
>    Set oShell = CreateObject("Shell.Application")
>    Call oShell.ToggleDesktop
>    Set oShell = Nothing
> End Sub
>


Given the recent trend for voting, this one get's mine. I believe that it
should work under Win2000 and Windows 2003, and probably even Win98/ME.

Although, in looking through MSDN Library, I see there's a MinimizeAll
method of the Shell object. The docs state "Minimizes all of the windows on
the desktop. This method has the same effect as right-clicking on the
taskbar and selecting Minimize All Windows."  There's also an
UndoMinimizeALL method.  Out of curiosity, I tried this, having set a
reference to "Microsoft Shell Controls And Automation".  (Do a Browse from
the References dialog and select "shell32.dll" if this is not listed.)

    Dim oShell As Shell32.Shell
    Set oShell = New Shell
    oShell.MinimizeAll

This worked fine.  So then I tried late-binding as such:

    Dim oShell As Object
    Set oShell = CreateObject("Shell32.Shell")
    oShell.MinimizeAll

This bombed with the infamous error number 429 "ActiveX component can't
create object" on the CreateObject line. It's Friday and I've had a long
day.  But, I can't see what I did wrong with the late-binding code. Probably
something stupid that I just am not seeing.

--
Mike
Microsoft MVP Visual Basic
Author
11 Nov 2005 11:07 PM
Dmitriy Antonov
Show quote Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:ueh5JHx5FHA.3760@TK2MSFTNGP14.phx.gbl...
>
> "Jim Edgar @cox.net>" <djedgar<removethis> wrote in message
> news:%23V3heqv5FHA.444@TK2MSFTNGP11.phx.gbl...
>>
>> "blaine67" <blain***@discussions.microsoft.com> wrote in message
>> news:EEF88587-4837-4BF8-BE42-E7227BFCA04A@microsoft.com...
>>> This has been probably asked before, but, since I can't find anything
>>> relevant in a search, Is there a way in VB code to minimize all windows
>>> to
>>> show the desk top??
>>
>> Not sure if this is a good way to do it but it works on XP.
>>
>> Private Sub ToggleDesktop()
>>    Dim oShell As Object
>>    Set oShell = CreateObject("Shell.Application")
>>    Call oShell.ToggleDesktop
>>    Set oShell = Nothing
>> End Sub
>>
>
>
> Given the recent trend for voting, this one get's mine. I believe that it
> should work under Win2000 and Windows 2003, and probably even Win98/ME.
>
> Although, in looking through MSDN Library, I see there's a MinimizeAll
> method of the Shell object. The docs state "Minimizes all of the windows
> on the desktop. This method has the same effect as right-clicking on the
> taskbar and selecting Minimize All Windows."  There's also an
> UndoMinimizeALL method.  Out of curiosity, I tried this, having set a
> reference to "Microsoft Shell Controls And Automation".  (Do a Browse from
> the References dialog and select "shell32.dll" if this is not listed.)
>
>    Dim oShell As Shell32.Shell
>    Set oShell = New Shell
>    oShell.MinimizeAll
>
> This worked fine.  So then I tried late-binding as such:
>
>    Dim oShell As Object
>    Set oShell = CreateObject("Shell32.Shell")
>    oShell.MinimizeAll
>
> This bombed with the infamous error number 429 "ActiveX component can't
> create object" on the CreateObject line. It's Friday and I've had a long
> day.  But, I can't see what I did wrong with the late-binding code.
> Probably something stupid that I just am not seeing.
>
> --
> Mike
> Microsoft MVP Visual Basic
>

This works :

Dim oShell As Object
Set oShell = CreateObject("Shell.Application")
oShell.MinimizeAll

Dmitriy
Author
12 Nov 2005 3:12 AM
Jim Edgar
Show quote Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:ueh5JHx5FHA.3760@TK2MSFTNGP14.phx.gbl...
>
> "Jim Edgar @cox.net>" <djedgar<removethis> wrote in message
> news:%23V3heqv5FHA.444@TK2MSFTNGP11.phx.gbl...
> >
> > "blaine67" <blain***@discussions.microsoft.com> wrote in message
> > news:EEF88587-4837-4BF8-BE42-E7227BFCA04A@microsoft.com...
> >> This has been probably asked before, but, since I can't find anything
> >> relevant in a search, Is there a way in VB code to minimize all windows
> >> to
> >> show the desk top??
> >
> > Not sure if this is a good way to do it but it works on XP.
> >
> > Private Sub ToggleDesktop()
> >    Dim oShell As Object
> >    Set oShell = CreateObject("Shell.Application")
> >    Call oShell.ToggleDesktop
> >    Set oShell = Nothing
> > End Sub
> >
>
>
> Given the recent trend for voting, this one get's mine. I believe that it
> should work under Win2000 and Windows 2003, and probably even Win98/ME.
>
> Although, in looking through MSDN Library, I see there's a MinimizeAll
> method of the Shell object. The docs state "Minimizes all of the windows
on
> the desktop. This method has the same effect as right-clicking on the
> taskbar and selecting Minimize All Windows."  There's also an
> UndoMinimizeALL method.  Out of curiosity, I tried this, having set a
> reference to "Microsoft Shell Controls And Automation".  (Do a Browse from
> the References dialog and select "shell32.dll" if this is not listed.)
>
>     Dim oShell As Shell32.Shell
>     Set oShell = New Shell
>     oShell.MinimizeAll
>
> This worked fine.  So then I tried late-binding as such:
>
>     Dim oShell As Object
>     Set oShell = CreateObject("Shell32.Shell")
>     oShell.MinimizeAll
>
> This bombed with the infamous error number 429 "ActiveX component can't
> create object" on the CreateObject line. It's Friday and I've had a long
> day.  But, I can't see what I did wrong with the late-binding code.
Probably
> something stupid that I just am not seeing.
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
>

I think that MinimizeAll does just that where ToggleDesktop will either
minimize or restore the windows depending on when it's called.  Run my code
with a timer set at about 3 seconds and be prepared for some fun.

Jim Edgar
Author
12 Nov 2005 9:42 AM
Ben Amada
Yet another way to minimize all windows:

http://vbnet.mvps.org/code/screen/keybd_event.htm

Ben
Author
15 Nov 2005 3:26 PM
blaine67
Thanks all for your post.  All of the information was helpful.  I really
appreciate it.....

Show quoteHide quote
"blaine67" wrote:

> This has been probably asked before, but, since I can't find anything
> relevant in a search, Is there a way in VB code to minimize all windows to
> show the desk top??