language: C++ 4.7.2 (gcc-4.7.2)
date: 907 days 19 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
 
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
 
 
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR    lpCmdLine, int       nCmdShow)
{
        MSG msg;
        CWnd    cMainWindow(TEXT("DentoMan"), TEXT("Bejkoman"));
 
        cMainWindow.CreateDef();
        // Main message loop:
        while (GetMessage(&msg, NULL, 0, 0))
        {
                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
        }
        return (int)msg.wParam;
}
 
class CWnd
{
        public:
                                CWnd();
                                CWnd(LPTSTR lpszClassName, LPTSTR lpszWindowName);
                virtual ~CWnd();
                virtual HWND CreateDef(void);                   // Create the window with default parameters
                virtual HWND Create(void);                              // Create window with custom params
                virtual LRESULT         WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam );
 
        private:
                static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
                HWND            g_hWnd;         //Global window handle for this window
                HINSTANCE       hInst;          //Global instance for this window
 
                LPTSTR                  lpszClassName;
                LPTSTR                  lpszWindowName;
 
};
 
 
CWnd::CWnd()
{
 
};
 
CWnd::CWnd(LPTSTR lpszClassName, LPTSTR lpszWindowName)
{
        CWnd::lpszClassName             = lpszClassName;
        CWnd::lpszWindowName    = lpszWindowName;
 
 
};
 
CWnd::~CWnd()
{
 
};
// Create the window with default parameters
HWND CWnd::CreateDef(void)
        {
                WNDCLASSEX wcex;
 
                wcex.cbSize = sizeof(WNDCLASSEX);
 
                wcex.style                      = CS_HREDRAW | CS_VREDRAW;
                wcex.lpfnWndProc        = StaticWndProc;
                wcex.cbClsExtra         = 0;
                wcex.cbWndExtra         = 0;
                wcex.hInstance          = (HINSTANCE)GetModuleHandle(NULL);
                wcex.hIcon                      = 0;
                wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);
                wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW + 4);
                wcex.lpszMenuName       = 0;
                wcex.lpszClassName      = lpszClassName;
                wcex.hIconSm            = 0;
 
                RegisterClassEx(&wcex);
                g_hWnd = CreateWindowEx(0,lpszClassName, lpszWindowName, WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, wcex.hInstance, this);
                hInst   =       wcex.hInstance;
 
            if (!g_hWnd) return false;
 
 
   
           ShowWindow(g_hWnd, SW_SHOW);
           UpdateWindow(g_hWnd);
 
                return g_hWnd;
        }
 
// Create window with custom params
HWND CWnd::Create(void)
        {
                WNDCLASSEX wcex;
 
                wcex.cbSize = sizeof(WNDCLASSEX);
 
                wcex.style                      = CS_HREDRAW | CS_VREDRAW;
                wcex.lpfnWndProc        = StaticWndProc;
                wcex.cbClsExtra         = 0;
                wcex.cbWndExtra         = 0;
                wcex.hInstance          = (HINSTANCE)GetModuleHandle(NULL);
                wcex.hIcon                      = 0;
                wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);
                wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW + 1);
                wcex.lpszMenuName       = 0;
                wcex.lpszClassName      = lpszClassName;
                wcex.hIconSm            = 0;
 
                return g_hWnd;
        }
 
 
 
 
 
 
 
LRESULT CALLBACK CWnd::StaticWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
 
    // If this is a create message, trap the 'this' pointer passed in and store it within the window.
        /*The Only Message we take here so we store the 'this' pointer within the window to identify messages 
        comming from it by the 'this' pointer*/
    if ( Message == WM_CREATE )
        {
                SetWindowLong( hWnd, GWL_USERDATA, (LONG)((CREATESTRUCT FAR *)lParam)->lpCreateParams);
        }
 
    // Obtain the correct destination for this message
        /*Store the window pointer in the class pointer we just created in order to run the right public WndPRoc */
    CWnd *Destination = (CWnd*)GetWindowLong( hWnd, GWL_USERDATA );
    
    // If the hWnd has a related class, pass it through
        /**/
    if (Destination)
        {
                return Destination->WndProc( hWnd, Message, wParam, lParam );
        }
    
    // No destination found, defer to system...
    return DefWindowProc( hWnd, Message, wParam, lParam );
 
 
};
 
LRESULT CWnd::WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
 
 
    // Determine message type
        switch (Message)
    {
                case WM_LBUTTONDOWN:
                        {
                                /*this is a common trick for easy dragging of the window.this message fools windows telling that the user is
                                 actually dragging the application caption bar.*/
                                 SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION,NULL);
                                break;
                        }
                /*case WM_CREATE:
            break;
                */
        case WM_CLOSE:
                        PostQuitMessage(0);
                        break;
                
        case WM_DESTROY:
                        UnregisterClass(lpszClassName, hInst);
                        PostQuitMessage(0);
                        break;
                        
 
 
        case WM_KEYDOWN:                                //KeyBoard keys
 
            // Which key was pressed?
                        switch (wParam) 
            {
                                case VK_ESCAPE:                 //close through escape key
                                        PostQuitMessage(0);
                                        return 0;
                                case VK_RETURN:
                                        MessageBox(hWnd, TEXT("DFGDGD"), TEXT("DFGDFG"), NULL);
                                        return 0;
 
                        } // End Switch
 
                        break;
 
        case WM_COMMAND:
                        /*switch(LOWORD(wParam))
                        {
                                        
            
                        }*/
                        break;
                case WM_PAINT:
                        
                        break;
                default:
                        return DefWindowProc(hWnd, Message, wParam, lParam);
 
    } // End Message Switch
    
 
        return 0;
 
 
};
prog.cpp:2:21: error: windows.h: No such file or directory
prog.cpp:6:19: error: tchar.h: No such file or directory
prog.cpp:9: error: expected initializer before ‘_tWinMain’