-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
70 lines (68 loc) · 1.53 KB
/
main.cpp
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
#pragma comment(linker, "/opt:nowin98")
#include <windows.h>
#define IDM_TEST 100
CHAR szClassName[]="window";
LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
HMENU hMenu;
switch (msg){
case WM_SYSCOMMAND:
switch (LOWORD(wParam)){
case IDM_TEST:
MessageBox(hWnd,"テストメニュー",szClassName,0);
break;
default:
return(DefWindowProc(hWnd, msg, wParam, lParam));
}
break;
case WM_CREATE:
hMenu=GetSystemMenu(hWnd,FALSE);
AppendMenu(hMenu,MF_STRING,IDM_TEST,"テストメニュー");
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd,msg,wParam,lParam));
}
return (0L);
}
int WINAPI WinMain(HINSTANCE hinst,HINSTANCE hPreInst,
LPSTR pCmdLine,int nCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASS wndclass;
if(!hPreInst){
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance =hinst;
wndclass.hIcon=NULL;
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szClassName;
if(!RegisterClass(&wndclass))
return FALSE;
}
hWnd=CreateWindow(szClassName,
"タイトル",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hinst,
NULL);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}