Started by Theo Gottwald, March 01, 2008, 09:03:55 PM
0 Members and 1 Guest are viewing this topic.
DECLARE SUB U_LV_Notify(BYVAL S01 AS STRING,BYVAL CVal&,BYVAL Cancel&)' Here are the Listview Events'SUB WF_LISTVIEW1_Events( MyID&, CMsg&, CVal&, Cancel&) SELECT CASE AS LONG CMsg& CASE %EZ_Selected CASE %EZ_Focus CASE %EZ_RButtonUp ' Doesn't work, the Listview does not generate this Event CASE ELSE END SELECTEND SUBSUB WF_LISTVIEW1_Notify(BYVAL CVal&, Cancel&) ' The term "WF" will identify the Form and will be internally computed to the Form-Windows-handle, this is EZGUI specific. ' U_LV_Notify "WF",CVal&, Cancel&END SUB' Here we get the Right Mouse button Click'SUB U_LV_Notify(BYVAL S01 AS STRING,BYVAL CVal&,BYVAL Cancel&) REGISTER R01 AS LONG LOCAL T01 AS PointAPI LOCAL hCtrl&, ID&, NCode& , NM AS LONG PTR, X&, Y& EZ_GetNotify CVal&, hCtrl&, ID&, NCode& SELECT CASE AS LONG NCode& ' Notification Code CASE -5 ' this is NM_RCLICK GetCursorPos(T01) ' This is the way to get the Mouse Position in Screen coordinates U_DoPopup(S01,hCtrl&,ID&,T01.X&,T01.Y&) ' Here comes the EZGUI PopUp-Menu R01=EZ_SetMouseXY(T03,T04) ' this will decode the Hi- and Loword of the X- and Y-Position S02="Copy|Paste|Cut" ' Please note the "S" at the end, this will make the Menu appear in Screen coordinate EZ_DoPopupMenu S01, R01, 9000, S02, "S" END SELECT END SUB ' And this is the Message Loop for the Form itself.' This is where we get the Menu-Press.'SUB WF_Events(CID&, CMsg&, CVal&, Cancel&) SELECT CASE AS LONG CID& CASE %EZ_Window SELECT CASE AS LONG CMsg& CASE %EZ_Loading CASE %EZ_Loaded U_WF_Loaded() ' This is User-Code CASE %EZ_Size EZ_ResizeRTForm "WF" CASE %EZ_Close U_WF_Close() EZ_FreeRTForm "WF" CASE ELSE END SELECT ' Popup_menu-Items CASE 9000:IF CMsg& = %EZ_Click THEN U_WF_B3(0) ' Copy CASE 9001:IF CMsg& = %EZ_Click THEN U_WF_B4() ' Delete CASE 9002:IF CMsg& = %EZ_Click THEN U_WF_B2() ' Cut CASE ELSE END SELECTEND SUB
QuoteHello Theo,I solved the problem and posted working code in the forum.See:http://chrisboss.hypermart.net/ubb/Forum1/HTML/000690.htmlThe problem was quite simple. Popup menus don't work right with the common controls (ie. treeview, listview) when created during a mouse down event. They must be created during a mouse UP event. This is a quirk in Windows and has nothing to do with EZGUI as far as I can tell. The trouble was getting the right button up event. This can't be done trhough subclassing because the common controls are somehow preventing the generation of this message. It can be down though through WM_NOTIFY and I demonstrate how to do it.The code in my posted example should work exactly the same for the listview control.
CASE %WM_CONTEXTMENU ' Display the context menu associated with the window IF GetDlgCtrlID(wParam) = %IDC_FORM1_LISTVIEW1 THEN dwFlags = %TPM_LEFTBUTTON OR %TPM_LEFTALIGN OR %TPM_TOPALIGN OR %TPM_HORIZONTAL lMsgResult = phnxContextMenu(hWnd, wParam, lParam, ghInstance, %IDR_FORM1_POPUPMENU1, dwFlags) EXIT FUNCTION END IF
Page created in 0.220 seconds with 21 queries.