I have a custom form which does not have any type of border. I'm drawing some custom borders of my own instead, which do not extend up to the far edges of the form. Instead, whatever's outside this custom drawn border is transparent, through the use of the form's transparent properties. This leaves a smaller portion of the form to be usable and visible.
I know there are tons of solutions out there to accomplish this, and I've already found the best suited method to do this. However, this method assumes that user will be pointing the mouse along the far edges of the form. I need to limit it to react from within different constraints (for example a smaller sized rect).
Here's the code I found which already works on a next-to-the-edge constraint:
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
....
procedure TForm1.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 begin
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;
end;
end;
How would I go about changing the bounds for this to react? For example, the left and right edges should react 10 pixels into the form. The standard form rect may be (0, 0, 100, 100)
but I want this method above to work within bounds of (10, 3, 90, 97)