First look at the figure:
During form expansion:
Full Form display:
To display an animated window, you need to use the movewindow function and the timer. The movewindow function can change the position and size of the specified window, with the timer, You can dynamically change the position and size of the window within a certain period of time. The movewindow function is prototype as follows: Function prototype: bool movewindow (hwnd, int X, int y, int nwidth, int nheight, bool brepaint );
Parameters
Hwnd specifies the window handle
X specifies the new position on the left of cwnd.
Y specifies the new position on the top of cwnd.
Nwidth specifies the new width of cwnd.
Nheight specifies the new height of cwnd.
Brepaint specifies whether to re-draw cwnd. If it is true, cwnd receives a wm_paint message in the onpaint message processing function as usual. If this parameter is set to false, no type of re-painting will be performed. This applies to the customer area, non-customer area (including title bar and scroll bar), and any part of the parent window exposed by cwnd movement. When this parameter is set to false, the application must explicitly invalidate or redraw the required part of the cwnd and parent windows.
Movewindow sends wm_windowposchanging, wm_windowposchanged, wm_move, wm_size, and wm_nccalcsize messages to the window.
Two overload functions of movewindow ()
Void cwnd: movewindow (int x, int y, int nwidth, int nheight, bool brepaint = true );
Void cwnd: movewindow (lpcrect lprect, bool brepaint = true );
Parameters
X specifies the new position on the left of cwnd.
Y specifies the new position on the top of cwnd.
Nwidth specifies the new width of cwnd.
Nheight specifies the new height of cwnd.
Brepaint specifies whether to re-draw cwnd. If it is true, cwnd receives a wm_paint message in the onpaint message processing function as usual. If this parameter is set to false, no type of re-painting will be performed. This applies to the customer area, non-customer area (including title bar and scroll bar), and any part of the parent window exposed by cwnd movement. When this parameter is set to falseProgramThe part that must be re-painted in the cwnd and parent windows must be explicitly invalid or re-painted.
The lprectcrect object or rect structure, specifying the new size and position. This function changes the position and size of the window. For the top-level cwnd object, the X and Y parameters are relative to the upper left corner of the screen. For sub-objects, they are relative to the upper left corner of the parent window customer area.
The movewindow function sends a wm_getminmaxinfo message. When processing this message, cwnd gets an opportunity to change the maximum and minimum window defaults. If the parameter passed to the movewindow member function exceeds these values, the minimum or maximum value can be used in the wm_getminmaxinfo processing function.
First, let's look at the implementation process: Void cdhxsctdlg: ontimer (uint nidevent) {// Todo: add your message handler code here and/or call default Getwindowrect (rect ); Getwindowrect topwindow ()-> getwindowrect (RC );Movewindow (-m_dx + RC. width ()-rect. width ()/2, (-m_dy + RC. height ()-rect. height ()/2, + m_dx + rect. width (), + m_dy + rect. height (); If (rect. height ()> = m_height) {m_dy = 0;} If (rect. width ()> = m_width) & (rect. height ()> = m_height) {killtimer (1) ;}cdialog: ontimer (nidevent) ;}in the initialization function of the dialog box: getwindowrect (rect); getwindowtopwindow () -> getwindowrect (RC); movewindow (RC. width ()-rect. width ()/2, (RC. height ()-rect. height ()/2, 0, 0); m_wi DTH = rect. Width (); m_height = rect. Height (); m_dx = 2; m_dy = 2; settimer (, null); This achieves the above effect.