§ Borderless window resizing with WM_NCHITTEST
Want to have a borderless window that can be resized like a normal window? Use WM_NCHITTEST.
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST; ... procedure TForm2.WMNCHitTest(var Message: TWMNCHitTest); const EDGEDETECT = 7; //adjust to suit yourself var deltaRect: TRect; //not really used as a rect, just a convenient structure begin inherited; if BorderStyle = bsNone then with Message, deltaRect do begin Left := XPos - BoundsRect.Left; Right := BoundsRect.Right - XPos; Top := YPos - BoundsRect.Top; Bottom := BoundsRect.Bottom - YPos; if (Top<EDGEDETECT)and(Left<EDGEDETECT) then Result := HTTOPLEFT else if (Top<EDGEDETECT)and(Right<EDGEDETECT) then Result := HTTOPRIGHT else if (Bottom<EDGEDETECT)and(Left<EDGEDETECT) then Result := HTBOTTOMLEFT else if (Bottom<EDGEDETECT)and(Right<EDGEDETECT) then Result := HTBOTTOMRIGHT else if (Top<EDGEDETECT) then Result := HTTOP else if (Left<EDGEDETECT) then Result := HTLEFT else if (Bottom<EDGEDETECT) then Result := HTBOTTOM else if (Right<EDGEDETECT) then Result := HTRIGHT end; //with Message, deltaRect; if BorderStyle = bsNone end;
That's it! Now Windows will take care of the resizing arrows and the resizing as you drag the edges.
last edited on May 7th, 2010 at 6:36 PM
Categories
Comments
- Walid on "Adventures with Ubuntu 9.10 on G4 Yikes!" - I am in the same process as you. Although I still dual-boot to Windows for my ganimg leisure. My first contact with Ubuntu was way…
- Slashback on "Simpler adding & removing element classnames" - Actually, the addClassName function does what you want, pretty much the same way you suggest.
- angie on "Simpler adding & removing element classnames" - And what if I want to add a class, but keeping the csseals the element already has?I mean, I have an element with a class, let's name…
- backlinks on "Adjust iframe height to contents" - Definitely helped me.
- Slashback on "Simpler validate form fields are filled in (no additional class names)" - You are welcome!