Using VC MSN, QQ message prompt window has known QQ and MSN chat tools, as long as friends go online, it will display a prompt window at the position of the tray, so as to pull the curtain, or fade out The formal appears; think about it does not add a beautiful prompt window for your own program?
First, MSN pull-up window production
Section 3: 1. Display of the window; 2, the window of the window; 3, the disappearance of the window; if you reach this, there are three timers in the system to perform separately. The defined timer is as follows:
#define id_timer_pop_window 1 # define id_timer_dispaly_delay 2 #define id_timer_close_window 3
Inheriting a window from CWND, of course, can also derive from CFrameWnd, this is not the main problem, the key is to see how you deal with WM_Paint, WM_MOUSEMOVE, WM_TIMER message. In general, I will display pictures from OnPaint (), handle timer messages in WM_TIMER, the following is the code used in the timer:
CMSGWnd :: CMSGWnd () {... settimer (id_tiemr_pop_window, 20, null); ...}
void CMsgWnd :: OnTimer (UINT nIDEvent) {static int nHeight = 0; int cy = GetSystemMetrics (SM_CYSCREEN); int cx = GetSystemMetrics (SM_CXSCREEN); RECT rect; SystemParametersInfo (SPI_GETWORKAREA, 0, & rect, 0); int y = rect .bottom-Rect.top; int x = Rect.right-Rect.Left; x = x-win_width;
switch (nIDEvent) {case ID_TIMER_POP_WINDOW: if (nHeight <= WIN_HEIGHT) { nHeight; MoveWindow (x, y-nHeight, WIN_WIDTH, WIN_HEIGHT); Invalidate (FALSE);} else {KillTimer (ID_TIMER_POP_WINDOW); SetTimer (ID_TIMER_DISPLAY_DELAY, 5000, NULL);} break; case ID_TIMER_CLOSE_WINDOW: if (nHeight> = 0) {nHeight--; MoveWindow (x, y-nHeight, WIN_WIDTH, nHeight);} else {KillTimer (ID_TIMER_CLOSE_WINDOW); SendMessage (WM_CLOSE);} Break; case id_timer_display_delay: killtimer; settimer (id_timer_close_window, 20, null); Break;} CWnd :: Ontimer (nidevent);
Control the display process of the window according to the length of the timer you set; Second, QQ fade off and display realizes
Actually, an API function: AnimateWindow, below is some instructions for this function:
Bool AnimateWindow (HWND HWND, // Handle to the Window To Animation DWORD DWFLAGS // Animation Type); The top two parameters before the above functions understand, no need to say, the last parameter DWFlags Set the style of the animation window:
Various markers Description:
Flag Description AW_SLIDE Uses slide animation. By default, roll animation is used. This flag is ignored when used with the AW_CENTER flag. AW_ACTIVATE Activates the window. Do not use this flag with AW_HIDE. AW_BLEND Uses a fade effect. This flag can be used only if hwnd is a top-level window. AW_HIDE Hides the window. By default, the window is shown. AW_CENTER Makes the window appear to collapse inward if the AW_HIDE flag is used or expand outward if the AW_HIDE flag is not used. AW_HOR_POSITIVE Animate the window from left to right. This flag can be used with roll or slide animation. It is ignored when used with the AW_CENTER flag. AW_HOR_NEGATIVE Animate the window from right to left. This flag can be used with roll or slide animation. It is ignored when used with the AW_CENTER flag. AW_VER_POSITIVE Animate the window from top to bottom. This flag can be used with roll or slide animation.It is ignored when used with the AW_CENTER flag. AW_VER_NEGATIVE Animate the window from bottom to Top. This flag can be used with roll or slide animation.it is ignored by used with the aw_center flag.
The above is extracted from the MSDN, and the effect of fade into the fade out, uses AW_BELND.
Third, the code displayed by the control window
CMAINFRAME :: OnCreate (...) {// ... Animatewindow (getsafehwnd (), 1000, aw_center | aw_blend; // ...}
Fourth, close code
CMAINFRAME :: OnClose (.) {AnimateWindow (getsafehwnd (), 1000, aw_hide | aw_center | aw_blend;
In fact, AnimateWindow just uses the WINDOWS itself. If you want more personal window effect, then do more to write some code, one point hard, one point gains
Five, conclude
In fact, on the MSN's prompt window, if you want to use a complicated background and effect, then there is a problem of refreshing the screen, you should do no flash. Due to time, there is inevitable, at the same time, the above code Also refer to a part of the previous VCKBASE technical documentation, thank you! If there is a problem, welcome to exchange! Common progress!