📄 taskbar.c
字号:
#include <windows.h>#include <shellapi.h>#include <utility.h>#include <userint.h>#include <ansi_c.h>#include "taskbar.h"static int panelHandle;static NOTIFYICONDATA icon_data;static HWND hwnd;void CVICALLBACK TaskbarStatusAreaCallback (WinMsgWParam wParam, WinMsgLParam lParam, void *callbackData);int main (int argc, char *argv[]){ int registeredWinMsgId; int registeredMsgNumber; HANDLE hIcon; // Remove Taskbar Button SetSystemAttribute(ATTR_TASKBAR_BUTTON_VISIBLE, 0); if (InitCVIRTE (0, argv, 0) == 0) /* Initialize CVI libraries */ return -1; /* out of memory */ SetSleepPolicy(VAL_SLEEP_MORE); // Load CVI panel if ((panelHandle = LoadPanel (0, "taskbar.uir", PANEL)) < 0) return -1; // Load icon image if (!(hIcon = LoadImage( NULL, "cvi.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE ))) { MessagePopup("Error","Could not load image from icon file."); } // Register CVI Callback if ((registeredMsgNumber = RegisterWinMsgCallback (&TaskbarStatusAreaCallback, "CVITaskbarStatusAreaExample", 0, 0, ®isteredWinMsgId, 1))<0) { MessagePopup("Error","Could not register callback."); } // Setup icon information icon_data.cbSize = sizeof(icon_data); icon_data.hIcon = hIcon; icon_data.uID = 0; icon_data.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; icon_data.hWnd = (HWND)GetCVIWindowHandle (); icon_data.uCallbackMessage = registeredMsgNumber; strncpy(icon_data.szTip, "This is a Status Tip for a CVI EXE", 64); // Add icon to Taskbar Status Area Shell_NotifyIcon(NIM_ADD, &icon_data); // Run UIR DisplayPanel (panelHandle); RunUserInterface (); // Remove icon to Taskbar Status Area Shell_NotifyIcon(NIM_DELETE, &icon_data); UnRegisterWinMsgCallback (registeredWinMsgId); return 0;}void CVICALLBACK TaskbarStatusAreaCallback (WinMsgWParam wParam, WinMsgLParam lParam, void *callbackData){ HWND hwnd; int hMenuBar=0; switch(lParam) { case WM_RBUTTONDOWN: hMenuBar=LoadMenuBar (0, "taskbar.uir", MENU); RunPopupMenu (hMenuBar, MENU_MENU1, panelHandle, 760, 560, 0, 0, 0, 0); //GetPanelAttribute (panelHandle, ATTR_SYSTEM_WINDOW_HANDLE, &hwnd); //PostMessage (hwnd,WM_NULL, 0, 0); DiscardMenuBar(hMenuBar); break; }}int CVICALLBACK Quit (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){ switch (event) { case EVENT_COMMIT: QuitUserInterface (0); break; } return 0;}void CVICALLBACK Help (int menuBar, int menuItem, void *callbackData, int panel){ MessagePopup("Help","This is NotifyIcon");}void CVICALLBACK Quit1 (int menuBar, int menuItem, void *callbackData, int panel){ QuitUserInterface (0); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -