Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enable ESC key to quit the app

  • Loading branch information...
commit f719c840b4f61f813b1c15d3443dd2f34d8b74ae 1 parent 6fdc784
Isshu Rakusai authored
Showing with 20 additions and 9 deletions.
  1. +20 −9 gyazowin/gyazowin.cpp
View
29 gyazowin/gyazowin.cpp
@@ -129,30 +129,31 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASS wc;
-
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = LayerWndProc;
+ // メインウィンドウ
+ wc.style = 0; // WM_PAINT を送らない
+ wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_GYAZOWIN));
wc.hCursor = LoadCursor(NULL, IDC_CROSS); // + のカーソル
- wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
+ wc.hbrBackground = 0; // 背景も設定しない
wc.lpszMenuName = 0;
- wc.lpszClassName = szWindowClassL;
+ wc.lpszClassName = szWindowClass;
RegisterClass(&wc);
- wc.style = 0; // WM_PAINT を送らない
- wc.lpfnWndProc = WndProc;
+ // レイヤーウィンドウ
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = LayerWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_GYAZOWIN));
wc.hCursor = LoadCursor(NULL, IDC_CROSS); // + のカーソル
- wc.hbrBackground = 0; // 背景も設定しない
+ wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
- wc.lpszClassName = szWindowClass;
+ wc.lpszClassName = szWindowClassL;
return RegisterClass(&wc);
}
@@ -197,6 +198,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
+ // ESCキー検知タイマー
+ SetTimer(hWnd, 1, 100, NULL);
// レイヤーウィンドウの作成
@@ -490,6 +493,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hWnd, message, wParam, lParam);
break;
+ case WM_TIMER:
+ // ESCキー押下の検知
+ if (GetKeyState(VK_ESCAPE) & 0x8000){
+ DestroyWindow(hWnd);
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ break;
+
case WM_MOUSEMOVE:
if (onClip) {
// 新しい座標をセット
Please sign in to comment.
Something went wrong with that request. Please try again.