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
|
// Test.cpp : Defines the entry point for the application.
//
#include "windows.h"
#include "commdlg.h"
#define IDM_ABOUT 1
#define IDM_EXIT 2
#define IDM_HELP 3
#define IDM_OPEN 4
WCHAR AppName[] = L"Analysis";
WCHAR AboutTitle[] = L"About Analysis";
WCHAR iconfilename[] = L"analysis.ico";
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
WNDCLASS wndclass;
HMENU hMenu, hMenuPopup;
MSG msg;
HWND hWnd;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = (HICON)LoadImage(NULL,iconfilename,IMAGE_ICON,0,0,LR_LOADFROMFILE|LR_DEFAULTSIZE|LR_SHARED);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclass.lpszMenuName = AppName;
wndclass.lpszClassName = AppName;
if (!RegisterClass(&wndclass))
{
MessageBox(NULL,L"Call to RegisterClass failed!",AppName,NULL);
return(1);
}
hWnd = CreateWindow(AppName, AppName, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT, 700, 400, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
MessageBox(NULL, L"Call to CreateWindow failed!", AppName, NULL);
return(1);
}
hMenu = CreateMenu();
hMenuPopup = CreateMenu();
AppendMenu(hMenuPopup, MF_STRING, IDM_OPEN, L"Open");
AppendMenu(hMenuPopup, MF_STRING, IDM_EXIT, L"Exit");
AppendMenu(hMenu, MF_POPUP, UINT_PTR(hMenuPopup), L"File");
hMenuPopup = CreateMenu();
AppendMenu(hMenuPopup, MF_STRING, IDM_ABOUT, L"About Analysis");
AppendMenu(hMenu, MF_POPUP, UINT_PTR(hMenuPopup), L"Help");
SetMenu(hWnd, hMenu);
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
WCHAR text[80] = { 0 };
switch (message)
{
case WM_COMMAND:
// Parse the menu selections:
switch (LOWORD(wParam))
{
case IDM_OPEN:
return(0);
case IDM_EXIT:
SendMessage(hwnd, WM_CLOSE, 0, 0);
return(0);
case IDM_ABOUT:
wsprintf(text, L"%s\n\u00a92021 Lookout Portable Security\nVersion 1.0", AppName);
MessageBox(hwnd,text,AboutTitle,MB_ICONINFORMATION|MB_OK);
return(0);
}
break;
// case WM_PAINT:
// return(0);
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
| |