Implement the window title you can drag

xiaoxiao2021-03-06  17

1. Do a message mapping for WM_NCHITTEST.

Begin_MESSAGE_MAP Message_Handler (WM_NCHITTEST, TMESSAGE, WMNCHITEST) END_MESSAGE_MAP (TFORM)

2, then add the following code in the message processing function:

void __fastcall TDragForm :: WMNCHitTest (TMessage & Msg) {int xPos, yPos; xPos = LOWORD (Msg.LParam); yPos = HIWORD (Msg.LParam); TPoint Pxy; Pxy = Point (xPos, yPos); Pxy = ScreenToClient ( PXY); BOOL MDRAG1 = PtinRect (& (Shape1-> BoundSRect), PXY); if (getasynckeyState (vk_lbutton <0 && mdrag1) msg.result = htcaption; else msg.result = htclient;}

(Shape1-> BoundSRect is the setting area) so you can remove the blue title bar of the ordinary window, change a better look.)

转载请注明原文地址:https://www.9cbs.com/read-44065.html

New Post(0)