You can use this to create a message window similar to MSN and QQ.
Void caboutdlg: onok () <br/> {<br/> // todo: add extra validation here <br/> animatewindow (getsafehwnd (), 1000, aw_hide | aw_blend); <br/> cdialog: onok (); <br/>}
Function details:
Bool animatewindow <br/> (<br/> hwnd, <br/> DWORD dwtime, <br/> DWORD dwflags <br/>); <br/>
Hwnd: Specifies the handle for generating the animation window;
Dwtime: Specifies the animation duration (in microseconds). The standard time for completing an animation is 200 microseconds;
Dwfags: Specifies the animation type. This parameter can be a combination of one or more labels.
Dwflags:
Aw_slide: Use the slide type. The default value is the scroll type. The aw_center flag is ignored;
Aw_activate: Activation window. This flag cannot be used after the aw_hide flag is used;
Aw_blend: fades out. This flag can be used only when hwnd is a top-level window;
Aw_hide: hides the window. The window is displayed by default;
Aw_center: If the aw_hide flag is used, the window overlaps inwards, that is, the window is shrunk. If the aw_hide flag is not used, the window is extended, that is, the window is expanded;
Aw_hor_positive: the window is displayed from left to right. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the flag is ignored;
Aw_ver_positive: the window is displayed from top to bottom. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the flag is ignored;
Aw_ver_negative: the window is displayed from bottom to top. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the flag is ignored;
Return Value: If the function succeeds, the return value is non-zero. If the function fails, the return value is zero.
If:
1. Windows use window boundaries;
2. The window is visible and still needs to be displayed;
3. The window is hidden and you still need to hide it.
The function fails.
The following error may occur (due to a Windows Version problem ):
Error c2065: 'animatewindow': Undeclared identifier <br/> error c2065: 'aw _ hide ': Undeclared identifier <br/> error c2065: 'aw _ blend ': undeclared identifier <br/>
Why? The problem lies in the header file winuser that defines the animatewindow function. h, enter the include sub-directory under the VC installation directory, and use Edit to open winuser. h file. Press the F3 key to find the animatewindow. You can find two definitions: one is to define the parameters used in the function, and the other is the definition of the function prototype. Both definitions show the condition judgment for the Windows version:
# If (winver >=0x0500) <br/>/** // * <br/> * animatewindow () commands <br/> */</P> <p> # If (winver> = 0x0500) <br/> winuserapi <br/> bool <br/> winapi <br/> animatewindow (<br/> hwnd, <br/> DWORD dwtime, <br/> DWORD dwflags); <br/> # endif/* winver> = 0x0500 */
It turns out that the main Windows versions we currently use are below. Therefore, when compiling the above program in VC, the compilation system will naturally exclude the animatewindow function. Therefore, to use this function in our program, we have to make some small modifications to its header file, that is, # If (winver> = 0x500) change to # If (winver> = 0x400). Note that you must modify the definition of the function in both cases.
If you do not want to modify winuser. H, you can add the following definition to the front of stdafx. h file in the project:
# UNDEF winver <br/> # define winver 0x500 <br/>