Browse Source

tray icon behaviour

main
Hendrik Langer 6 years ago
parent
commit
50ad10f2c4
  1. 16
      windows-snapshot-tool/src/main.cpp
  2. 3
      windows-snapshot-tool/src/resource.h

16
windows-snapshot-tool/src/main.cpp

@ -14,6 +14,7 @@ const wchar_t* szClassName = L"IUL Snapshot Tool.";
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
void minimize();
void restore();
void doScreenshot();
void InitNotifyIconData();
int CaptureImage(HWND hWnd, const wchar_t* filename);
void getRaspiStorage(LPWSTR out);
@ -110,7 +111,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
ShowWindow(Hwnd, SW_HIDE);
Hmenu = CreatePopupMenu();
AppendMenu(Hmenu, MF_STRING, ID_TRAY_EXIT, TEXT( "Exit The Demo" ) );
AppendMenu(Hmenu, MF_STRING, ID_TRAY_OPEN, TEXT( "Open" ) );
AppendMenu(Hmenu, MF_STRING, ID_TRAY_EXIT, TEXT( "Exit" ) );
break;
@ -146,7 +148,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
if (lParam == WM_LBUTTONUP)
{
restore();
doScreenshot();
}
else if (lParam == WM_RBUTTONDOWN)
{
@ -162,6 +164,10 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
SendMessage(hwnd, WM_NULL, 0, 0); // send benign message to window to make sure the menu goes away.
if (clicked == ID_TRAY_OPEN)
{
restore();
}
if (clicked == ID_TRAY_EXIT)
{
// quit the application.
@ -175,7 +181,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case WM_HOTKEY_FREEZE:
{
restore();
doScreenshot();
}
break;
@ -216,6 +222,10 @@ void minimize()
void restore()
{
ShowWindow(Hwnd, SW_SHOW);
}
void doScreenshot()
{
WCHAR path[12];
getRaspiStorage(path);
CaptureImage(Hwnd, L"file.bmp");

3
windows-snapshot-tool/src/resource.h

@ -3,6 +3,7 @@
#define ICO1 101
#define ID_TRAY_APP_ICON 1001
#define ID_TRAY_EXIT 1002
#define ID_TRAY_OPEN 1002
#define ID_TRAY_EXIT 1003
#define WM_SYSICON (WM_USER + 1)
#define WM_HOTKEY_FREEZE (WM_USER + 2)

Loading…
Cancel
Save