I don't want to let my own procedure, like Rising or Jinshan's word, after starting, leave an icon in the tray, to indicate that the program is running in the background, if you need, and you still don't know how to get started, please step by step Step step by step !
First, first add the following statement in the * .h file: #include
PUBLIC: TICON * Myicon; Void Virtual __fastcall iconclick (tMessage & MSG);
Begin_MESSAGE_MAP Message_Handler (WM_USER 100, TMESSAGE, ICONCLICK) END_MESSAGE_MAP (TFORM1)
Second, add the following code in * .cpp file: The following code is added to the constructor: myicon = new ticon (); tNotifyicondata iconData; myicon-> loadFromfile ("c: /data/icon.ico"); // ico icon position IconData.cbSize = Sizeof (IconData); IconData.hwnd = Handle; IconData.uID = 100; IconData.hIcon = myIcon-> Handle; IconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; IconData.uCallbackMessage = WM_USER 100; strcpy (ICondata.sztip, "My Program"); Shell_Notifyicon (Nim_ADD, & ICONDATA); // Increasing Tray Icon SetWindowlong (Application-> Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); // Hide Task Bar Icon
Destructor: TNotifyicondata IconData; iconData.cbsize = sizeof (icondata); icondata.hwnd = handle; icondata.uid = 100; shell_notifyicon (nim_delete, & icondata); // Delete tray icon delete myicon;
Click event: void __fastcall tform1 :: iconclick (tMessage & msg) {TPOINT PO; if (msg.lparam == wm_lbuttondtonDblclk) / / Perform your left button Double-click Event IF (msg.lparam == WM_RBUTTONDOWN) /// Right-click pop up menu {getCursorpos (& PO); popupmenu1-> popup (dep. X, asy);}
The following block is debugged in Win200 / XP C Bulider6.0!