Skip to content

Commit

Permalink
Enable ESC key to quit the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Isshu Rakusai committed Nov 2, 2009
1 parent 6fdc784 commit f719c84
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions gyazowin/gyazowin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -197,6 +198,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);

// ESCキー検知タイマー
SetTimer(hWnd, 1, 100, NULL);


// レイヤーウィンドウの作成
Expand Down Expand Up @@ -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) {
// 新しい座標をセット
Expand Down

0 comments on commit f719c84

Please sign in to comment.