I have a code that creates a hole in Form
using the mouse.
var
FormRegion, HoleRegion: HRGN;
begin
FormRegion := CreateRectRgn(0, 0, Form1.Width, Form1.Height);
HoleRegion := CreateRectRgn(X1, Y1, X2, Y2);
CombineRgn(FormRegion, FormRegion, HoleRegion, RGN_DIFF);
SetWindowRgn(Form1.Handle, FormRegion, True);
end;
Now i wish put one Panel
(that already have a fixed height) always above of hole region (and with same width of hole) to simulate a title bar, something like this:
How can be made?
You did not read carefully my request for additional information, so I leave it to you to adjust however you like.
Anyway, I believe your actual question is concerning the alignment of the panel with the transparent region. You probably do not consider that the region calculations with the form window includes the borders, so you have an offset to the right and downwards.
Since the regions are calculated including the borders of the form, you will need a variable
ClientOffset: TPoint
to hold the values of width of the left border and the height of the top border (incl. title bar of the form).To calculate the
ClientOffset
you can use the predefinedClientOrigin
and the formsLeft
andTop
properties.Then, either subtract
ClientOffset
from the panelsLeft
andTop
properties, or addClientOffset
to theHoleRegions
coordinates. The latter being more correct if you use the mouse (and presumably the forms client coordinates) to define the "hole" region