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); LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
void minimize(); void minimize();
void restore(); void restore();
void doScreenshot();
void InitNotifyIconData(); void InitNotifyIconData();
int CaptureImage(HWND hWnd, const wchar_t* filename); int CaptureImage(HWND hWnd, const wchar_t* filename);
void getRaspiStorage(LPWSTR out); void getRaspiStorage(LPWSTR out);
@ -110,7 +111,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
ShowWindow(Hwnd, SW_HIDE); ShowWindow(Hwnd, SW_HIDE);
Hmenu = CreatePopupMenu(); 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; break;
@ -146,7 +148,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
if (lParam == WM_LBUTTONUP) if (lParam == WM_LBUTTONUP)
{ {
restore(); doScreenshot();
} }
else if (lParam == WM_RBUTTONDOWN) 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. 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) if (clicked == ID_TRAY_EXIT)
{ {
// quit the application. // quit the application.
@ -175,7 +181,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case WM_HOTKEY_FREEZE: case WM_HOTKEY_FREEZE:
{ {
restore(); doScreenshot();
} }
break; break;
@ -216,6 +222,10 @@ void minimize()
void restore() void restore()
{ {
ShowWindow(Hwnd, SW_SHOW); ShowWindow(Hwnd, SW_SHOW);
}
void doScreenshot()
{
WCHAR path[12]; WCHAR path[12];
getRaspiStorage(path); getRaspiStorage(path);
CaptureImage(Hwnd, L"file.bmp"); CaptureImage(Hwnd, L"file.bmp");

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

@ -3,6 +3,7 @@
#define ICO1 101 #define ICO1 101
#define ID_TRAY_APP_ICON 1001 #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_SYSICON (WM_USER + 1)
#define WM_HOTKEY_FREEZE (WM_USER + 2) #define WM_HOTKEY_FREEZE (WM_USER + 2)

Loading…
Cancel
Save