Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rightclick on Form Titlebar
Message
De
06/07/2020 09:33:31
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01675113
Message ID:
01675116
Vues:
172
This message has been marked as the solution to the initial question of the thread.
J'aime (4)
>I'm pretty sure that this is not possible, but I am asking anyway, maybe someone has an idea: Is it possible to show a custom popup menu on rightclick on a form's titlebar?
>
>I tried the rightclick() method, but that is not being called. Also I tried GetAsyncKeyState, but that also is not triggered when I right click in the titlebar of a form, except when I right click on the icon of the form.
>
>So I suppose this is handled very high up and shows always the move/resize context menu.

Try this:
* Each of these define mouse actions in the non-client areas of the window.
* Use the HT* defines below to test for which part to examine
#define WM_NCMOUSEMOVE          0x00A0

* Left button actions
#define WM_NCLBUTTONDOWN        0x00A1
#define WM_NCLBUTTONUP          0x00A2
#define WM_NCLBUTTONDBLCLK      0x00A3

* Right button actions
#define WM_NCRBUTTONDOWN        0x00A4
#define WM_NCRBUTTONUP          0x00A5
#define WM_NCRBUTTONDBLCLK      0x00A6

* Middle button actions
#define WM_NCMBUTTONDOWN        0x00A7
#define WM_NCMBUTTONUP          0x00A8
#define WM_NCMBUTTONDBLCLK      0x00A9

* Other button actions
#define WM_NCXBUTTONDOWN        0x00AB
#define WM_NCXBUTTONUP          0x00AC
#define WM_NCXBUTTONDBLCLK      0x00AD

* We need to continue the message chain and not just intercept and hog the message
DECLARE INTEGER DefWindowProc IN WIN32API INTEGER hwnd, INTEGER msg, INTEGER wparam, INTEGER lparam

* Tell Windows to send thisForm.HWnd the messages related to the right-mouse-button-going-down
* Use other BINDEVENT()s for other actions you'd like to track
BINDEVENT(thisForm.HWnd, WM_NCRBUTTONDOWN, thisForm, "non_client_mouse_down")


**********************************************************
* For the non_client_mouse_down() method:
LPARAMETERS tnHwnd, tnMsg, tnHitTest, tnCoords
LOCAL lnX, lnY

* These define the "hit test" or "what's there at the coordinates the user did something"
#define HTERROR                 (-2)
#define HTTRANSPARENT           (-1)
#define HTNOWHERE               0
#define HTCLIENT                1
#define HTCAPTION               2
#define HTSYSMENU               3
#define HTGROWBOX               4
#define HTSIZE                  HTGROWBOX
#define HTMENU                  5
#define HTHSCROLL               6
#define HTVSCROLL               7
#define HTMINBUTTON             8
#define HTMAXBUTTON             9
#define HTLEFT                  10
#define HTRIGHT                 11
#define HTTOP                   12
#define HTTOPLEFT               13
#define HTTOPRIGHT              14
#define HTBOTTOM                15
#define HTBOTTOMLEFT            16
#define HTBOTTOMRIGHT           17
#define HTBORDER                18
#define HTREDUCE                HTMINBUTTON
#define HTZOOM                  HTMAXBUTTON
#define HTSIZEFIRST             HTLEFT
#define HTSIZELAST              HTBOTTOMRIGHT
#define HTOBJECT                19
#define HTCLOSE                 20
#define HTHELP                  21

    * Get coordinate within the window's non-client area where it was clicked
    lnX = BITAND(tnCoords, 0xffff) - thisForm.Left
    lnY = BITRSHIFT(BITAND(tnCoords, 0xffff0000), 16) - thisForm.Top
    * Note:  lnX and lnY can still be off if you're using a non-ShowWindow-AsTopLevelForm form.
    * Note:  Use SYSMETRIC() functions to get the correct values in those cases.

    * See where they did it
    DO CASE
        CASE tnHitTest = HTCAPTION
            * You can check GetAsyncKeyState() here to see if it's a Shift+Right click, or Ctrl+, etc.
            thisForm.onRightClickTitleBar(lnX, lnY)

        * Other items can be tracked here as well
    ENDCASE

    * Call Windows like normal, so it processes its own events
    DefWindowProc(tnHwnd, tnMsg, tnHitTest, tnCoords)


**********************************************************
* For the onRightClickTitleBar() method
LPARAMETERS tnX, tnY

    WAIT WINDOW "X=" + TRANSFORM(tnX) + CHR(13) + "Y=" + TRANSFORM(tnY) NOWAIT
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform