| 77a37381 |
1 | // tester1.cpp : Defines the entry point for the application. |
| 2 | // |
| 3 | |
| 4 | #include "stdafx.h" |
| 5 | #include "tester1.h" |
| 6 | #include <commctrl.h> |
| 7 | //#include <aygshell.h> |
| 8 | #include <sipapi.h> |
| 9 | #include "setup.h" |
| 10 | |
| 11 | #define MAX_LOADSTRING 100 |
| 12 | |
| 13 | // Global Variables: |
| 14 | HINSTANCE hInst; // The current instance |
| 15 | HWND hwndCB; // The command bar handle |
| 16 | |
| 17 | //static SHACTIVATEINFO s_sai; |
| 18 | |
| 19 | ATOM MyRegisterClass (HINSTANCE, LPTSTR); |
| 20 | BOOL InitInstance (HINSTANCE, int); |
| 21 | LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); |
| 22 | LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM); |
| 23 | HWND CreateRpCommandBar(HWND); |
| 24 | |
| c5f1f439 |
25 | |
| 77a37381 |
26 | #pragma warning(disable: 4100 4710 4189; error: 4701) |
| 27 | /* who cares?! |
| 28 | 4100: whining about parameters not being used. |
| 29 | 4710: whining about screwing up inlining. |
| 30 | 4189: initialized but not used. make that an error: later. |
| 31 | 4701: usage w/o initialization. |
| 32 | */ |
| c5f1f439 |
33 | |
| 77a37381 |
34 | int WINAPI WinMain( HINSTANCE hInstance, |
| 35 | HINSTANCE hPrevInstance, |
| 36 | LPTSTR lpCmdLine, |
| 37 | int nCmdShow) |
| 38 | { |
| 39 | MSG msg; |
| 40 | HACCEL hAccelTable; |
| 41 | |
| 42 | // Perform application initialization: |
| 43 | if (!InitInstance (hInstance, nCmdShow)) |
| 44 | { |
| 45 | return FALSE; |
| 46 | } |
| 47 | |
| 48 | hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTER1); |
| 49 | |
| 50 | // Main message loop: |
| 51 | while (GetMessage(&msg, NULL, 0, 0)) |
| 52 | { |
| 53 | if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) |
| 54 | { |
| 55 | TranslateMessage(&msg); |
| 56 | DispatchMessage(&msg); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return msg.wParam; |
| 61 | } |
| 62 | |
| 63 | // |
| 64 | // FUNCTION: MyRegisterClass() |
| 65 | // |
| 66 | // PURPOSE: Registers the window class. |
| 67 | // |
| 68 | // COMMENTS: |
| 69 | // |
| 70 | // It is important to call this function so that the application |
| 71 | // will get 'well formed' small icons associated with it. |
| 72 | // |
| 73 | ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass) |
| 74 | { |
| 75 | WNDCLASS wc; |
| 76 | |
| 77 | wc.style = CS_HREDRAW | CS_VREDRAW; |
| 78 | wc.lpfnWndProc = (WNDPROC) WndProc; |
| 79 | wc.cbClsExtra = 0; |
| 80 | wc.cbWndExtra = 0; |
| 81 | wc.hInstance = hInstance; |
| 82 | wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TESTER1)); |
| 83 | wc.hCursor = 0; |
| 84 | wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); |
| 85 | wc.lpszMenuName = 0; |
| 86 | wc.lpszClassName = szWindowClass; |
| 87 | |
| 88 | return RegisterClass(&wc); |
| 89 | } |
| c5f1f439 |
90 | |
| 91 | HANDLE OpenCOM1() { |
| 92 | |
| 93 | static HANDLE COM1handle = INVALID_HANDLE_VALUE; |
| 94 | const char msg[] = "\r\n--------linexec--------\r\n"; |
| 95 | unsigned long wrote; |
| 96 | int speed = CBR_115200; |
| 97 | HANDLE h; |
| 98 | |
| 99 | if (COM1handle != INVALID_HANDLE_VALUE) |
| 100 | return (COM1handle); |
| 101 | |
| 102 | h = CreateFile(TEXT("COM1:"), |
| 103 | GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, |
| 104 | NULL); |
| 105 | if (h == INVALID_HANDLE_VALUE) |
| 106 | return (h); |
| 107 | |
| 108 | DCB dcb; |
| 109 | if (!GetCommState(h, &dcb)) |
| 110 | goto bad; |
| 111 | |
| 112 | dcb.BaudRate = speed; |
| 113 | if (!SetCommState(h, &dcb)) |
| 114 | goto bad; |
| 115 | |
| 116 | // Print banner on serial console. |
| 117 | WriteFile(h, msg, sizeof msg, &wrote, 0); |
| 118 | |
| 119 | COM1handle = h; |
| 120 | |
| 121 | return (h); |
| 122 | bad: |
| 123 | CloseHandle(h); |
| 124 | return (INVALID_HANDLE_VALUE); |
| 125 | } |
| 77a37381 |
126 | |
| 127 | // |
| 128 | // FUNCTION: InitInstance(HANDLE, int) |
| 129 | // |
| 130 | // PURPOSE: Saves instance handle and creates main window |
| 131 | // |
| 132 | // COMMENTS: |
| 133 | // |
| 134 | // In this function, we save the instance handle in a global variable and |
| 135 | // create and display the main program window. |
| 136 | // |
| 137 | |
| 138 | BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) |
| 139 | { |
| c5f1f439 |
140 | HWND hWnd = NULL; |
| 141 | TCHAR szTitle[MAX_LOADSTRING]; // The title bar text |
| 77a37381 |
142 | TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name |
| c5f1f439 |
143 | |
| 144 | hInst = hInstance; // Store instance handle in our global variable |
| 145 | // Initialize global string |
| 146 | LoadString(hInstance, IDC_TESTER1, szWindowClass, MAX_LOADSTRING); |
| 77a37381 |
147 | LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); |
| c5f1f439 |
148 | |
| 77a37381 |
149 | //If it is already running, then focus on the window |
| 150 | hWnd = FindWindow(szWindowClass, szTitle); |
| 151 | if (hWnd) |
| 152 | { |
| 153 | SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01)); |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | MyRegisterClass(hInstance, szWindowClass); |
| 158 | |
| 159 | RECT rect; |
| 160 | GetClientRect(hWnd, &rect); |
| c5f1f439 |
161 | |
| 77a37381 |
162 | OpenCOM1(); |
| 163 | load_boot("\\My Documents\\params.txt"); |
| 164 | load_boot("\\Storage Card\\params.txt"); |
| b3b3aa8d |
165 | load_boot("\\Speicherkarte\\params.txt"); |
| 166 | load_boot("\\Carte de stockage\\params.txt"); |
| 167 | load_boot("\\Mes documents\\params.txt"); |
| 2f5d6735 |
168 | load_boot("\\My Handheld PC\\Storage Card\\params.txt"); |
| c5f1f439 |
169 | load_boot("\\ÒÓØ ¶°ÄÞ\\params.txt"); |
| 77a37381 |
170 | |
| 171 | hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE, |
| 172 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); |
| 173 | if (!hWnd) |
| 174 | { |
| 175 | return FALSE; |
| 176 | } |
| 177 | |
| 178 | |
| 179 | |
| 180 | //When the main window is created using CW_USEDEFAULT the height of the menubar (if one |
| 181 | // is created is not taken into account). So we resize the window after creating it |
| 182 | // if a menubar is present |
| 183 | { |
| 184 | RECT rc; |
| 185 | GetWindowRect(hWnd, &rc); |
| 186 | rc.bottom -= MENU_HEIGHT; |
| 187 | if (hwndCB) |
| 188 | MoveWindow(hWnd, rc.left, rc.top, rc.right, rc.bottom, FALSE); |
| 189 | } |
| 190 | |
| 191 | |
| 192 | ShowWindow(hWnd, nCmdShow); |
| 193 | UpdateWindow(hWnd); |
| 194 | |
| 195 | return TRUE; |
| 196 | } |
| 197 | |
| 198 | // |
| 199 | // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) |
| 200 | // |
| 201 | // PURPOSE: Processes messages for the main window. |
| 202 | // |
| 203 | // WM_COMMAND - process the application menu |
| 204 | // WM_PAINT - Paint the main window |
| 205 | // WM_DESTROY - post a quit message and return |
| 206 | // |
| 207 | // |
| 208 | LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 209 | { |
| c5f1f439 |
210 | |
| 77a37381 |
211 | HDC hdc; |
| c5f1f439 |
212 | |
| 77a37381 |
213 | int wmId, wmEvent; |
| c5f1f439 |
214 | |
| 77a37381 |
215 | PAINTSTRUCT ps; |
| c5f1f439 |
216 | |
| 77a37381 |
217 | TCHAR szHello[MAX_LOADSTRING]; |
| 77a37381 |
218 | |
| c5f1f439 |
219 | |
| 220 | |
| 77a37381 |
221 | switch (message) |
| c5f1f439 |
222 | |
| 77a37381 |
223 | { |
| c5f1f439 |
224 | |
| 77a37381 |
225 | case WM_COMMAND: |
| c5f1f439 |
226 | |
| 77a37381 |
227 | wmId = LOWORD(wParam); |
| c5f1f439 |
228 | |
| 77a37381 |
229 | wmEvent = HIWORD(wParam); |
| c5f1f439 |
230 | |
| 77a37381 |
231 | // Parse the menu selections: |
| c5f1f439 |
232 | |
| 77a37381 |
233 | switch (wmId) |
| c5f1f439 |
234 | |
| 77a37381 |
235 | { |
| c5f1f439 |
236 | |
| 77a37381 |
237 | case IDM_HELP_ABOUT: |
| c5f1f439 |
238 | |
| 77a37381 |
239 | DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); |
| c5f1f439 |
240 | |
| 77a37381 |
241 | break; |
| c5f1f439 |
242 | |
| 77a37381 |
243 | case IDOK: |
| c5f1f439 |
244 | |
| 77a37381 |
245 | SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd); |
| c5f1f439 |
246 | |
| 77a37381 |
247 | SendMessage (hWnd, WM_CLOSE, 0, 0); |
| c5f1f439 |
248 | |
| 77a37381 |
249 | break; |
| c5f1f439 |
250 | |
| 77a37381 |
251 | default: |
| c5f1f439 |
252 | |
| 77a37381 |
253 | return DefWindowProc(hWnd, message, wParam, lParam); |
| c5f1f439 |
254 | |
| 77a37381 |
255 | } |
| c5f1f439 |
256 | |
| 77a37381 |
257 | break; |
| c5f1f439 |
258 | |
| 77a37381 |
259 | case WM_CREATE: |
| c5f1f439 |
260 | |
| 77a37381 |
261 | hwndCB = CreateRpCommandBar(hWnd); |
| c5f1f439 |
262 | |
| 77a37381 |
263 | break; |
| c5f1f439 |
264 | |
| 77a37381 |
265 | case WM_PAINT: |
| c5f1f439 |
266 | |
| 77a37381 |
267 | RECT rt; |
| c5f1f439 |
268 | |
| 77a37381 |
269 | hdc = BeginPaint(hWnd, &ps); |
| c5f1f439 |
270 | |
| 77a37381 |
271 | GetClientRect(hWnd, &rt); |
| c5f1f439 |
272 | |
| 77a37381 |
273 | LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); |
| c5f1f439 |
274 | |
| 77a37381 |
275 | DrawText(hdc, szHello, _tcslen(szHello), &rt, |
| c5f1f439 |
276 | |
| 77a37381 |
277 | DT_SINGLELINE | DT_VCENTER | DT_CENTER); |
| c5f1f439 |
278 | |
| 77a37381 |
279 | EndPaint(hWnd, &ps); |
| c5f1f439 |
280 | |
| 77a37381 |
281 | break; |
| c5f1f439 |
282 | |
| 77a37381 |
283 | case WM_DESTROY: |
| c5f1f439 |
284 | |
| 77a37381 |
285 | CommandBar_Destroy(hwndCB); |
| c5f1f439 |
286 | |
| 77a37381 |
287 | PostQuitMessage(0); |
| c5f1f439 |
288 | |
| 77a37381 |
289 | break; |
| c5f1f439 |
290 | |
| 77a37381 |
291 | case WM_SETTINGCHANGE: |
| c5f1f439 |
292 | |
| 77a37381 |
293 | // SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); |
| c5f1f439 |
294 | |
| 77a37381 |
295 | break; |
| c5f1f439 |
296 | |
| 77a37381 |
297 | default: |
| c5f1f439 |
298 | |
| 77a37381 |
299 | return DefWindowProc(hWnd, message, wParam, lParam); |
| c5f1f439 |
300 | |
| 77a37381 |
301 | } |
| c5f1f439 |
302 | |
| 77a37381 |
303 | return 0; |
| c5f1f439 |
304 | |
| 77a37381 |
305 | } |
| 77a37381 |
306 | |
| c5f1f439 |
307 | |
| 308 | |
| 77a37381 |
309 | HWND CreateRpCommandBar(HWND hwnd) |
| c5f1f439 |
310 | |
| 77a37381 |
311 | { |
| c5f1f439 |
312 | /* |
| 77a37381 |
313 | SHMENUBARINFO mbi; |
| 77a37381 |
314 | |
| c5f1f439 |
315 | |
| 316 | |
| 77a37381 |
317 | memset(&mbi, 0, sizeof(SHMENUBARINFO)); |
| c5f1f439 |
318 | |
| 77a37381 |
319 | mbi.cbSize = sizeof(SHMENUBARINFO); |
| c5f1f439 |
320 | |
| 77a37381 |
321 | mbi.hwndParent = hwnd; |
| c5f1f439 |
322 | |
| 77a37381 |
323 | mbi.nToolBarId = IDM_MENU; |
| c5f1f439 |
324 | |
| 77a37381 |
325 | mbi.hInstRes = hInst; |
| c5f1f439 |
326 | |
| 77a37381 |
327 | mbi.nBmpId = 0; |
| c5f1f439 |
328 | |
| 77a37381 |
329 | mbi.cBmpImages = 0; |
| 77a37381 |
330 | |
| c5f1f439 |
331 | |
| 332 | |
| 77a37381 |
333 | if (!SHCreateMenuBar(&mbi)) |
| c5f1f439 |
334 | |
| 77a37381 |
335 | return NULL; |
| 77a37381 |
336 | |
| c5f1f439 |
337 | |
| 338 | |
| 77a37381 |
339 | return mbi.hwndMB; |
| c5f1f439 |
340 | */ |
| 341 | return NULL; |
| 77a37381 |
342 | } |
| 77a37381 |
343 | |
| c5f1f439 |
344 | |
| 345 | |
| 77a37381 |
346 | // Mesage handler for the About box. |
| c5f1f439 |
347 | |
| 77a37381 |
348 | LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) |
| c5f1f439 |
349 | |
| 77a37381 |
350 | { |
| c5f1f439 |
351 | |
| 77a37381 |
352 | // SHINITDLGINFO shidi; |
| 77a37381 |
353 | |
| c5f1f439 |
354 | |
| 355 | |
| 77a37381 |
356 | switch (message) |
| c5f1f439 |
357 | |
| 77a37381 |
358 | { |
| c5f1f439 |
359 | |
| 77a37381 |
360 | case WM_INITDIALOG: |
| c5f1f439 |
361 | |
| 77a37381 |
362 | // Create a Done button and size it. |
| c5f1f439 |
363 | |
| 77a37381 |
364 | // shidi.dwMask = SHIDIM_FLAGS; |
| c5f1f439 |
365 | |
| 77a37381 |
366 | // shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN; |
| c5f1f439 |
367 | |
| 77a37381 |
368 | // shidi.hDlg = hDlg; |
| c5f1f439 |
369 | |
| 77a37381 |
370 | // SHInitDialog(&shidi); |
| c5f1f439 |
371 | |
| 77a37381 |
372 | return TRUE; |
| 77a37381 |
373 | |
| c5f1f439 |
374 | |
| 375 | |
| 77a37381 |
376 | case WM_COMMAND: |
| c5f1f439 |
377 | |
| 77a37381 |
378 | if (LOWORD(wParam) == IDOK) { |
| c5f1f439 |
379 | |
| 77a37381 |
380 | EndDialog(hDlg, LOWORD(wParam)); |
| c5f1f439 |
381 | |
| 77a37381 |
382 | return TRUE; |
| c5f1f439 |
383 | |
| 77a37381 |
384 | } |
| c5f1f439 |
385 | |
| 77a37381 |
386 | break; |
| c5f1f439 |
387 | |
| 77a37381 |
388 | } |
| c5f1f439 |
389 | |
| 77a37381 |
390 | return FALSE; |
| c5f1f439 |
391 | |
| 77a37381 |
392 | } |
| c5f1f439 |
393 | |