PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/compiler/ucos-vs2008/ftklua_run/ftklua_run.cpp

http://ftk.googlecode.com/
C++ | 192 lines | 121 code | 27 blank | 44 comment | 11 complexity | a7e802161bca89131a6fed8fefe92216 MD5 | raw file
  1// ftklua_run.cpp : ???????????
  2//
  3
  4#include "stdafx.h"

  5#include "ftklua_run.h"

  6#if 0
  7#define MAX_LOADSTRING 100
  8
  9// ????:
 10HINSTANCE hInst;								// ????
 11TCHAR szTitle[MAX_LOADSTRING];					// ?????
 12TCHAR szWindowClass[MAX_LOADSTRING];			// ?????
 13
 14// ????????????????:
 15ATOM				MyRegisterClass(HINSTANCE hInstance);
 16BOOL				InitInstance(HINSTANCE, int);
 17LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
 18INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);
 19
 20int APIENTRY _tWinMain(HINSTANCE hInstance,
 21                     HINSTANCE hPrevInstance,
 22                     LPTSTR    lpCmdLine,
 23                     int       nCmdShow)
 24{
 25	UNREFERENCED_PARAMETER(hPrevInstance);
 26	UNREFERENCED_PARAMETER(lpCmdLine);
 27
 28 	// TODO: ???????
 29	MSG msg;
 30	HACCEL hAccelTable;
 31
 32	// ????????
 33	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
 34	LoadString(hInstance, IDC_FTKLUA_RUN, szWindowClass, MAX_LOADSTRING);
 35	MyRegisterClass(hInstance);
 36
 37	// ?????????:
 38	if (!InitInstance (hInstance, nCmdShow))
 39	{
 40		return FALSE;
 41	}
 42
 43	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_FTKLUA_RUN));
 44
 45	// ?????:
 46	while (GetMessage(&msg, NULL, 0, 0))
 47	{
 48		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
 49		{
 50			TranslateMessage(&msg);
 51			DispatchMessage(&msg);
 52		}
 53	}
 54
 55	return (int) msg.wParam;
 56}
 57
 58
 59
 60//
 61//  ??: MyRegisterClass()
 62//
 63//  ??: ??????
 64//
 65//  ??:
 66//
 67//    ????
 68//    ??????? Windows 95 ??“RegisterClassEx”
 69//    ????? Win32 ???????????????????????????
 70//    ??????????????
 71//    “?????”????
 72//
 73ATOM MyRegisterClass(HINSTANCE hInstance)
 74{
 75	WNDCLASSEX wcex;
 76
 77	wcex.cbSize = sizeof(WNDCLASSEX);
 78
 79	wcex.style			= CS_HREDRAW | CS_VREDRAW;
 80	wcex.lpfnWndProc	= WndProc;
 81	wcex.cbClsExtra		= 0;
 82	wcex.cbWndExtra		= 0;
 83	wcex.hInstance		= hInstance;
 84	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FTKLUA_RUN));
 85	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
 86	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
 87	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_FTKLUA_RUN);
 88	wcex.lpszClassName	= szWindowClass;
 89	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
 90
 91	return RegisterClassEx(&wcex);
 92}
 93
 94//
 95//   ??: InitInstance(HINSTANCE, int)
 96//
 97//   ??: ????????????
 98//
 99//   ??:
100//
101//        ?????????????????????
102//        ???????????
103//
104BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
105{
106   HWND hWnd;
107
108   hInst = hInstance; // ?????????????
109
110   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
111      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
112
113   if (!hWnd)
114   {
115      return FALSE;
116   }
117
118   ShowWindow(hWnd, nCmdShow);
119   UpdateWindow(hWnd);
120
121   return TRUE;
122}
123
124//
125//  ??: WndProc(HWND, UINT, WPARAM, LPARAM)
126//
127//  ??: ?????????
128//
129//  WM_COMMAND	- ????????
130//  WM_PAINT	- ?????
131//  WM_DESTROY	- ?????????
132//
133//
134LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
135{
136	int wmId, wmEvent;
137	PAINTSTRUCT ps;
138	HDC hdc;
139
140	switch (message)
141	{
142	case WM_COMMAND:
143		wmId    = LOWORD(wParam);
144		wmEvent = HIWORD(wParam);
145		// ??????:
146		switch (wmId)
147		{
148		case IDM_ABOUT:
149			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
150			break;
151		case IDM_EXIT:
152			DestroyWindow(hWnd);
153			break;
154		default:
155			return DefWindowProc(hWnd, message, wParam, lParam);
156		}
157		break;
158	case WM_PAINT:
159		hdc = BeginPaint(hWnd, &ps);
160		// TODO: ??????????...
161		EndPaint(hWnd, &ps);
162		break;
163	case WM_DESTROY:
164		PostQuitMessage(0);
165		break;
166	default:
167		return DefWindowProc(hWnd, message, wParam, lParam);
168	}
169	return 0;
170}
171
172// “??”?????????
173INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
174{
175	UNREFERENCED_PARAMETER(lParam);
176	switch (message)
177	{
178	case WM_INITDIALOG:
179		return (INT_PTR)TRUE;
180
181	case WM_COMMAND:
182		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
183		{
184			EndDialog(hDlg, LOWORD(wParam));
185			return (INT_PTR)TRUE;
186		}
187		break;
188	}
189	return (INT_PTR)FALSE;
190}
191
192#endif