Click to See Complete Forum and Search --> : Hiding desktop icons


jmh547
December 16th, 2006, 08:47 PM
I am trying to write a small program that will hide the desktop icons. I tried the reg edit thing but you have to restart explorer when you hide/show them. I also tried this. x=0 will show the desktop x!=0 will hide it.

HWND hw;
hw = FindWindowEx(0,0,"Progman", NULL);
ShowWindow(hw, x);

However this completely disables the desktop (no right click) and i have some trouble with explorer crashing every now and then when i use it. Does anyone know what command is called when you right click on the desktop "Arrange Icons by" --> "Show Desktop Icons"

Ideally this is the command that i would like to use if it is accessible

PeejAvery
December 17th, 2006, 05:51 PM
Are you attemping to do this in Visual Basic? It looks that way. If so, is it 6 or .Net?

RobDog888
December 23rd, 2006, 04:15 AM
It might be best if you use Group Policies to hide desktop icons, drives, or control panel appletts.

HanneSThEGreaT
December 23rd, 2006, 04:51 AM
Are you attemping to do this in Visual Basic? It looks that way. If so, is it 6 or .Net?
I'd say it's more Visual C++, because of the ; behind the statements :)

All may be well when you eventually hide and show the icons, but isn't it better to allow the user to be able to do this. All system settings IMHO, must be up to the user to decide whether he / she wants to change it.
Why do you need such a program that does this ¿
I never could understand why programmers must do this.
I'm not being funny or anything, but, it's just my opinion.

Remember also that not every use is an advanced user. Some beginner users might not have a clue of what's going on and why, and of course how to fix it!
Some users may want their icons to be always displayed, some may not, but it should ultimately be up to the user to decide.

Just my 2 cents, don't shoot me it's Christmas! :D :)

RobDog888
December 23rd, 2006, 01:27 PM
Could be like I have seen, the client desires a controlled environment (desktop) in a business network. This is where using GPOs is more beneficial then writting any code.

Ps, looks like C# possibly. :D

Marc G
December 27th, 2006, 03:57 PM
You have to find Progman, then the desktop window and then the listview containing the actual icons. Something like the following in C++:
HWND GetDesktopListViewHWND()
{
HWND hDesktopListView = NULL;
HWND hProgman = FindWindow(_T("Progman"), 0);
if (hProgman)
{
HWND hDesktop = FindWindowEx(hProgman, 0, _T("SHELLDLL_DefView"), 0);
if (hDesktop)
{
hDesktopListView = FindWindowEx(hDesktop, 0, _T("SysListView32"), 0);
}
}

return hDesktopListView;
}

void ShowDesktopIcons(BOOL bShow)
{
HWND hWndDesktopListView = GetDesktopListViewHWND();
ShowWindow(hWndDesktopListView, (bShow?SW_SHOW:SW_HIDE));
}

HanneSThEGreaT
December 28th, 2006, 01:45 AM
You have to find Progman, then the desktop window and then the listview containing the actual icons. Something like the following in C++:
HWND GetDesktopListViewHWND()
{
HWND hDesktopListView = NULL;
HWND hProgman = FindWindow(_T("Progman"), 0);
if (hProgman)
{
HWND hDesktop = FindWindowEx(hProgman, 0, _T("SHELLDLL_DefView"), 0);
if (hDesktop)
{
hDesktopListView = FindWindowEx(hDesktop, 0, _T("SysListView32"), 0);
}
}

return hDesktopListView;
}

void ShowDesktopIcons(BOOL bShow)
{
HWND hWndDesktopListView = GetDesktopListViewHWND(&hWndDesktopListView, NULL, NULL);
ShowWindow(hWndDesktopListView, (bShow?SW_SHOW:SW_HIDE));
}

Oh Yes, now I remember....
The other day, I answered this (http://codeguru.earthweb.com/forum/showthread.php?t=403677) thread, and when I saw SHELLDLL_DefView and SysListView32 in your post, I remembered it. You are right you have to get the Program, then SHELLDLL_DefView, and then you have access to the icons.

I also found this on CodeProject :
http://www.codeproject.com/tips/TransIcon.asp?df=100&forumid=26235&exp=0&fr=26

Why am I so forgetful! :mad: :rolleyes: :D