;This function can be used with SetWindowSubclass as window procedure. ;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)
;OutWinMsg message wParam lParam _s _i ;;uncomment to see received messages sel message ,caseWM_RBUTTONUP ,Acc a.FromMouse ,int mi=iif((a.elem<>0)21) ,mac"sub.rcmessage""" mi int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass);;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass) ,;case ...
ret R
#sub rcmessage function i sel i ,case1 ,mes("button was right clicked") ,case2 ,mes("combo list was right clicked")
;This function can be used with SetWindowSubclass as window procedure. ;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)
;OutWinMsg message wParam lParam _s _i ;;uncomment to see received messages sel message ,caseWM_RBUTTONUP ,Acc a.FromMouse ,int mi=iif((a.elem<>0)21) ,mac"sub.rcmessage""" mi int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass);;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass) ,;case ...
ret R
#sub rcmessage function i sel i ,case1 ,;_s.getwintext(id(4 hDlg)) ,mac+ _s , ,case2 ,;_s.getwintext(id(4 hDlg)) ,mac+ _s
;This function can be used with SetWindowSubclass as window procedure. ;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)
;OutWinMsg message wParam lParam ;;uncomment to see received messages sel message ,caseWM_RBUTTONUP ,Acc a.FromMouse ,int rcrn=a.Role ,str rcitem=a.Name ,if rcrn=34 ,,int rccbh=a.Hwnd ,,int rciti= a.elem -1 ,,mac"sub.rcmessage""" rcrn rcitem rciti rccbh ,else ,,mac"sub.rcmessage""" rcrn rcitem int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass);;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass) ,;case ...
ret R
#sub rcmessage function i [~item][itemindex][chwnd] str mtext sel i ,case43: ,mtext="button was right clicked" ,case34: ,,;mtext.format("combo list item: (%s) was right clicked" item) ,,CB_SelectItem(chwnd itemindex) ,,mac+ item ,case33: ,,mtext="combo list was right clicked on an empty item" if(!empty(mtext)) ,mes(mtext)
;This function can be used with SetWindowSubclass as window procedure. ;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)
;OutWinMsg message wParam lParam ;;uncomment to see received messages sel message ,caseWM_RBUTTONUP ,Acc a.FromMouse ,int rcrn=a.Role ,str rcitem=a.Name ,if rcrn=34 ,,int rccbh=a.Hwnd ,,int rciti= a.elem -1 ,,mac"sub.rcmessage""" rcrn rcitem rciti rccbh ,else ,,mac"sub.rcmessage""" rcrn rcitem int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass);;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass) ,;case ...
ret R
#sub rcmessage function# i [~item][#itemindex][#chwnd] str mtext sel i ,case43: ,mtext="button was right clicked" ,case34: ,,;mtext.format("combo list item: (%s) was right clicked" item) ,,CB_SelectItem(chwnd itemindex) ,,mac+ item ,case33: ,,mtext="combo list was right clicked on an empty item" if(!empty(mtext)) ,mes(mtext)
and if still error try this
Function DialogSubclassExample
;This function can be used with SetWindowSubclass as window procedure. ;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)
;OutWinMsg message wParam lParam ;;uncomment to see received messages sel message ,caseWM_RBUTTONUP ,Acc a.FromMouse ,int rcrn=a.Role ,str rcitem=a.Name ,if rcrn=34 ,,int rccbh=a.Hwnd ,,int rciti= a.elem -1 ,,mac"sub.rcmessage""" rcrn rcitem rciti rccbh ,;else ,,;mac "sub.rcmessage" "" rcrn rcitem int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass);;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass) ,;case ...
ret R
#sub rcmessage function# i ~item #itemindex #chwnd str mtext sel i ,case43: ,mtext="button was right clicked" ,case34: ,,;mtext.format("combo list item: (%s) was right clicked" item) ,,CB_SelectItem(chwnd itemindex) ,,mac+ item ,case33: ,,mtext="combo list was right clicked on an empty item" if(!empty(mtext)) ,mes(mtext)
and if your not using the latest qm please update qm and try again. Latest version is 2.4.8.2
04-23-2019, 02:13 PM (This post was last modified: 04-23-2019, 02:15 PM by win.)
In addition, right-click on the item in the list box to open the function, but when opened, the item is not selected.
I don't understand the number 43 34 Where did it come from?
this code would fail every time. You can't run a dialog button text. In this case item is just the name of the button.
case 43:
mtext="button was right clicked"
mac+ item
04-23-2019, 02:21 PM (This post was last modified: 04-23-2019, 02:23 PM by Kevin.)
"I hope that when I right click on the item, It will select the item first and then open it."
it does that it just happens so fast you dont see it cause qm window covers dialog window
you need to look at the code above and figure out where the numbers are coming from
04-23-2019, 02:34 PM (This post was last modified: 04-23-2019, 02:49 PM by Kevin.)
because you don't understand the code at all .I explained above that you cannot use mac + in case 43 as the value of item in that case is the button name.
and also the button is not programed to do anything other than popup a message. And in the code your using the button subclassing is disabled
;This function can be used with SetWindowSubclass as window procedure. ;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)
;OutWinMsg message wParam lParam ;;uncomment to see received messages sel message ,caseWM_RBUTTONUP ,Acc a.FromMouse ,int rcrn=a.Role ,str rcitem=a.Name ,if rcrn=34 ,,int rccbh=a.Hwnd ,,int rciti= a.elem -1 ,,mac"sub.rcmessage""" rcrn rcitem rciti rccbh ,else ,,mac"sub.rcmessage""" rcrn rcitem int R=DefSubclassProc(hwnd message wParam lParam)
sel message ,caseWM_NCDESTROY ,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass);;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass) ,;case ...
ret R
#sub rcmessage function# i [~item][#itemindex][#chwnd] str mtext sel i ,case43: ,mtext="button was right clicked" ,case34: ,,;mtext.format("combo list item: (%s) was right clicked" item) ,,CB_SelectItem(chwnd itemindex) ,,mac+ item ,case33: ,,mtext="combo list was right clicked on an empty item" if(!empty(mtext)) ,mes(mtext)