root/lang/cplusplus/SleipnirGoogleSuggest/CompletionWindow.h

Revision 14174, 2.0 kB (checked in by saturday06, 7 months ago)

アカウントもらった記念に今作ってるものを全部うp

Line 
1#pragma once
2
3#include <mol/windows/WindowProcedureRedirector.h>
4
5namespace SleipnirGoogleSuggest {
6
7class CompletionWindow {
8    mol::WindowProcedureRedirector<CompletionWindow> windowProcedureRedirector;
9    HWND hWnd;
10public:
11    CompletionWindow() : hWnd(NULL), windowProcedureRedirector(*this) {
12        HINSTANCE hInstance = GetModuleHandle(NULL);
13        const TCHAR ClassName[] = _T("hogehagehige");
14        int nCmdShow = SW_SHOW;
15
16        WNDCLASSEX wc;
17        wc.cbSize        = sizeof(WNDCLASSEX);
18        wc.style         = CS_HREDRAW | CS_VREDRAW | WS_OVERLAPPED;
19        wc.lpfnWndProc   = DefWindowProc;
20        wc.cbClsExtra    = 0;
21        wc.cbWndExtra    = 0;
22        wc.hInstance     = hInstance;
23        wc.hIcon         = NULL;//LoadIcon(hCrtInst, MAKEINTRESOURCE(IDI_ICON1));
24        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
25        wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
26        wc.lpszMenuName  = NULL;
27        wc.lpszClassName = ClassName;
28        wc.hIconSm       = NULL;
29
30        assert(RegisterClassEx(&wc));
31
32        hWnd = CreateWindowEx(
33            0,                          //
34            ClassName,                  //
35            _T(""),                     //
36            WS_OVERLAPPEDWINDOW,        //
37            CW_USEDEFAULT,              //
38            CW_USEDEFAULT,              //
39            200,                        //
40            50,                         //
41            NULL,                       //
42            NULL,                       //
43            hInstance,                  //
44            NULL                        //
45            );
46
47        assert(IsWindow(hWnd));
48
49        windowProcedureRedirector.set(hWnd);
50        ShowWindow(hWnd, nCmdShow);
51        UpdateWindow(hWnd);
52    }
53
54    LRESULT WindowProcedure(UINT msg, WPARAM wParam, LPARAM lParam) {
55        if (msg == WM_DESTROY) {
56            PostQuitMessage(0);
57        }
58        return DefWindowProc(hWnd, msg, wParam, lParam);
59    }
60};
61
62}
Note: See TracBrowser for help on using the browser.