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
|
#include <Windows.h>
#include "resource.h"
#include <CommCtrl.h>
LRESULT CALLBACK WinProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
INT WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hprevInstance,LPSTR lpCmdLine,int nShowCmd)
{
TCHAR AddCaption[40];
MSG Msg;
HWND HWnd;
WNDCLASSEX WndClsEx;
const int NUMBUTTONS = 3;
HINSTANCE hInst = hInstance;
LPCTSTR ClsName = TEXT("BasicApp");
LPCTSTR WndName = TEXT("Cafeteria Shooting");
LoadString(hInstance,IDS_APP_NAME,AddCaption,40);
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW || CS_VREDRAW;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.lpszClassName = ClsName;
WndClsEx.lpszMenuName = MAKEINTRESOURCE(IDR_MAINFRAME);
WndClsEx.lpfnWndProc = WinProc;
WndClsEx.hCursor = LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CURSOR1));
WndClsEx.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
WndClsEx.hIconSm = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClsEx.hInstance = hInstance;
RegisterClassEx(&WndClsEx);
HWnd = CreateWindowEx(0,ClsName,AddCaption,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
if(!HWnd)
return 0;
INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&InitCtrlEx);
TBBUTTON tbrButtons[3];
tbrButtons[0].iBitmap = 0;
tbrButtons[0].idCommand = IDM_FILE_NEW;
tbrButtons[0].fsState = TBSTATE_ENABLED;
tbrButtons[0].fsStyle = TBSTYLE_BUTTON;
tbrButtons[0].dwData = 0L;
tbrButtons[0].iBitmap = 0;
tbrButtons[0].iString = 0;
tbrButtons[1].iBitmap = 0;
tbrButtons[1].idCommand = IDM_FILE_DICT;
tbrButtons[1].fsState = TBSTATE_ENABLED;
tbrButtons[1].fsStyle = TBSTYLE_BUTTON;
tbrButtons[1].dwData = 0L;
tbrButtons[1].iBitmap = 0;
tbrButtons[1].iString = 0;
tbrButtons[2].iBitmap = 0;
tbrButtons[2].idCommand = IDM_FILE_CALC;
tbrButtons[2].fsState = TBSTATE_ENABLED;
tbrButtons[2].fsStyle = TBSTYLE_BUTTON;
tbrButtons[2].dwData = 0L;
tbrButtons[2].iBitmap = 0;
tbrButtons[2].iString = 0;
HWND HWndToolbar = CreateToolbarEx(HWnd,WS_CHILD || WS_VISIBLE || WS_BORDER,IDB_STANDARD,NUMBUTTONS,hInst,IDB_STANDARD,tbrButtons,NUMBUTTONS,16,16,16,16,sizeof(TBBUTTON));
ShowWindow(HWnd,SW_SHOWNORMAL);
UpdateWindow(HWnd);
while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
|