Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP window dont draggable when maximize
Message
From
02/01/2024 04:01:30
 
 
To
06/12/2023 09:09:53
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
01687384
Message ID:
01687491
Views:
60
Likes (1)
>Hi @all
>
>In this blogpost:
>http://yousfi.over-blog.com/2016/01/vfp-window-dont-draggable-when-maximized.html
>
>Yousfi Benameur describes the Problem. Does anyone have an solution?

I did something similar for top level windows, this is an adjusted example how to bind to the click event on the titlebar. Using the other events you could try optimizing it.
* 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

#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          0x00A

DEFINE CLASS TitleBarController AS Custom

PROCEDURE Register
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(_VFP.HWnd, WM_NCLBUTTONDOWN, THIS, "non_client_mouse_down")
ENDPROC

PROCEDURE non_client_mouse_down

LPARAMETERS tnHwnd, tnMsg, tnHitTest, tnCoords

LOCAL loForm
loForm = _SCREEN

* Get coordinate within the window's non-client area where it was clicked
* LOCAL lnX, lnY
* lnX = BITAND(m.tnCoords, 0xffff) - loForm.Left
* lnY = BITRSHIFT(BITAND(m.tnCoords, 0xffff0000), 16) - loForm.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.

LOCAL llDefaultProc
llDefaultProc = .T.

DO CASE
    CASE m.tnHitTest = HTCAPTION
	
        * You can check GetAsyncKeyState() here to see if it's a Shift+Right click, or Ctrl+, etc.
        llDefaultProc = THIS.OnLeftClickTitleBar()

ENDCASE

* Call Windows like normal, so it processes its own events
IF m.llDefaultProc
	DefWindowProc(m.tnHwnd, m.tnMsg, m.tnHitTest, m.tnCoords)
ENDIF

RETURN .T.
ENDPROC

PROCEDURE OnLeftClickTitleBar
	_SCREEN.WindowState = 0
ENDPROC

ENDDEFINE
Christian Isberner
Software Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform