When I right click on a ListBox,which message will the window receives?

Started by stalker, July 30, 2008, 09:04:58 AM

Previous topic - Next topic

stalker

as the title,how to empty a ListBox(of course in win32asm)
haha,the post work now,I have a new question about ListBox
as the title also,actually,i want my program work like this:when i right click on the ListBox,a pop menu will appear

stalker

#1
LB_RESETCONTENT

there has another question on the top :bg

hutch--

No need to apologise, its a reasonable question and you have provided the answer as well.  :U
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

PBrennick

Personally, I always enjoy questions because it keeps my brain working ( and sometimes I even have the right answer ). What is really exciting, though, is to see someone find a solution themselves. It is a credit to a person who just does not sit back and wait for an answer but continues to plug away trying to find an answer themselves.

Good work, stalker.

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

stalker

hey,Paul,nice to meet you
but have you saw my new question?I add a new question in the post

PBrennick

stalker,
This is the way to do it.


       .elseif uMsg == WM_RBUTTONDOWN
         invoke  GetCursorPos, ADDR Pt
         invoke  GetSubMenu, hMnu, menu_popup
         mov     hSM, eax
         invoke  TrackPopupMenu, hSM, TPM_LEFTALIGN or TPM_LEFTBUTTON,
                 Pt.x, Pt.y, 0, hWnd, NULL



Where the WM_RBUTTONDOWN and TrackPopupMenu are very important. I am attaching a very old editor I wrote years ago that has this code in it. With it you can see how it is done. The menu is drawn as a copy from the main menu. In this case, I am using the File subMenu, you can use any of them or create an original one with special functions.
If you need more help, just ask.
-- Paul


[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

japheth


IIRC the window receives WM_RBUTTONDOWN, the parent window gets a WM_NOTIFY / NM_RCLICK. 


PBrennick

Japheth,
That is possible although the documentation does not mention that. At any rate the menu pops up without processing those messages as you can see in the editor. The only thing I am using WM_NOTIFY for is the processing of ToolTips.

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

japheth

Quote from: PBrennick on July 30, 2008, 03:07:20 PM
Japheth,
That is possible although the documentation does not mention that. At any rate the menu pops up without processing those messages as you can see in the editor. The only thing I am using WM_NOTIFY for is the processing of ToolTips.

-- Paul

Yes, sorry! I meant Common Controls - like ListView - but the OP talked about ListBox, so my comment was a bit off-topic.

stalker

thank you  all at first

.elseif uMsg == WM_RBUTTONDOWN
    invoke MessageBox,0,0,0,0


I added the code above in my message process function,but when i right click on the ListBox,nothing happened :(

jj2007

Quote from: stalker on July 31, 2008, 01:36:02 AM
I added the code above in my message process function,but when i right click on the ListBox,nothing happened :(

You may have to subclass the listbox. Here are the necessary elements.

SubList   PROTO:DWORD,:DWORD,:DWORD,:DWORD

opList   dd ? ; handle to listbox

   invoke SetWindowLong, hList, GWL_WNDPROC, SubList
   mov opList, eax

SubList proc hwnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
   SWITCH uMsg
   CASE WM_RBUTTONUP

   CASE WM_RBUTTONDOWN

   ENDSW

  invoke CallWindowProc, opList, hwnd, uMsg, wParam, lParam
  ret
SubList endp

evlncrn8

its a bit over the top subclassing it for that, just use the messaging system, less bother and less potential for bugs...

stalker

thank your code jj2007,my problem have solved,thank you all again :bg

jj2007

Quote from: evlncrn8 on July 31, 2008, 10:20:57 AM
its a bit over the top subclassing it for that, just use the messaging system, less bother and less potential for bugs...

I like simple solutions - show me, please!

PBrennick

JJ,
Tedd already explained this in another topic. If you add something like the following to the main message loop that usually is in WinMain (doesn't have to be, though):


    invoke  IsDialogMessage, hFind, addr msg  ; Find Dialog box message?


You will add the dialog to the messaging system. In this case, this is processing my FIND dialog in my editor. If the message is for this dialog, acontrol is passed to FindDlgProc and the key is processed.

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