Read system tray area

xiaoxiao2021-03-06  94

Many of the current software use the system tray area to place the icon, and hide the window. It is usually displayed when clicked on the icon of the tray area, and the method described herein can add animation effect to the purpose of the display of the display of the display.

Preparation 1 Be familiar with an API function DrawanImatedRects, this function can draw a moving window between the two rectangles you specify, an example is the animation effect of the window when maximizing / minimizing, the function prototype is as follows:

Bool WinApi DrawanImatedRects

(

HWND HWND, // window handle

Int idani, // animation effect mark, reserve and can only be 0

Const Rect * Lprcfrom, // Start window rectangle

Const Rect * Lprcto // End window rectangle

);

Preparation 2 Look at the location where the tray area icon is located. We use FindWindow to find the tops of the task strip window, then find the tray area window by listed the sub-window, the class name of the task strip window is "shell_traywnd", the class name of the tray area window is TRAYNOTIFYWND.

Bool Callback FindtrayWnd (HWND HWND, LPARAM LPARAM)

{

Tchar szclassname [256];

GetclassName (HWND, SZClassName, 255);

// Compare the window class name

IF (_TCSCMP (SzclassName, _T ("TRAYNOTIFYWND")) == 0)

{

CRECT * prect = (create *) lparam;

:: getWindowRect (hwnd, prect);

Return True;

}

// When you find a clock window, you can end.

IF (_TCSCMP (SzclassName, _T ("TRAYCLOCKWCLASS") == 0)

{

CRECT * prect = (create *) lparam;

CRECT RectClock;

:: getWindowRect (HWND, RectClock);

Prect-> Right = RectClock.Left;

Return False;

}

Return True;

}

CRECT GETTRAYWNDRECT ()

{

CRECT RECT (0, 0, 0);

/ / Find Tray Window

CWND * PWND = FINDWINDOW (_T ("shell_trayWnd"), NULL);

IF (PWND)

{

/ / Find by listed subsequent window

EnumChildWindows (PWND-> M_HWND, FindtrayWnd, (LPARAM) & Rect);

PWND-> getWindowRect (RECT);

// RECT is a rectangle of the tray area

}

RETURN RECT;

}

The following pseudo code shows how to dynamically display and hide the window.

Rect_tray = find_tray_rect (...)

Rect_from = window.getcurrentRect (...)

RECT_TO = Rect_tray

Call DrawanImatedRects (...)

转载请注明原文地址:https://www.9cbs.com/read-96238.html

New Post(0)