---- Since Window 95 adds support to window area concepts, the window area is the shape of the defined window, the window area is used as the actual boundary area of the window, so that the window area not only defines the colorless area of the window, Moreover, the hidden area and the response window area of the response mouse key event are defined.
---- The various shapes of the button are set at runtime instead of setting up when designing. The shape of the button is still rectangular or square.
---- Button shape is divided into two steps.
---- The first step is created the shape of the button, that is, the window area is defined. Creating a function using an API can achieve the purpose. There are a lot of regional creation functions, mainly CreatellLipTicRGN, CreatePolygonRGN, CreateRectrGN, CreateroundRectrGN, which is used to create different types of area displays. If a complex area shape is required, you can create different zones using different zone functions, and then call the CombinerGN API function to combine them. So, not only create a park, a triangular button, but also a button of other shapes.
---- The second step is applied to the window. Once a new area display is created using the zone function, you can apply this zone to the window using the SetWindowsRGN function.
---- The specific code achieved by the garden shape and triangle button will be given below. To visually display the effect, set the background color of the form to black (Color Set to CLBTNTEXT) and set the Cursor of the two buttons to CRCROSS. Place two Button buttons in the form, defined as RButton, TButton, respectively. The best time to implement the window area is to create a handler in the oncreate event in the form of the form.
Void __fastcall tform1 :: formcreate (TOBJECT * Sender) {// Create a garden button hrgn hrgnr = cretellipticRGN (0, 0, rbutton-> width, rbutton-> height); setWindowRgn (RButton-> Handle, HRGNR, true);
// Create a triangular button trpoint [0] .x = tbutton-> width / 2; trpoint [0] .y = 0;
Trpoint [1] .x = 0; trpoint [1] .y = tbutton-> height;
Trpoint [2] .x = tbutton-> width; trpoint [2] .y = tbutton-> height;
HRGN HRGNT = CREATEPOLYGONRGN (Trpoint, 3, Alternate); setWindowRgn (TButton-> Handle, HRGNT, TRUE);} where trpoint is defined in unit.h header files as follows: private: // user declarationspoint trpoint [3]; - - The above code creates a garden area and a triangular area within the boundary of the button, and then assigns it to the respective buttons as the new window area. When you create a garden button, use the Ellipse area to create a function, to make the button as a garden in design, the button should be designed as a square. The additional area is defined in the form of buttons coordinates, rather than using screen coordinates. (0, 0) The point is the upper left corner of the button, and the (width, high) point is the bottom right corner of the button.
---- It should be noted that once the zone handle is assumed to the button, the zone handle cannot be used for any operation. If you assign the zone handle to the button, modify or delete this handle will cause the program to crash.