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
|
//Main.cpp
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include <windows.h>
#define BTN_START 1500
#define BTN_STOP 1505
LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HINSTANCE hIns=((LPCREATESTRUCT)lParam)->hInstance;
CreateWindowEx(0,L"button",L"Start",WS_CHILD|WS_VISIBLE,125,40,80,30,hwnd,(HMENU)BTN_START,hIns,0);
CreateWindowEx(0,L"button",L"Stop",WS_CHILD,125,80,80,30,hwnd,(HMENU)BTN_STOP,hIns,0);
return 0;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case BTN_START:
ShowWindow(GetDlgItem(hwnd,BTN_STOP),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,BTN_START),SW_HIDE);
break;
case BTN_STOP:
MessageBox(hwnd,L"You Clicked The Stop Button!",L"Report",MB_OK);
break;
}
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
TCHAR szClassName[]=L"PowerfulProcessing";
WNDCLASSEX wc={0};
MSG messages;
HWND hWnd;
wc.lpszClassName = szClassName;
wc.lpfnWndProc = fnWndProc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
wc.hInstance = hInstance;
RegisterClassEx(&wc);
hWnd=CreateWindowEx(0,szClassName,L"Some Big Powerful Processing App",WS_OVERLAPPEDWINDOW,150,150,350,250,HWND_DESKTOP,0,hInstance,0);
ShowWindow(hWnd,iShow);
while(GetMessage(&messages,NULL,0,0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
|