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
|
#include "config.h"
#if _run_app == _sub_menu
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void AddMenus(HWND);
#define IDM_FILE_NEW 1
#define IDM_FILE_IMPORT 2
#define IDM_IMPORT_MAIL 11
#define IDM_ASSET 20
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR lpCmdLine, int nCmdShow) {
MSG msg;
WNDCLASSW wc = { 0 };
wc.lpszClassName = L"Submenu";
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClassW(&wc);
CreateWindowW(wc.lpszClassName, L"The Incredible Asura",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 350, 250, 0, 0, hInstance, 0);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
::Sleep(1);
}
return (int)msg.wParam;
}
HDC hdc;
HGLRC glc;
static PAINTSTRUCT ps;
HBRUSH hBrush;
HBRUSH hOldBrush;
HPEN hPen;
HPEN hOldPen;
PIXELFORMATDESCRIPTOR pfd;
int pf;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE:
AddMenus(hwnd);
hdc = GetDC(hwnd);
glc = wglCreateContext(hdc);
memset(&pfd, 0, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pf = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, pf, &pfd);
DescribePixelFormat(hdc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
ReleaseDC(hwnd, hdc);
glc = wglCreateContext(hdc);
wglMakeCurrent(hdc, glc);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDM_FILE_NEW:
MessageBoxW(NULL, L"New file selected",
L"Information", MB_OK);
break;
case IDM_IMPORT_MAIL:
MessageBoxW(NULL, L"Import mail selected",
L"Information", MB_OK);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_PAINT:
//hdc = BeginPaint(hwnd, &ps);
//hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
//hOldPen = (HPEN)SelectObject(hdc, hPen);
//hBrush = CreateSolidBrush(RGB(0, 0, 255));
//hOldBrush = (HBRUSH)SelectObject(hdc, hBrush);
//Rectangle(hdc, 100, 100, 200, 170);
//EndPaint(hwnd, &ps);
hdc = GetDC(hwnd);
glc = wglCreateContext(hdc);
wglMakeCurrent(hdc, glc);
glClearColor(0.16, 0.16, 0.16, 1);
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(0.219, 0.219, 0.219, 1);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f); //ƾ
glFlush(); //ִOpenGLָбеָ
wglMakeCurrent(NULL, NULL);
BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps);
break;
}
return DefWindowProcW(hwnd, msg, wParam, lParam);
}
void AddMenus(HWND hwnd) {
HMENU hMenubar = CreateMenu();
HMENU hMenu = CreateMenu();
HMENU hSubMenu = CreatePopupMenu();
HMENU asserMenu = CreateMenu();
AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW, L"&New");
AppendMenuW(asserMenu, MF_STRING, IDM_ASSET, L"Import &mail &assets");
AppendMenuW(hSubMenu, MF_STRING | MF_POPUP, (UINT_PTR)asserMenu, L"Import &mail");
AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, L"&Import");
AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hMenu, L"&File");
SetMenu(hwnd, hMenubar);
}
#endif // _run_app == _sub_menu
|