zoukankan      html  css  js  c++  java
  • TaskIcon 系统任务栏图标

    编辑器加载中...

    #include <Shellapi.h> // for task icon

    #pragma comment (lib, "Shell32.lib")

    #define WM_TRAYICON WM_USER + 1
    #define ICON_ID 1


    BOOL
    TrayIcon (HWND hwnd, HICON hIcon, DWORD dwMsg)
    {
    NOTIFYICONDATA nid = {0};
    nid.cbSize = sizeof (NOTIFYICONDATA);
    nid.hWnd = hwnd;
    nid.uID = ICON_ID;
    nid.uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE;
    nid.uCallbackMessage = WM_TRAYICON;
    nid.hIcon = hIcon;

    lstrcpy (nid.szTip, "CloneHv -v1\nA software simulating LPR");
    return Shell_NotifyIcon (dwMsg, &nid);
    }


    void
    OnTrayIcon (UINT uIconId, UINT uMsg)
    {
    if (uIconId == ICON_ID) {
    if (uMsg == WM_LBUTTONUP) {
    ShowWindow (g_hwndDlg, SW_SHOWNORMAL);
    SetForegroundWindow (g_hwndDlg);
    }
    }
    }


    void
    OnSize (WPARAM wFlag, WORD wWidth, WORD wHeight)
    {
    if (wFlag == SIZE_MINIMIZED) {
    ShowWindow (g_hwndDlg, SW_HIDE);
    }
    }


    HWND g_hwndDlg = NULL;
    HICON g_hIcon = NULL;

    WM_INITDIALOG:
    hwndDlg = hwndDlg;
    g_hIcon = ::LoadIcon (g_hInst, MAKEINTRESOURCE (IDI_ICON1));
    TrayIcon (hwnd, g_hIcon, NIM_ADD);

    WM_SIZE:
    case WM_SIZE:
    OnSize (wParam, LOWORD (lParam), HIWORD (wParam));

    WM_CLOSE:
    TrayIcon (g_hwndDlg, g_hIcon, NIM_DELETE);
    DestroyIcon (g_hIcon);
    return TRUE;
  • 相关阅读:
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
    ajax 几种提交方式
  • 原文地址:https://www.cnblogs.com/lin1270/p/2359409.html
Copyright © 2011-2022 走看看