How to hide/show icons on desktop?
My old program works on Windows ME but now it won't do anything to hide/show icons on XP desktop anymore.
Please give me a hint or something that will help.
Thank you.
Hint: the 'desktop' is just another listview control - get its handle and tell it to do what you want :wink
hi dark
i post my algo + example!
regards rag dog
[attachment deleted by admin]
Ragdog,
The exe with that example doesn't work on my laptop ( WinXP Home sp2 .. )..
Just to let you know..
Cheers
hi EddIeB
this work correct on my maschin with winxp sp2
i search for the mistake
greetz ragdog
i have testet on 2 laptops 1.xpsp2 , 2xpsp2
this work correct!!
ragdog
Doesn't work at all here ;)
Doesn't hide a single icon.
hmmm! :red
i can´t help you!
by me works on 3 maschine! this works by a friends
your must posting to donkey he can definit help you
best regards
ragdog
Something strange,work on XP SP2 professionnal
ToutEnMasm
thx ToutEnMasm
sorry EddieB :wink
i have only tested on professional :wink
can anywhere test on home version if correct works??
ragdog
source code for GetDesktopListView is missing,not easy to search something
ToutEnMasm
ragdog,
It works on my machine. XP, Home Edition w/SP2.
Nice, but the source code is not complete?
Paul
hmm????
Sorry, I don't understand :'(
your mean this?
[attachment deleted by admin]
sorry,it's complete.I have made a mistake.
I search
ToutEnMasm
to ToutEnMasm
works on your maschien??
maybe this works
this should be enough to get desktop_listview handle:
GetDesktopListView proc
invoke FindWindow, offset szProgman, 0
test eax, eax
jz error
invoke FindWindowEx, eax, 0, 0, 0
error:
ret
GetDesktopListView endpt
[attachment deleted by admin]
this was just an example of my possibilitys :bg
ragdog
Hello,
I am working and found a first mistake in the WM_COMMAND
You must extract the words from wParam and lparam like that ,it's enough to have different results
in differents systems
ToutEnMasm
.elseif uMsg == WM_COMMAND
HIWORD wParam ;events of controls
mov edx,eax ;exemple :TCN_SELCHANGE
LOWORD wParam ;ID of commands eax
mov ebx,lParam ; handle of controles
;suite
.if eax == IDC_EXIT
call HideIcons
.elseif eax == 1002
call ShowIcons
.endif
HIWORD MACRO ParamFen
mov eax,ParamFen
shr eax,16
ENDM
LOWORD MACRO ParamFen
mov eax,ParamFen
and eax,0FFFFh
ENDM
:U
that is not to work between home and professinal?
or which you meant?
Try this one , he would have les random work
ToutEnMasm
Quote
; #########################################################################
.NOLIST
.586
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive
include macro.inc
include \masm32\include\windows.inc
LIB user32,kernel32,comdlg32,comctl32,shell32,advapi32,gdi32
DlgProc PROTO :HWND,:UINT,:WPARAM,:LPARAM
ShowIcons PROTO
GetDesktopListView PROTO
HideIcons PROTO
.const
IDD_DIALOG equ 1000
IDC_EXIT equ 1001
;#########################################################################
.data
szProgman db "Progman", 0
szSHELLDLL db "SHELLDLL_DefView", 0
szSysList db "SysListView32", 0
HidingState db 1
IconState db 1
hInstance dd 0
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG,NULL,addr DlgProc,NULL
invoke ExitProcess,0
DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg == WM_INITDIALOG
.elseif uMsg == WM_COMMAND
HIWORD wParam ;evenements des listbox ,combo sont ici
mov edx,eax ;exemple :TCN_SELCHANGE
LOWORD wParam ;IDentificateurs de commandes eax
mov ebx,lParam ; handle du controle
;suite
.if eax == IDC_EXIT
invoke HideIcons
.elseif eax == 1002
invoke ShowIcons
.endif
.elseif uMsg == WM_CLOSE
invoke EndDialog,hWnd,0
.endif
xor eax, eax
ret
DlgProc endp
;-------------------------------------------------------------------------
GetDesktopListView proc
invoke FindWindow, offset szProgman, NULL
.if eax != 0
invoke FindWindowEx, eax, NULL, offset szSHELLDLL, NULL
.if eax != 0
invoke FindWindowEx, eax, NULL, offset szSysList, NULL
.endif
.endif
ret
GetDesktopListView endp
;----------------------------------------------------------------------------------------------------
ShowIcons proc
Local Hwindow:DWORD
invoke GetDesktopListView
.if eax != 0
mov Hwindow,eax
invoke IsWindowVisible, Hwindow
.if eax == 0
invoke ShowWindow, Hwindow, SW_SHOW
.endif
mov IconState, 1
.endif
ret
ShowIcons endp
;-------------------------------------------------------------------------
HideIcons proc
Local Hwindow:DWORD
invoke GetDesktopListView
.if eax != 0
mov Hwindow,eax
invoke IsWindowVisible,Hwindow
.if eax == TRUE
invoke ShowWindow, Hwindow, SW_HIDE
.endif
mov IconState, 0
.endif
ret
HideIcons endp
end start
[attachment deleted by admin]
Ramaguru's code worked for me :)
how said that was a fast example!
also there I have it still ma tested with my sister their laptop xp home edition thats works
which you meant with ?
HIWORD wParam ;evenements des listbox ,combo sont ici
mov edx,eax ;exemple :TCN_SELCHANGE
LOWORD wParam ;IDentificateurs de commandes eax
mov ebx,lParam ; handle du controle
you can explain to me more exactly?
GetDesktopListView proc
invoke FindWindow, offset szProgman, 0
test eax, eax
jz error
invoke FindWindowEx, eax, 0, 0, 0
error:
ret
GetDesktopListView endp
and why functions only with EddieB?
ragdog
Hello,
A little explain
The wparam is defined as follow in winhelp
WM_COMMAND
wNotifyCode = HIWORD(wParam); // notification code
wID = LOWORD(wParam); // item, control, or accelerator identifier
hwndCtl = (HWND) lParam; // handle of control
EAx mus be divide in two words (it's a a double word = 4 bytes),each word have a differant information in it.
ToutEnMasm
there are differences with the wparam function there between home and pro?
.if wParam == IDC_EXIT
call HideIcons
.elseif wParam == 1002
call ShowIcons
.endif
There is no difference between the definition but values are differents and you can have random results if you compare a word with a dword.
First you must extract the word,make his size a dword filling it with 0 and then you can compare it with a dword.
ToutEnMasm
I understand nothing more :bg
mov edi ,wParam
.if edi == IDC_HIDE
call xxx
.elseif edi == IDC_SHOW
call xxx
.endif
this algo functioned to today on each pc with me and with befriend pc
sorry this algo
.if wParam == IDC_HIDE
call xxx
.elseif wParam == IDC_SHOW
call xxx
.endif
I repeat that there is two informations in wparam (coded in two words) and not only one coded in a DWORD.Wparam is a dword.
If the hight word has no information in it (0),your code can work,but if he has one your code fail.
ToutEnMasm
when u press a button u can expect only one notification code
BN_CLICKED equ 0
so zero'ing of wparam high-order word(0000XXXX) is waste of time and this
.if wParam == 1002
is enough, correct etc.
thus am I to use HIWORD and LOWORD macro in the future?
there then very many people must make wrong because I in such a way acquired themselves!!
thanks fo this great information :U
thank ramguru :bg
Quote from: ramguru on November 08, 2006, 09:03:45 PM
when u press a button u can expect only one notification code
BN_CLICKED equ 0
so zero'ing of wparam high-order word(0000XXXX) is waste of time and this
.if wParam == 1002
is enough, correct etc.
Ragmuru,
This code is actually incorrect because it CAN fail....If the notification code came from an accelerator, it WILL fail because the HIWORD has been set. :-)
You must check the LOWORD only.
Relvinian
In what i say , I just follow microsoft and winhelp.See some samples of microsoft coded in c++ and you will see that it is the only way to have a good code.
If you lost some µs,you win some hours to ask you why something don't work or work randomly.
ToutEnMasm
thus must be like that??
.elseif uMsg == WM_COMMAND
LOWORD wParam ;ID of commands eax
.if eax == IDC_HIDE
call HideIcons
.elseif eax == IDC_SHOW
call ShowIcons
.endif
correct??
it would be nice if you could poste a complete source, so i could have a look at for a better understanding
ragdog
Quote from: Relvinian on November 08, 2006, 09:13:43 PM
Quote from: ramguru on November 08, 2006, 09:03:45 PM
when u press a button u can expect only one notification code
BN_CLICKED equ 0
so zero'ing of wparam high-order word(0000XXXX) is waste of time and this
.if wParam == 1002
is enough, correct etc.
Ragmuru,
This code is actually incorrect because it CAN fail....If the notification code came from an accelerator, it WILL fail because the HIWORD has been set. :-)
You must check the LOWORD only.
Relvinian
Quote from: EddieB on November 08, 2006, 08:04:36 PM
Ramaguru's code worked for me :)
In one topic :) to make such a big mistake twice :)
There is no way...that suddenly you can get other than BN_CLICKED notification code in that small app, since it handles only messages that came from its instance...Checking if wParam==1002 in other than that app would be correct too unless 1002 is menuitem's or accel's ID
is this correct???
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
.IF eax == IDC_HIDE
.ELSEIF eax == IDC_SHOW
.ENDIF
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
and eax,0FFFFh ;needed and you have the low word
.IF eax == IDC_HIDE
.ELSEIF eax == IDC_SHOW
.ENDIF
I thank it understood!
I have a German example found with comments!
I thank you still times all me helped
here is the correct source
best greets
ragdog
[attachment deleted by admin]
You guys never learn ::)
.if wParam == 1001
is the only correct way to check if button with id 1001 was clicked, 'cause you are checking if notification code was BN_CLICKED (equ 0) & if the control had 1001 ID at the same time. Try to set BS_NOTIFY (to button) and app will behave "randomly" if you are clearing high-order word. ToutEnMasm it's you who make program give random results not me...
:red
which you mean correct ?
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
and eax,0FFFFh ;needed and you have the low word
.if eax == 1001
call HideIcons
.elseif eax == 1002
call ShowIcons
.endif
send me correctly example! please
rAGDOG
ragdog,
Thank you.
Paul
paul for wat??
QuoteWM_COMMAND
wNotifyCode = HIWORD(wParam); // notification code
wID = LOWORD(wParam); // item, control, or accelerator identifier
hwndCtl = (HWND) lParam; // handle of control
So,
.
.
.
.ELSEIF uMsg==WM_COMMAND
xor ecx, ecx
mov eax, wParam
mov cx, ax
shr eax, 16
;eax holds now the notification code
;ecx holds "item, control, or accelerator identifier"
.IF ecx==1001; first find out who is sending the notification
.IF eax==BN_CLICKED ;then find what it needs
call HideIcons
.ENDIF
.ELSEIF ecx==1002
.IF eax==BN_CLICKED
call ShowIcons
.ENDIF
.ENDIF
.ELSEIF uMsg==....
.
.
.
NOTE: The code above does not call DefWindowProc for unprocessed messages!!!
I would say this is the only safe way. First you find out the control that is sending the message, because same number in notification may mean different things for different controls, then you test the notification code, to see if it is the one you are interested in.
Of course that, in certain situations, you may remove some conditions, but, again, this is the safe widely way in my opinion.
Regards,
Nick
PS: Sorry for late reply to this topic.
Now how I should prove you that you're wasting code...
given: BN_CLICKED=0
wParam=000003E9h
IF ecx==1001
IF eax==BN_CLICKED
do_show()
ENDIF
ENDIF
can be replaced with
IF ecx==1001 && eax==BN_CLICKED
do_show()
ENDIF
in other words
IF ecx==1001 && eax==0
do_show()
ENDIF
in other words
IF (LOWORD)wParam==1001 && (HIWORD)wParam==0
do_show()
ENDIF
in other words
IF wParam==1001
do_show()
ENDIF
So you whole code can be replaced with
.ELSEIF uMsg==WM_COMMAND
.IF wParam==1001
call HideIcons
.ELSEIF wParam==1002
call ShowIcons
.ENDIF
; And only if you need to check accelerator's value you should shift & do that stuff etc...
.ELSEIF uMsg==...
thx fo the information :U
i make that so
.ELSEIF uMsg==WM_COMMAND
.IF wParam==1001
call HideIcons
.ELSEIF wParam==1002
call ShowIcons
.ENDIF
This is embarrassing...
You are absolutely right.
ID_Button1 EQU 1001
ID_Button1 EQU 1001
.
.
.
.ELSEIF uMsg==WM_COMMAND
.IF wParam==(BN_CLICKED SHL 16) or ID_Button1
call HideIcons
.ELSEIF wParam==(BN_CLICKED SHL 16) or ID_Button1
call ShowIcons
.ENDIF
=> general form
.ELSEIF uMsg==WM_COMMAND
.IF wParam==(AnyNotificationCode1 SHL 16) or ID_Any
call Something1
.ELSEIF wParam==(AnyNotificationCode2 SHL 16) or ID_Any
call Something2
.
.
.
.ENDIF
I will stand in a corner in my knees for 10 minutes for this one. :tdown :red
Nick