|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Minimize all windowsThis 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?? "blaine67" <blain***@discussions.microsoft.com> wrote in message Hmmm, good question. Here's my thoughts: since this feature has been 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?? 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. 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?? "blaine67" <blain***@discussions.microsoft.com> wrote in message This works "almost" like the ShowDesktop button....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?? 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.. "Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message Whatever happened to old Joe?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 "Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message Well? <g> Here's his site. Looks like he's moved on to "greener pastures" news:O44ycVv5FHA.2956@TK2MSFTNGP12.phx.gbl... > > > Whatever happened to old Joe? <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.. "blaine67" <blain***@discussions.microsoft.com> wrote in message Not sure if this is a good way to do it but it works on XP.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?? Private Sub ToggleDesktop() Dim oShell As Object Set oShell = CreateObject("Shell.Application") Call oShell.ToggleDesktop Set oShell = Nothing End Sub Jim Edgar
Show quote
Hide quote
"Jim Edgar @cox.net>" <djedgar<removethis> wrote in message Given the recent trend for voting, this one get's mine. I believe that it 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 > 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
Show quote
Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message This works :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 > Dim oShell As Object Set oShell = CreateObject("Shell.Application") oShell.MinimizeAll Dmitriy
Show quote
Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message I think that MinimizeAll does just that where ToggleDesktop will eithernews: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 > > > 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 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??
Grouping Lines of Code
Converting string to hexa value.... Looking for a VB.NET book geared towards Console applications. list files from folder in hard disk dynamically create the DLL VB and AutoCad System boot date ? DCOM settings programmatically? Creating combo box showing drives+desktop+mycomputer datagrid checkbox why? |
|||||||||||||||||||||||