The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Dark Schneider on November 08, 2006, 08:36:31 AM

Title: Icons on desktop....
Post by: Dark Schneider on November 08, 2006, 08:36:31 AM
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.
Title: Re: Icons on desktop....
Post by: Tedd on November 08, 2006, 02:43:08 PM
Hint: the 'desktop' is just another listview control - get its handle and tell it to do what you want :wink
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 04:25:01 PM
hi dark

i post my algo + example!

regards rag dog

[attachment deleted by admin]
Title: Re: Icons on desktop....
Post by: EddieB on November 08, 2006, 04:35:43 PM
Ragdog,

The exe with that example doesn't work on my laptop ( WinXP Home sp2 .. )..

Just to let you know..

Cheers
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 05:13:20 PM
hi EddIeB

this work correct on my maschin with winxp sp2

i search for the mistake

greetz ragdog
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 05:24:26 PM
i have testet on 2 laptops 1.xpsp2 , 2xpsp2

this work correct!!

ragdog
Title: Re: Icons on desktop....
Post by: EddieB on November 08, 2006, 05:49:17 PM
Doesn't work at all here ;)

Doesn't hide a single icon.
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 06:00:29 PM
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
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 06:16:32 PM

Something strange,work on XP SP2 professionnal
                             ToutEnMasm
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 06:21:42 PM
thx ToutEnMasm

sorry EddieB  :wink

i have only tested on professional :wink

can anywhere test on home version if correct works??

ragdog

Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 06:25:29 PM

source code for GetDesktopListView is missing,not easy to search something
                           ToutEnMasm
Title: Re: Icons on desktop....
Post by: PBrennick on November 08, 2006, 06:27:34 PM
ragdog,
It works on my machine. XP, Home Edition w/SP2.

Nice, but the source code is not complete?
Paul
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 06:29:09 PM
hmm????

Sorry, I don't understand :'(
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 06:35:12 PM
your mean this?

[attachment deleted by admin]
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 06:39:50 PM

sorry,it's complete.I have made a mistake.
           I search
               ToutEnMasm
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 06:42:48 PM
to ToutEnMasm

works on your maschien??
Title: Re: Icons on desktop....
Post by: ramguru on November 08, 2006, 06:54:11 PM
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]
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 06:56:57 PM
this was just an example of my possibilitys :bg

ragdog
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 07:47:38 PM
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



Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 07:51:01 PM
 :U
that is not to work between home and professinal?
or which you meant?
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 08:03:31 PM

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]
Title: Re: Icons on desktop....
Post by: EddieB on November 08, 2006, 08:04:36 PM
Ramaguru's code worked for me :)
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 08:20:54 PM
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
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 08:26:50 PM

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


Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 08:30:50 PM
there are differences with the wparam function there between home and pro?

.if wParam == IDC_EXIT
      call HideIcons

       
        .elseif    wParam == 1002
   
        call    ShowIcons
   

        .endif         
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 08:37:00 PM

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
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 08:43:14 PM
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

Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 08:47:34 PM
sorry this algo

   .if wParam == IDC_HIDE
      call xxx

       
        .elseif    wParam == IDC_SHOW
   
        call   xxx
   

        .endif
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 08:58:02 PM

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
Title: Re: Icons on desktop....
Post by: 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.
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 09:04:23 PM
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
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 09:07:15 PM
thank ramguru :bg
Title: Re: Icons on desktop....
Post by: 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
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 09:16:47 PM

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

Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 09:26:29 PM
   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
Title: Re: Icons on desktop....
Post by: ramguru on November 08, 2006, 09:28:19 PM
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
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 09:42:04 PM
  is this correct???


   .ELSEIF uMsg==WM_COMMAND
              mov eax,wParam
    .IF eax == IDC_HIDE           
 
        .ELSEIF eax == IDC_SHOW

    .ENDIF
Title: Re: Icons on desktop....
Post by: ToutEnMasm on November 08, 2006, 10:28:05 PM

.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
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 10:32:39 PM
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]
Title: Re: Icons on desktop....
Post by: ramguru on November 08, 2006, 11:00:02 PM
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...
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 11:06:11 PM
 :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
Title: Re: Icons on desktop....
Post by: PBrennick on November 08, 2006, 11:40:15 PM
ragdog,
Thank you.
Paul
Title: Re: Icons on desktop....
Post by: ragdog on November 08, 2006, 11:42:43 PM
paul for wat??
Title: Re: Icons on desktop....
Post by: TNick on January 07, 2007, 01:47:07 PM
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.
Title: Re: Icons on desktop....
Post by: ramguru on January 07, 2007, 02:09:49 PM
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==...
Title: Re: Icons on desktop....
Post by: ragdog on January 07, 2007, 02:52:57 PM
thx fo the information :U

i make that so

.ELSEIF uMsg==WM_COMMAND
   .IF  wParam==1001
          call HideIcons
    .ELSEIF wParam==1002
          call    ShowIcons
    .ENDIF
Title: Re: Icons on desktop....
Post by: TNick on January 07, 2007, 02:58:56 PM
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