Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

PBDLL6: DDT Popup-Menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PBDLL6: DDT Popup-Menu

    Code:
    #COMPILE EXE
    #INCLUDE "win32api.inc"
     
    %IDM_TEST1 = 101
    %IDM_TEST2 = 102
    %IDM_TEST3 = 103
    %IDM_TEST4 = 104
     
    DECLARE CALLBACK FUNCTION DlgProc
     
    FUNCTION PBMAIN
     
        LOCAL hDlg AS LONG
     
        DIALOG NEW 0, "Right click !",,,400,300, %DS_CENTER OR %WS_SYSMENU OR %WS_MINIMIZEBOX TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "&Exit", 350, 255, 40, 14
        DIALOG SHOW MODAL hDlg CALL DlgProc
     
    END FUNCTION
     
    
    CALLBACK FUNCTION DlgProc
     
        LOCAL pt AS POINTAPI
        LOCAL hPopup AS LONG
     
        SELECT CASE CBMSG
        CASE %WM_RBUTTONDOWN
            pt.x = LOWRD(CBLPARAM) : pt.y = HIWRD(CBLPARAM)
            ClientToScreen CBHNDL, pt
     
            MENU NEW POPUP TO hPopup
            MENU ADD STRING, hPopup, "Test1", %IDM_TEST1, %MF_ENABLED
            MENU ADD STRING, hPopup, "Test2", %IDM_TEST2, %MF_ENABLED
            MENU ADD STRING, hPopup, "Test3", %IDM_TEST3, %MF_ENABLED
            MENU ADD STRING, hPopup, "Test4", %IDM_TEST4, %MF_ENABLED
     
            TrackPopupMenu hPopup, %TPM_LEFTALIGN OR %TPM_RIGHTBUTTON, pt.x, pt.y, 0, CBHNDL, BYVAL 0
     
        CASE %WM_COMMAND
            SELECT CASE LOWRD(CBWPARAM)
            CASE %IDCANCEL
                DIALOG END CBHNDL
            CASE %IDM_TEST1
                MSGBOX "%IDM_TEST1"
            CASE %IDM_TEST2
                MSGBOX "%IDM_TEST2"
            CASE %IDM_TEST3
                MSGBOX "%IDM_TEST3"
            CASE %IDM_TEST4
                MSGBOX "%IDM_TEST4"
            END SELECT
        END SELECT
     
    END FUNCTION
Working...
X