zoukankan      html  css  js  c++  java
  • C++刷新托盘程序图标

    C++刷新托盘程序图标

    托盘程序在非正常被关闭的情况下,就会出现托盘图标不消失的情况,需要鼠标移到上面才会消失。这里就模拟鼠标事件来处理。但是对于缩到托盘里面的图标则没有办法刷新,待找...

    #include <windows.h>
    #include <iostream>
    
    int main() {
    	HWND shell_tray_wnd_handle = FindWindow(L"Shell_TrayWnd", NULL);
    	HWND tray_notify_wnd_handle = FindWindowEx(shell_tray_wnd_handle, 0, L"TrayNotifyWnd", NULL);
    	HWND sys_paper_handle = FindWindowEx(tray_notify_wnd_handle, 0, L"SysPager", NULL);
    
    	HWND tool_bar_handle = NULL;
    	if (sys_paper_handle != NULL) {
    		tool_bar_handle = FindWindowEx(sys_paper_handle, 0, L"ToolbarWindow32", NULL);
    	}
    	else {
    		tool_bar_handle = FindWindowEx(tray_notify_wnd_handle, 0, L"ToolbarWindow32", NULL);
    	}
    
    	if (tool_bar_handle == NULL) {
    		return 0;
    	}
    
    	RECT rect;
    	GetWindowRect(tool_bar_handle, &rect);
    	int width = rect.right - rect.left;
    	int height = rect.bottom - rect.top;
    
    	for (int x = 1; x < width; x += 2) {
    		for (int y = 1; y < height; y += 2) {
    			SendMessage(tool_bar_handle, WM_MOUSEMOVE, 0, MAKELPARAM(x, y));
    		}
    	}
    
    	return 0;
    }
    
  • 相关阅读:
    周二
    周末
    简单I/O
    格式输出(1)
    c语言—变量
    水仙花数
    控制语句—循环语句
    mysql6数据库安装与配置
    如何解决Tomcat端口号被占用
    eclipse配置tomcat详细步骤
  • 原文地址:https://www.cnblogs.com/zzr-stdio/p/14304658.html
Copyright © 2011-2022 走看看