flat assembler
Message board for the users of flat assembler.

Index > Windows > WM_COMMAND catching

Author
Thread Post new topic Reply to topic
Rayslava



Joined: 07 Mar 2006
Posts: 7
Location: Moscow, Russia
Rayslava
So I'm a newbie in winapi programming and I've got a question:
I have a window and a LISTBOX on it, my aim is to get clicks and keyboard shortcuts from it.
So i am catching a WM_COMMAND message, then I filter message from my listbox thet way
Code:
cmp     ebx,[edithwnd]
je        edit        
    

And then after the label `edit` I don't know what to do...
Code:
cmp     [wparam],WM_LBUTTONDOWN
je        about  
    

doesn't work as I say.
P.S.
Please don't laugh at me and forward to Google, RTFM etc.
Cool
Post 07 Mar 2006, 20:45
View user's profile Send private message ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
IIRC you need WM_KEYDOWN or WM_KEYUP or WM_CHAR for keyboard, not WM_COMMAND. Or did I misunderstand something? Post some code, maybe there's an easier way?
Post 07 Mar 2006, 21:02
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Win32 Reference wrote:
WM_COMMAND
wNotifyCode = HIWORD(wParam); // notification code
wID = LOWORD(wParam); // item, control, or accelerator identifier
hwndCtl = (HWND) lParam; // handle of control

Let's say you have your WinProc defined like: hwnd, umsg, wparam, lparam. So:
hwnd = hwnd Smile
umsg = WM_COMMAND
wparam.hiword = notification code
wparam.loword = item id
lparam = control's hwnd

I suggest checking first the 'umsg' value for WM_COMMAND and then 'lparam' for the handle of listbox (or whatever). If both compares match you can be sure that someone clicked/focused/etc. on your listbox Smile
Post 07 Mar 2006, 21:34
View user's profile Send private message Visit poster's website Reply with quote
Rayslava



Joined: 07 Mar 2006
Posts: 7
Location: Moscow, Russia
Rayslava
Code:
proc WindowProc, hwnd,wmsg,wparam,lparam

        push    ebx esi edi
        mov     eax,[wmsg]
...
        cmp     eax,WM_COMMAND
        je      wmcommand
...
    


That's beginning of windowproc.

Code:
wmcommand:
        mov     ebx,[lparam]

        cmp     ebx,[edithwnd]
        je      edit
    


And this part also works fine.

Code:
 edit:
        cmp     [wparam],WM_LBUTTONDOWN
        je      about
        jmp     finish
    


And I have a suspicion, that in this part I'd use
Quote:
wNotifyCode = HIWORD(wParam);
.
I've read the manual, but what I have to compare NotifyCode with?
It's clear to me that my bug is hiding over here, but...
Post 08 Mar 2006, 06:31
View user's profile Send private message ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
for me it is not clear what exactly you do and what exactly you wish to do. what "edithwnd" means if you say about there is a list box? and what WM_COMMAND are you expecting from listview? zip your code please and post, and tell specific what behavior you are expecting of it.
regards!
Post 08 Mar 2006, 08:52
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
wNotifyCode = HIWORD(wParam); >

movzx eax,word [wParam + 2]
Post 08 Mar 2006, 08:54
View user's profile Send private message Visit poster's website Reply with quote
Rayslava



Joined: 07 Mar 2006
Posts: 7
Location: Moscow, Russia
Rayslava
Quote:

I have a window and a LISTBOX on it, my aim is to get clicks and keyboard shortcuts from listbox.


I get WM_COMMAND message, I can filter messages from my listbox, using lparam and then Program should select if the message is WM_LBUTTONDOWN or another... So my only problem is to get WM_message number from wparam.
For example there is a notify Message BN_CLICKED, but what messages I should check to get mouse clicks, keyboard buttons and how to convert wmNotify codes to WM_messages?
For example, how could I get a key that was pressed in the listbox window?


Description: Source
Download
Filename: FM.zip
Filesize: 2.58 KB
Downloaded: 56 Time(s)

Post 08 Mar 2006, 09:48
View user's profile Send private message ICQ Number Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Possible wNotfyCode values: (check win32 reference for their meaning)
LBN_DBLCLK
LBN_ERRSPACE
LBN_KILLFOCUS
LBN_SELCANCEL
LBN_SELCHANGE
LBN_SETFOCUS

Example. Let's say you want to catch when someone doubleclicks on your listbox. First, catch WM_COMMAND (in [umsg]), then check listbox handle (in [lparam]) and then LBN_DBLCLK (in word [wparam + 2]). If all these conditions are met - someone doubleclicked the listbox.

And something from my coding experience. Most of the time I just skip wNotifyCode checking. Usually I just process the message if it's WM_COMMAND and if the handle match. But if you must eg. differ between single- and doubleclick then freely try the combination with wNotifyCode.
Post 08 Mar 2006, 19:56
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
as far as i know there is no WM_COMMAND sent to the parent window when you press a key within the list box: that message will be sent by buttons, accelerators, menus. to catch listview notification messages you have to process WM_NOTIFY message: check for LVN_KEYDOWN for key pressed.
Post 09 Mar 2006, 05:54
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
when enter pressed in listview and not processed by it, then WM_COMMAND with wParam=IDOK will sent to the parent window. to catch VK_RETURN in listview you have to subclass listview and return DLGC_WANTALLKEYS to WM_GETDLGCODE message in subclassed routine. check there: http://board.flatassembler.net/topic.php?t=4786
Post 09 Mar 2006, 06:13
View user's profile Send private message Visit poster's website Reply with quote
Rayslava



Joined: 07 Mar 2006
Posts: 7
Location: Moscow, Russia
Rayslava
Thanks
Post 09 Mar 2006, 10:22
View user's profile Send private message ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
as well as i've been mixing listbox and listview and thus misguided you a little, so, here is my little help: a box working i think as well as you hope (just not with colour). also, i saw your source: you have to use FindClose when you finish use handle with FindNext.


Description:
Download
Filename: clr_list.1.1.zip
Filesize: 3.84 KB
Downloaded: 55 Time(s)


_________________
UNICODE forever!
Post 09 Mar 2006, 13:45
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.