|
-
Feb 17th, 2006, 06:22 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED]Show Desktop
Hi guys
I want to show the dekstop by clicking a button.
So everything is minimized
Shell ("C:\blah\Show Desktop.scf") didn't work
Thanx
Last edited by Private_sub; Feb 17th, 2006 at 07:58 AM.
-
Feb 17th, 2006, 06:24 AM
#2
Re: Show Desktop
no idea, but just give try to send keys of start menu key + d, this will show the desktop.
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Feb 17th, 2006, 06:25 AM
#3
Thread Starter
Hyperactive Member
Re: Show Desktop
Good idea!
I'll post my result
-
Feb 17th, 2006, 07:05 AM
#4
Thread Starter
Hyperactive Member
-
Feb 17th, 2006, 07:18 AM
#5
Re: Show Desktop
Try this
VB Code:
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 VK_CONTROL = &H11
Private Const VK_ESCAPE = &H1B
Private Const KEYEVENTF_KEYUP = &H2
Private Sub Command1_Click()
keybd_event VK_CONTROL, 0, 0, 0 ' Press Control Key
keybd_event VK_ESCAPE, 0, 0, 0 ' Press Escape Key
keybd_event VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0 ' Release Escape Key
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 ' Release Control Key
End Sub
-
Feb 17th, 2006, 07:23 AM
#6
Thread Starter
Hyperactive Member
Re: Show Desktop
Hmm..
That's Control and Escape.
Do you also know something for the Windows key?
Thanx
-
Feb 17th, 2006, 07:26 AM
#7
Re: Show Desktop
you could enumerate all visible windows and minimize them with API
Enumerate: EnumWindows
Check if visible: IsWindowVisible
And then minimze: ShowWindow
Last edited by bushmobile; Feb 17th, 2006 at 07:32 AM.
-
Feb 17th, 2006, 07:38 AM
#8
Thread Starter
Hyperactive Member
-
Feb 17th, 2006, 07:48 AM
#9
Re: Show Desktop
Actually, it seems it's easier.
Check out this code by Robdog888
http://www.vbforums.com/showthread.php?t=360571
-
Feb 17th, 2006, 07:58 AM
#10
Thread Starter
Hyperactive Member
Re: Show Desktop
That rocks!
Much easier! Thank you jcis (and Robdog)
-
Feb 17th, 2006, 08:27 AM
#11
Re: Show Desktop
When you click the "Show Desktop" button, explorer actually runs the Shell32.IShellDispatch4.ToggleDesktop() method.
See the proper way to Programmatically Showing the Desktop (ToggleDesktop) and the VB.NET way.
But it is not working in VB6.
Add a reference to Microsoft Shell Control & Automation and in object browser it will showup. (check 'show hidden members'). But I'm unable to create an instance of IShellDispatch4 interface in VB6. 
Apart from the keybd_event method, you can try these,
Idea 1 - Non-API
VB Code:
Option Explicit
' Add a reference to Microsoft Shell Control & Automation
Dim MyShell As New Shell32.shell
Private Sub Command1_Click()
MyShell.MinimizeAll
End Sub
Private Sub Command2_Click()
MyShell.UndoMinimizeALL
End Sub
or better,
Create a new .scf file (or use the default one) and use shell execute to call it.
Idea 2 - ShellExecute API (better)
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, _
App.Path & "\aaa.scf", _
vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Last edited by iPrank; Feb 17th, 2006 at 08:32 AM.
-
Feb 17th, 2006, 01:18 PM
#12
Thread Starter
Hyperactive Member
Re: [RESOLVED]Show Desktop
That's even better 
Maybe you can add it to the Codebank?
-
Apr 18th, 2007, 08:54 AM
#13
Re: [RESOLVED]Show Desktop
Just an update.
This works in VB6/VBScript:
vb Code:
Private Sub Command1_Click()
Dim objShell
Set objShell = CreateObject("Shell.Application")
objShell.ToggleDesktop
Set objShell = Nothing
End Sub
http://msdn2.microsoft.com/en-us/library/ms630442.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|