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
LB_RESETCONTENT
there has another question on the top :bg
No need to apologise, its a reasonable question and you have provided the answer as well. :U
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
hey,Paul,nice to meet you
but have you saw my new question?I add a new question in the post
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]
IIRC the window receives WM_RBUTTONDOWN, the parent window gets a WM_NOTIFY / NM_RCLICK.
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
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 List
Box, so my comment was a bit off-topic.
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 :(
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
its a bit over the top subclassing it for that, just use the messaging system, less bother and less potential for bugs...
thank your code jj2007,my problem have solved,thank you all again :bg
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!
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
Quote from: PBrennick on July 31, 2008, 02:50:05 PM
JJ,
Tedd already explained this in another topic. If you add
...
invoke IsDialogMessage, hFind, addr msg ; Find Dialog box message?
Maybe we can ask Stalker to post his code, and then you try to make it work? I tried in my own editor, but the listbox just doesn't care about WM_
RBUTTONxx.