00001
00002
00003
00004 #include "stdafx.h"
00005 #include "Client.h"
00006 #define MAX_LOADSTRING 100
00007
00008
00009 HINSTANCE hInst;
00010 TCHAR szTitle[MAX_LOADSTRING];
00011 TCHAR szWindowClass[MAX_LOADSTRING];
00012
00013
00014 ATOM MyRegisterClass(HINSTANCE hInstance);
00015 BOOL InitInstance(HINSTANCE, int);
00016 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
00017 LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
00018
00019 int APIENTRY _tWinMain(HINSTANCE hInstance,
00020 HINSTANCE hPrevInstance,
00021 LPTSTR lpCmdLine,
00022 int nCmdShow)
00023 {
00024
00025 MSG msg;
00026 HACCEL hAccelTable;
00027
00028
00029 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
00030 LoadString(hInstance, IDC_CLIENT, szWindowClass, MAX_LOADSTRING);
00031 MyRegisterClass(hInstance);
00032
00033
00034 if (!InitInstance (hInstance, nCmdShow))
00035 {
00036 return FALSE;
00037 }
00038
00039 hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_CLIENT);
00040
00041
00042 while (GetMessage(&msg, NULL, 0, 0))
00043 {
00044 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
00045 {
00046 TranslateMessage(&msg);
00047 DispatchMessage(&msg);
00048 }
00049 }
00050
00051 return (int) msg.wParam;
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 ATOM MyRegisterClass(HINSTANCE hInstance)
00070 {
00071 WNDCLASSEX wcex;
00072
00073 wcex.cbSize = sizeof(WNDCLASSEX);
00074
00075 wcex.style = CS_HREDRAW | CS_VREDRAW;
00076 wcex.lpfnWndProc = (WNDPROC)WndProc;
00077 wcex.cbClsExtra = 0;
00078 wcex.cbWndExtra = 0;
00079 wcex.hInstance = hInstance;
00080 wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_CLIENT);
00081 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
00082 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
00083 wcex.lpszMenuName = (LPCTSTR)IDC_CLIENT;
00084 wcex.lpszClassName = szWindowClass;
00085 wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
00086
00087 return RegisterClassEx(&wcex);
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00101 {
00102 HWND hWnd;
00103
00104 hInst = hInstance;
00105
00106 hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
00107 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
00108
00109 if (!hWnd)
00110 {
00111 return FALSE;
00112 }
00113
00114 ShowWindow(hWnd, nCmdShow);
00115 UpdateWindow(hWnd);
00116
00117 return TRUE;
00118 }
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00131 {
00132 int wmId, wmEvent;
00133 PAINTSTRUCT ps;
00134 HDC hdc;
00135
00136 switch (message)
00137 {
00138 case WM_COMMAND:
00139 wmId = LOWORD(wParam);
00140 wmEvent = HIWORD(wParam);
00141
00142 switch (wmId)
00143 {
00144 case IDM_ABOUT:
00145 DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
00146 break;
00147 case IDM_EXIT:
00148 DestroyWindow(hWnd);
00149 break;
00150 default:
00151 return DefWindowProc(hWnd, message, wParam, lParam);
00152 }
00153 break;
00154 case WM_PAINT:
00155 hdc = BeginPaint(hWnd, &ps);
00156
00157 EndPaint(hWnd, &ps);
00158 break;
00159 case WM_DESTROY:
00160 PostQuitMessage(0);
00161 break;
00162 default:
00163 return DefWindowProc(hWnd, message, wParam, lParam);
00164 }
00165 return 0;
00166 }
00167
00168
00169 LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00170 {
00171 switch (message)
00172 {
00173 case WM_INITDIALOG:
00174 return TRUE;
00175
00176 case WM_COMMAND:
00177 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
00178 {
00179 EndDialog(hDlg, LOWORD(wParam));
00180 return TRUE;
00181 }
00182 break;
00183 }
00184 return FALSE;
00185 }