隐藏系统托盘图标:如何自动移去系统托盘失效的图标来源: 发布时间:星期四, 2009年2月12日 浏览:126次 评论:0
有些window应用在启动以后会在系统托盘去添加个小图标, 般情况下当正常退出时会自动去掉,但有时由于应用非法关闭,这个图标便直留在托盘区,直到用鼠标移动图标上时,才会自己消失.那么我们就可以模拟鼠标移动到逐个图标上,来达到这个效果. void __fastcall removedeadicons { hwnd htraywindow; rect rcttrayicon; niconwidth; niconheight; tpo cursorpos; nrow; ncol; // get tray window handle and bounding rectangle htraywindow = findwindowex(findwindow( \"shell_traywnd\", null), 0, \"traynotywnd\", null); (!getwindowrect(htraywindow, &rcttrayicon)) ; // get small icon metrics niconwidth = getsystemmetrics(sm_cxsmicon); niconheight = getsystemmetrics(sm_cysmicon); // save current mouse position } getcursorpos(&cursorpos); // sweep the mouse cursor over each icon in the tray in both dimensions for(nrow=0; nrow<(rcttrayicon.bottom-rcttrayicon.top)/niconheight; nrow) { for(ncol=0; ncol<(rcttrayicon.right-rcttrayicon.left)/niconwidth; ncol) { cursorpos(rcttrayicon.left + ncol * niconwidth + 5, rcttrayicon.top + nrow * niconheight + 5); sleep(0); } } // restore mouse position cursorpos(cursorpos.x, cursorpos.x); // redraw tray window (to fix bug in multi-line tray area) redrawwindow(htraywindow, null, 0, rdw_invalidate | rdw_erase | rdw_updatenow); } 0
相关文章读者评论发表评论 |
|