C ++ Builder master advancement (four) dynamic display taskbar icon

zhaozj2021-02-16  26

C builder master advanced

(4) Dynamic display taskbar icon

nxyc_twz@163.com

At the time of the application, sometimes it is sometimes temporarily lost because of the large amount of data to be processed, so that the feeling of the user is extremely unhappy, affecting the broader application of the software. Using multi-threaded technology can solve this problem, you can use multithreading here, I want to demonstrate how to prepare dynamic taskbar icons. My programming idea is to send a specific message to the specified time interval to make the task bar icon constantly changed by setting the Timer Clock Control to make the taskbar icon to form an animation effect. The implementation method is to drag and drop several image controls in the form of the application, so that they load the corresponding drawings, and several graphs are continuously displayed in order, they form an animation. The application must be used to send a message to notify the taskbar to add, delete, and modify the icon. Send messages must call Shell_Notifyicon. Its original shape is: Winshellapi Boll WinAPI shell_notifyicon; the first parameter dWMessage is a flag that sends a message, you can choose the NIM_ADD / / Task Bar Notification area Add Icon NIM_DELETE // to the taskbar notification area to delete icons NIM_MODIFY // modify notification taskbar notification area icon message preparation function TrayMessagebool __fastcall TForm1 :: TrayMessage (DWORD dwMessage) {NOTIFYICONDATA tnd; PSTR pszTip; pszTip = tipText (); tnd.cbSize = sizeof (NOTIFYICONDATA); // structure Size Tnd.ucallbackMessage = mywm_notify; // Custom callback message, declare Tnd.hwnd = handle; // accepted the window of the callback message in the header file TND.UID = IDC_MYICON; // icon flag number tnd.uflags = nif_message | NIF_ICON | NIF_TIP; // Specify which three parameters include valid data if (dwMessage == nim_modify) {tnd.hicon = (hicon) iconhandle (); // get the icon handle IF (psztip) LSTRCPYN (tnd.sztip, psztip , SIZEOF (TND.SZTIP)); elsetnd.sztip [0] = '/0';}}}}} Return (shell_notifyicon (SHELL_NOTICON (DWMESSAGE, & TND) )));} Component to obtain the function of the icon handle hicon __fastcall tform1 :: iconhandle (void) {if (n == 1) {return (image1-> picture-> icon-> handle); // n is global variable, 1 To display image1,0 is image2} else {return (image2-> picture-> icon-> handle);}}}}}}} The icon status conversion function void __fastcall tform1 :: ToggleState (void) {if (n == 1) // n is the icon handle lock, is a global variable, 1 is display image1, 0 is image2 {n = n-1;} else {n = n 1;} TRAYMESSAGE NIM_MODIFY); // Send Icon Transform Message} to prepare code to the Timer control, set its INTERVAL attribute to 1000, that is, the timer responds once every second.

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

New Post(0)