Updated : Hide / Show Desktop Icons Programmatic (Windows)

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Updated : Hide / Show Desktop Icons Programmatic (Windows)

Post by RASHAD »

It is very small tip but it can be useful for somebody

Code: Select all

  hwnd = OpenWindow(0, 0, 0, 300, 300, "Hide \ Show Desktop Icons", #PB_Window_Invisible)
  ShowWindow_(GetWindow_(hwnd,#GW_HWNDLAST), #SW_HIDE)           ;Hide Desktop Icons
  ;ShowWindow_(GetWindow_(hwnd,#GW_HWNDLAST), #SW_SHOW)        ;Show Desktop Icons
  Repeat
  Delay(10)
  Q = 1
  Until Q = 1
Have fun
Last edited by RASHAD on Fri Nov 05, 2010 5:41 am, edited 2 times in total.
Egypt my love
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: Hide / Show Desktop Icons Programatic (Windows)

Post by yrreti »

Thanks RASHAD
Your small example is big in usefulness. My desktop is cluttered with
icons that I often use, but sometimes it's nice to make them disappear.
Your code works perfectly.
Thanks much.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Hide / Show Desktop Icons Programatic (Windows)

Post by Kwai chang caine »

Thanks RASHAD 8)

It can be usefull.... and also funny for make a joke, at my colleague of job for exampler :wink:
Kcc always ready to laugh :lol:
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Hide / Show Desktop Icons Programatic (Windows)

Post by RASHAD »

@yrreti
@KCC

You are welcome.
Egypt my love
Morty
User
User
Posts: 35
Joined: Mon Mar 19, 2007 8:30 am
Location: Germany
Contact:

Re: Hide / Show Desktop Icons Programatic (Windows)

Post by Morty »

Interesting code ... thanx.

But on my system i get a "little" bug.
If I press [window-key]+[d] (which I always do to get my desktop) the icons still are visible.
If i minimize all windows ... all works fine :)

Is there a way to prevent this behavior?

My system: Win 7 Professional (32 bit)

Morty
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Hide / Show Desktop Icons Programatic (Windows)

Post by RASHAD »

@Morty Hi and thank you
Sorry the only way I know To disable Windows Start+X shortcuts is by modifing the registry
then logoff / logon To refresh the registry (specially For windows 7)
The old method by end the explorer task and start new one is not working any more
I prefer the first by using scancode Map
To enable the shortcut again delete the key from the registry And refresh it again
But I will keep digging may be there is some other way to do it

1)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,00,00,5B,E0,00,00,5C,E0,00,00,00,00


2)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoWinKeys"=dword:00000001‏
Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Hide / Show Desktop Icons Programatic (Windows)

Post by RASHAD »

@Morty Hi again
Next is the same code with disabling the Windows Start Key Programmatic
It is as you requested
If you ask me and do not like it
But it is up to you
Tested with windows 7 only

Code: Select all


  hwnd = OpenWindow(0, 0, 0, 300, 300, "Hide \ Show Desktop Icons", #PB_Window_Invisible)
  ShowWindow_(GetWindow_(hwnd,#GW_HWNDLAST), #SW_HIDE)           ;Hide Desktop Icons
  ;ShowWindow_(GetWindow_(hwnd,#GW_HWNDLAST), #SW_SHOW)        ;Show Desktop Icons
  Repeat
  Delay(10)
  Q = 1
  Until Q = 1

Structure KBDLLHOOKSTRUCT
  vkCode.i
  scanCode.i
EndStructure

Global Hook.i, Dim Key.s(256)

Procedure KeyboardHook(nCode, wParam,*k.KBDLLHOOKSTRUCT)
  If nCode < 0 
    ProcedureReturn CallNextHookEx_(hook, nCode, wParam,*k.KBDLLHOOKSTRUCT)
  EndIf
  If (wParam=#WM_KEYDOWN And EventwParam() = 91) Or (wParam=#WM_KEYUP And EventwParam() = 91)
 
      ProcedureReturn 1
    EndIf
  ProcedureReturn CallNextHookEx_(hook, nCode, wParam,*k.KBDLLHOOKSTRUCT)
EndProcedure

OpenWindow(0, -200, 0, 0, 0, "", #PB_Window_SystemMenu)
hook=SetWindowsHookEx_(#WH_KEYBOARD_LL, @KeyboardHook(), GetModuleHandle_(0), 0)

Repeat
      event = WaitWindowEvent()
    
      Select event
      
        Case #PB_Event_CloseWindow: Break
            
      EndSelect
      
ForEver 
UnhookWindowsHookEx_(hook)
End
Egypt my love
Morty
User
User
Posts: 35
Joined: Mon Mar 19, 2007 8:30 am
Location: Germany
Contact:

Re: Updated : Hide / Show Desktop Icons Programatic (Windows

Post by Morty »

@RASHAD: Hi :D

Thanks for your help, but a keyboard hook is not what I'm searched for.
I don't know if I exlpained it wrong or if I misunderstood your answer :?:

The question is: Is there a way to hide the desktop icons in an other way, so that i can use [window-key]+[d] to switch to the desktop ?

Greatz, Morty
User avatar
ar-s
Enthusiast
Enthusiast
Posts: 344
Joined: Sat Oct 06, 2007 11:20 pm
Location: France

Re: Updated : Hide / Show Desktop Icons Programatic (Windows

Post by ar-s »

Thanks for this usefull code !
~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4

Code: Select all

r3p347 : 7ry : un71l d0n3 = 1
User avatar
Alireza
Enthusiast
Enthusiast
Posts: 143
Joined: Sat Aug 16, 2008 2:02 pm
Location: Iran

Re: Updated : Hide / Show Desktop Icons Programmatic (Window

Post by Alireza »

WOOW :D :D :D
thanks man , cooooooooooooooooooooooooooooooooooool :)
PB v 5.6 :D
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Updated : Hide / Show Desktop Icons Programmatic (Windows)

Post by IdeasVacuum »

RASHAD wrote: Tue Jun 08, 2010 7:22 am It is very small tip but it can be useful for somebody
Hi Rashad - it works well, but if I run the code via a button on my program, the program window is also hidden........

Your other code works perfect:

Code: Select all

#ToggleDesktopico = $7402
hWnd = GetWindow_(FindWindow_("Progman", "Program Manager"), #GW_CHILD)
SendMessage_(hWnd, #WM_COMMAND, #ToggleDesktopico, 0)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply