News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Icons on desktop....

Started by Dark Schneider, November 08, 2006, 08:36:31 AM

Previous topic - Next topic

ragdog

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

ragdog


Relvinian

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

ToutEnMasm


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


ragdog

   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

ramguru

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

ragdog

  is this correct???


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

    .ENDIF

ToutEnMasm


.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

ragdog

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]

ramguru

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...

ragdog

 :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

PBrennick

The GeneSys Project is available from:
The Repository or My crappy website

ragdog


TNick

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.

ramguru

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==...