|
|
|
The Desktop is a window like any other window in the system, so you can hide/show and enable/disable it. The only details you need to know is how to retrieve the handle to the Desktop window. It turns out that this window is the first child window of the "Program Manager" window, so all you need is a couple of API functions: |
Click here to copy the following block | Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _ lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _ ByVal wCmd As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, _ ByVal fEnable As Long) As Long
Private Const GW_CHILD = 5 Private Const SW_HIDE = 0 Private Const SW_SHOW = 5
Sub ShowDesktopIcons(ByVal bVisible As Boolean) Dim hWnd_DesktopIcons As Long hWnd_DesktopIcons = GetWindow( FindWindow("Progman", "Program Manager"), _ GW_CHILD) If bVisible Then ShowWindow hWnd_DesktopIcons, SW_SHOW Else ShowWindow hWnd_DesktopIcons, SW_HIDE End If End Sub
Sub EnableDesktop(ByVal bEnable As Boolean) Dim hWnd_Desktop As Long hWnd_Desktop = GetWindow( FindWindow("Progman", "Program Manager"), _ GW_CHILD) If bEnable Then EnableWindow hWnd_Desktop, True Else EnableWindow hWnd_Desktop, False End If End Sub |
You can make the above code more concise in this way: |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|