2024年4月1日发(作者:)
自动弹出窗口代码(Auto popup window code)
Guided reading:
Since the Microsoft Corp launched Windows 95 operating system,
system tray applications as an attractive user interface design,
by the vast number of users. Windows applications that use the
system tray as a user interface are numerous, such as PowerWord,
Winamp, RealPlayer, and so forth.
Do not display these running Windows running, only display an
icon on the taskbar, said the program is running, the user can
interact with the mouse application developers sometimes need
to prepare just in a similar program running in the background,
in order to run the interface does not interfere in front of
the program and display the unnecessary window. The main window
is not visible when the program is running. At the same time,
an icon is displayed in the static notification area in the
right side of the taskbar and responds to the user's mouse
action. The design method of this example introduces Visual C++
development for this type of program, after compiling the
program to run, if you double-click the tray icon, the program
will be a message list window pops up, as long as the mouse moves
over the tray icon or click (both right and left key click or
double-click), produced by the message will be displayed in the
window; when the mouse cursor moves to the tray icon, will
display a message on the icon near; right-click pop-up context
menu, open the property page should contain commands or other
open windows and the icon associated with the menu command, in
addition, the program can also change the tray dynamic icon.
With this example, it is believed that readers can easily and
easily use the system tray in their programs.
First, the realization method
In order to realize the tray procedures, the main window first
to make the program is not visible, this realization is very
easy, as long as the call ShowWindow (SW_HIDE) can be, the
examples of the use of this method, there is a way to hide the
main frame by setting a main frame window style and extended
style:
BOOL CMainFrame:: PreCreateWindow (CREATESTRUCT&, CS)
{
=WS_POPUP; / / the main window is not visible;
yle =WS_EX_TOOLWINDOW; / / does not display the task
button;
Return CFrameWnd:: PreCreateWindow (CS);
}
To display icons on the taskbar, use the system API function
Shell_NotifyIcon () to display an icon in the notification area
of the taskbar. The prototype of this function is:
BOOL Shell_NotifyIcon (DWORD, dwMessage, PNOTIFYICONDATA,
pnid);
The first parameter of this function, dwMessage, is DWORD,


发布评论