When you open QQ, the pop-up form of QQ news will slowly rise up a small window in the lower right corner of the screen, occupying a small space, which can serve as a prompt. Next let's take a look at how to use system APIs to easily implement this function.
API prototype functions:
Bool animatewindow (intptr hwnd, int dwtime, int dwflags );
Literally, this function is called "Window of activity". In fact, this function can enrich the form actions, to use winapi in C #, first introduce the namespace:
- // Introduce the namespace
- UsingSystem. runtime. interopservices;
- // API prototype
- [Dllimport ("user32.dll")]
- Private Static Extern BoolAnimatewindow (intptr hwnd,IntDatetime,IntDwflags); // hwnd window handle. datetime: animation duration. dwflags: Combination of animation types
The following are various animated symbols of dwflags:
Int aw_active = 0x20000; // activation window. Do not use this flag after the aw_hide flag is used.
Int aw_hide = 0x10000; // hide the window
Int aw_blend = 0x80000; // fade in and out
Int aw_slide = 0x40000; // use the sliding animation effect. The default value is the scroll animation type. When the aw_center flag is used, this flag is ignored.
Int aw_center = 0x0010; // If the aw_hide flag is used, the window overlaps inward; otherwise, the window expands outward.
Int aw_hor_positive = 0x0001; // display the window from left to right. This flag can be used in rolling and sliding animations. Ignore this flag when using the aw_center flag
Int aw_hor_negative = 0x0002; // a window is displayed from the right to the left. This flag can be used in rolling and sliding animations. Ignore this flag when using the aw_center flag
Int aw_ver_positive = 0x0004; // display the window from top to bottom. This flag can be used in rolling and sliding animations. Ignore this flag when using the aw_center flag
Int aw_ver_negative = 0x0008; // display the window from bottom to top. This flag can be used in rolling and sliding animations. Ignore this flag when using the aw_center flag
Declare variables to save the coordinates displayed in the form:
- Private IntCurrentx; // abscissa
- Private IntCurrenty; // ordinate
- Private IntScreenheight; // screen height
- Private IntScreenwidth; // screen width
Execute an animation in the load event:
Rectangle rect = screen. primaryscreen. workingarea;
Screenheight = rect. height;
Screenwidth = rect. width;
Currentx = screenwidth-This. width;
Currenty = screenheight-This. height;
This. Location = new system. Drawing. Point (currentx, currenty );
Animatewindow (this. Handle, 1000, aw_slide | aw_ver_negative );
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/PaulEAfly/archive/2010/01/14/5188830.aspx