After a week of silence, I started my blog again today.
Today, let's take a look at a more interesting feature in winx-control window layout. The window size is restricted, and the layout control is used.
Follow the winx tutorials. There are two examples:
MinsizelimitWorkChengWe introduced a macro that limits the window size,LayoutThe project introduces the macro used to arrange the layout of controls.
Limit window size
In the minsizelimit exampleWinx_mininfo_defaultMACRO: This is a macro that controls the window size. Its function is to make the window size not smaller than the initial size. If the window is a dialog box, the minimum size of the dialog box is the size when the resource design starts. After this macro is added, the window size cannot be smaller than the initial size.
This macro has no parameters. Its usage is in the class definition and is written as follows:
Winx_mininfo_default ();
In fact, there are other Macros in the restricted window:
Winx_mininfo
Winx_mininfo_pt
Winx_mininfoIt has two parameters, assuming CX and Cy, which indicate the minimum width and height of the window to be restricted. The usage is written as follows in the class definition:
Winx_mininfo (CX, CY); // Where CX and Cy are the width and height you want to limit
Winx_mininfo_ptIt is similar to winx_mininfo, but the parameter winx_mininfo_pt is a point structure in windows and is defined as follows:
Typedef struct tagpoint
{
Long X;
Long y;
} Point;
We can see that the macro is consistent. The usage is as follows:
Winx_mininfo_pt (PT );
Some people will say that the initial size of a dialog box can be obtained when I design it. But how can I know the initial size of a normal window? Here we need to introduce an auxiliary macro:
It is used to get the initial size of the window and store it into a private variable of the class. The name of this private variable is the macro parameter. For example, write the following in the class definition:
Winx_initial (m_ptorgsize );
The program automatically writes the initial size of the window to the private variable m_ptorgsize of the class (object. In this way, we can control the initial size of the window.
Arrange widget Layout
In the example layout, the layout of the Arrangement control is demonstrated. The following macros are used:
Winx_dlgresize_begin
Winx_dlgresize
Winx_dlgresize_end
The layout of the control is to set anchor for the control. For example, if you want to control a widget in the upper right corner, set its anchor to the upper right corner. This is the arrangement space layout ,:). This may be caused by a bunch of (rather than one) controls that set anchor. Therefore, winx provides two macro labels, winx_dlgresize_begin and winx_dlgresize_end, respectively. This method is similar to the Command Message.
When looking at the code in the example layout, we noticed that the winx_dlgresize_begin macro has a parameter with the value true or false, which indicates whether to allow the window (dialog box) set the minimum window size limit. If it is set to false, the window size limit is invalid even if you use macros such as winx_mininfo described above. If this parameter is set to true, the minimum window size limit can be set.
The winx_dlgresize macro sets anchor for the arrangement of specific controls. As shown in the following example:
Winx_dlgresize (idc_righttop, anchorrighttop)
This macro sets the anchor of the control whose ID is idc_righttop to anchorrighttop, which means that the control is located in the upper right corner of the window regardless of the window changes.
Anchor has the following values:
Anchor |
Description |
Anchorrighttop |
Always on top right |
Anchorleftbottom |
Always in the lower left corner |
Anchorrightbottom |
Always in the lower right corner |
Anchorall |
The size varies with the window size. |
Note thatThese macros are not followed by semicolons, which is different from the macro winx_mininfo.
<End>