Hi all, (See http://lazarus.freepascal.org/index.php/topic,14847.msg79038.html#msg79038 for initial question)
My program starts and stops external programs that have icons. It would be nice to immediately clean up the icons from the system tray once those programs have stopped. I've found this code: http://www.computersecurityarticles.info/security/refreshing-the-taskbar-notification-area/ #define FW(x,y) FindWindowEx(x, NULL, y, L”") void RefreshTaskbarNotificationArea() { HWND hNotificationArea; RECT r; GetClientRect( hNotificationArea = FindWindowEx( FW(FW(FW(NULL, L”Shell_TrayWnd”), L”TrayNotifyWnd”), L”SysPager”), NULL, L”ToolbarWindow32″, L”Notification Area”), &r); for (LONG x = 0; x < r.right; x += 5) for (LONG y = 0; y < r.bottom; y += 5) SendMessage( hNotificationArea, WM_MOUSEMOVE, 0, (y << 16) + x); } and got as far as: uses JwaTlHelp32 {for running processes}, JwaWinType {for processes declarations}, JwaWinBase {just a guess: for closing process handles}, JwaWinSvc {for services declarations, always required}, jwawinuser {for clearing tray icon/notification area}, ... some more... procedure CleanSystemTray; {description Clean dead icons from system tray/notification area} var hNotificationArea: HWND; r: RECT; x: integer; y: integer; begin hNotificationArea:=FindWindowEx( FindWindowEx(FindWindowEx(FindWindowEx (nil,nil,'Shell_TrayWnd', ''),nil,'TrayNotifyWnd', ''),nil,'SysPager',''), nil, 'ToolbarWindow32', 'Notification Area'); GetClientRect(hNotificationArea,r); //Now we've got the area, force it to update //by sending mouse messages to it. x:=0; y:=0; while x < r.Right do begin while y < r.Bottom do begin SendMessage(hNotificationArea, WM_MOUSEMOVE, 0, (y shl 16) + x); y:=y+5; end; x:=x+5; end; end; However compiler errors on the 2nd nil: (nil,nil,'Shell_TrayWnd', ''),nil,'TrayNotifyWnd', Error: Incompatible type for arg no. 2: Got "Pointer", expected "LongWord" Should I just pass 0 to those functions or bogus HWNDs... or do something else? (If you haven't figured it out by now, I understand C++ even less than Pascal ;) Finally, perhaps there is an easier way of cleaning up the tray icon? _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal