How to change the shape of your forms?



How to change the shape of your forms?..

Answer / editcdc

Found this write-up online:

n general terms, the algorithm goes like this:

1.

We adjust the form to the dimensions of the BMP file.
This is simple. For the purpose, the following two lines
will do it:

// Ajustar el área / to Ajust the area
ClientWidth := Image1.Width;
ClientHeight:= Image1.Height;

2.

We read the first pixel of the form and take it as
"transparent".
3.

We search for the first "non-transparent" pixel and
from this point we generate a polygon with the silhouette of
the "non-transparent" part (see GenRegion in the file
ffigura.pas).
4.

We get rid of the title bar (if it's still bothering
us). To do it:

BorderStyle := bsNone; // Titulo estorba / no Title

5.

We change the shape of the form according to the
polygon. To do it we make use of the CreatePolygonRgn and
SetWindowRgn API functions (see ActiveSkin in ffigura.pas).
Unlike the example of the first part of this article, in
this one we don't define an elliptical (circular) region.
6.

We set from the TImage the necessary events for
dragging the form like we did in the example of the first
article.

Except for the third step, nothing seems too difficult. To
generate the polygonal region we just look for the frontier
of the figure, then we advance thru all the outline of the
figure until we reach the starting point (or run out of
memory, in this case 1024 points). This series of points
define a polygon used to generate a region with the function
CreatePolygonRgn. Then we use SetWindowRgn y we get the form
with the given shape. It works but it has limitations: our
figure must have only one frontier, therefore it can't be a
figure with a hole in the middle (in any case the algorithm
will ignore the hole in the middle).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Delphi Interview Questions

How to Disable close button of a window ?

1 Answers  


What are the different types of object allocations methods in delphi?

1 Answers  


How to Display a bitmap on the client area of an MDI parent form?

1 Answers  


How to Use Date as a Field Name ?

1 Answers  


Why you want to join IBM only not others like, TCS Infosys, Satyam & Wipro Etc. please do'nt give general answers?.

14 Answers   IBM,


How to adjust the tab location in a TMemo component ?

1 Answers  


How to have a TBitBtn component that has a word wrapped caption?

1 Answers  


How to Print a TStringGrid / TDBGrid?

1 Answers  


How to make the TDateTimePicker display blank?

1 Answers  


How to Create a PolyPolygon using a point array?

1 Answers  


How to Create a palette with more than one entry ?

1 Answers   Wipro,


what is Client launching ?

1 Answers  


Categories