C # copy QQ pop-up news box

Source: Internet
Author: User

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:

View plaincopy to clipboardprint?
// Introduce the namespace
Using System. Runtime. InteropServices;
// API prototype
[DllImport ("user32.dll")]
Private static extern bool AnimateWindow (IntPtr hwnd, int dateTime, int dwFlags); // hwnd window handle. dateTime: animation duration. dwFlags: animation type combination
// Introduce the namespace
Using System. Runtime. InteropServices;
// API prototype
[DllImport ("user32.dll")]
Private static extern bool AnimateWindow (IntPtr hwnd, int dateTime, int dwFlags); // hwnd window handle. dateTime: animation duration. dwFlags: animation type combination

The following are various animated symbols of dwFlags:

View plaincopy to clipboardprint?
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
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:

View plaincopy to clipboardprint?
Private int currentX; // abscissa
Private int currentY; // y coordinate
Private int screenHeight; // screen height
Private int screenWidth; // screen width
Private int currentX; // abscissa
Private int currentY; // y coordinate
Private int screenHeight; // screen height
Private int screenWidth; // screen width


Execute an animation in the load event:

View plaincopy to clipboardprint?
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 );
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 );

Try it!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.