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
|
#include "windows.h"
#define IDM_ABOUT 1
#define IDM_EXIT 2
#define IDM_HELP 3
#define IDM_OPEN 4
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int CALLBACK wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR lpCmdLine, _In_ int iCmdShow)
{
WCHAR szTitle[] = L"Point Repeater Analysis";
WCHAR szAppName[] = L"PointRepeaterAnalysis";
WNDCLASSW wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = (HICON) LoadImageW(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
wc.hCursor = (HCURSOR) LoadImageW(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszMenuName = 0; // no need to define a class menu just yet, a custom menu will be used
wc.lpszClassName = szAppName;
if (!RegisterClassW(&wc))
{
MessageBoxW(NULL, L"Call to RegisterClass failed!", szAppName, NULL);
return 1;
}
// create your custom menu
HMENU hMenu = CreateMenu();
HMENU hMenuPopup = CreateMenu();
// the '&' adds an underscore to the menu item for keyboard access
AppendMenuW(hMenuPopup, MF_STRING, IDM_OPEN, L"&Open");
AppendMenuW(hMenuPopup, MF_STRING, IDM_EXIT, L"E&xit");
AppendMenuW(hMenu, MF_POPUP, (UINT_PTR) hMenuPopup, L"&File"); // the cast is for x86/x64 compatibility
HWND hWnd = CreateWindowW(szAppName, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 700, 400,
NULL, hMenu, // create the app's main window with your custom menu
hInstance, NULL);
if (!hWnd)
{
MessageBoxW(NULL, L"Call to CreateWindow failed!", szAppName, NULL);
return 1;
}
// register the menu with the app
SetMenu(hWnd, hMenu);
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
MSG msg;
// Main message loop:
while (GetMessageW(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return (int) msg.wParam; // the cast is for x86/x64 compatibility
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
// Parse the menu selections:
switch (LOWORD(wParam))
{
case IDM_OPEN:
MessageBeep(0);
return 0;
case IDM_EXIT:
SendMessageW(hWnd, WM_CLOSE, 0, 0);
return 0;
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc;
WCHAR greeting[] = L"Sutton - Point Repeater Analysis";
hdc = BeginPaint(hWnd, &ps);
TextOutW(hdc, 5, 5, greeting, lstrlenW(greeting));
EndPaint(hWnd, &ps);
return 0;
}
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProcW(hWnd, message, wParam, lParam);
}
| |