Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

641 lines
16 KiB

  1. /*************************************************
  2. * winmain.c *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. //
  8. // 1/17/96
  9. // @E01 Change for multi-threading
  10. // @E02 Change for multi-threading without extending function
  11. #include <windows.h> // required for all Windows applications
  12. #include <tchar.h>
  13. #include <process.h> // <=== @E01
  14. #include <commctrl.h> // <=== @E01
  15. #include <htmlhelp.h>
  16. #include "rc.h" // prototypes specific to this application
  17. #include "uimetool.h"
  18. #include "wizard.h"
  19. #include "imeattr.h"
  20. #include "imerc.h"
  21. #include "imm.h"
  22. #ifdef UNICODE
  23. typedef DWORD UNALIGNED FAR *LPUNADWORD;
  24. typedef WORD UNALIGNED FAR *LPUNAWORD;
  25. typedef TCHAR UNALIGNED FAR *LPUNATCHAR;
  26. #else
  27. typedef DWORD FAR *LPUNADWORD;
  28. typedef WORD FAR *LPUNAWORD;
  29. typedef TCHAR FAR *LPUNATCHAR;
  30. #define TCHAR BYTE
  31. #endif
  32. HINSTANCE hInst;
  33. HWND hProgMain = 0; // <=== @E01
  34. const static DWORD aLCtoolHelpIDs[] = { // Context Help IDs
  35. IDD_IME_NAME, IDH_IME_NAME,
  36. IDD_TABLE_NAME, IDH_TABLE_NAME,
  37. IDD_ROOT_NUM, IDH_ROOT_NUM,
  38. IDD_IME_FILE_NAME, IDH_IME_FILE_NAME,
  39. IDD_CANDBEEP_YES, IDH_CANDBEEP_YES,
  40. IDD_CANDBEEP_NO, IDH_CANDBEEP_NO,
  41. IDD_BROWSE, IDH_TABLE_NAME,
  42. 0, 0
  43. };
  44. BOOL ErrorFlag = 0;
  45. BOOL bFinish = 0;
  46. UINT nWizStratPage = 0;
  47. extern HWND hwndMain;
  48. extern TCHAR szIme_Name[IME_NAME_LEN_TOOL];
  49. extern TCHAR szTab_Name[MAX_PATH];
  50. extern TCHAR szKey_Num_Str[KEY_NUM_STR_LEN];
  51. extern TCHAR szFile_Out_Name[TAB_NAME_LEN];
  52. extern TCHAR Show_Mess[MAX_PATH];
  53. extern TCHAR Msg_buf[MAX_PATH];
  54. extern BOOL bCandBeep;
  55. void ErrMsg(UINT, UINT);
  56. BOOL CheckImeFileName(HWND hDlg);
  57. void ImmSetAlphanumMode(HWND hwnd);
  58. void ImmSetNativeMode(HWND hwnd);
  59. BOOL InitProgressMsg(void); // <=== @E01
  60. BOOL ProgressMsg(void); // <=== @E01
  61. void ResetParams(void)
  62. {
  63. lstrcpy(szIme_Name, _TEXT(""));
  64. lstrcpy(szFile_Out_Name, _TEXT(""));
  65. lstrcpy(szTab_Name, _TEXT(""));
  66. lstrcpy(szKey_Num_Str, _TEXT("4"));
  67. bCandBeep = TRUE;
  68. nWizStratPage = 0;
  69. }
  70. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  71. {
  72. DWORD retCode;
  73. // DWORD dwID;
  74. UNREFERENCED_PARAMETER( nCmdShow );
  75. UNREFERENCED_PARAMETER( lpCmdLine );
  76. UNREFERENCED_PARAMETER( hPrevInstance );
  77. hInst = hInstance;
  78. InitCommonControls();
  79. //retCode = DialogBox ((HANDLE)hInst, (LPCTSTR)_TEXT("UimeToolDialog"),
  80. // NULL, (DLGPROC)SetDialogProc);
  81. ResetParams();
  82. RE_START:
  83. bFinish = 0;
  84. retCode = CreateWizard(NULL, hInstance);
  85. if(bFinish)
  86. {
  87. //SetCursor(LoadCursor(NULL, IDC_WAIT));
  88. //MakeNewIme(hDlg);
  89. // <=== @E01
  90. if (InitProgressMsg()) {
  91. //_beginthreadex(NULL, 0, MakeNewImeThread, NULL, 0, &dwID);
  92. _beginthread((PVOID)MakeNewImeThread, 0, NULL);
  93. // AttachThreadInput(dwID, GetCurrentThreadId(), TRUE);
  94. ProgressMsg();
  95. if (!bFinish) {
  96. nWizStratPage = 2;
  97. goto RE_START;
  98. }
  99. }
  100. // <=== @E01
  101. //SetCursor(LoadCursor(NULL, IDC_ARROW));
  102. }
  103. return (retCode);
  104. }
  105. INT_PTR APIENTRY ImeName(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  106. {
  107. switch (message)
  108. {
  109. case WM_INITDIALOG:
  110. hwndMain = hDlg;
  111. SendDlgItemMessage(hDlg, IDD_IME_NAME, EM_SETLIMITTEXT, IME_NAME_LEN_TOOL-1, 0);
  112. SendDlgItemMessage(hDlg, IDD_IME_FILE_NAME, EM_SETLIMITTEXT, TAB_NAME_LEN-1, 0);
  113. //lstrcpy(szIme_Name, _TEXT(""));
  114. //lstrcpy(szFile_Out_Name, _TEXT(""));
  115. break;
  116. case WM_COMMAND:
  117. if(LOWORD(wParam) == IDD_IME_NAME)
  118. {
  119. if(HIWORD(wParam) == EN_SETFOCUS)
  120. ImmSetNativeMode((HWND)lParam);
  121. else if(HIWORD(wParam) == EN_KILLFOCUS)
  122. ImmSetAlphanumMode((HWND)lParam);
  123. }
  124. else if(LOWORD(wParam) == IDD_IME_FILE_NAME)
  125. {
  126. if(HIWORD(wParam) == EN_SETFOCUS)
  127. ImmSetAlphanumMode((HWND)lParam);
  128. else if(HIWORD(wParam) == EN_KILLFOCUS)
  129. {
  130. ImmSetNativeMode((HWND)lParam);
  131. ErrorFlag = !CheckImeFileName(hDlg);
  132. }
  133. }
  134. break;
  135. case WM_NOTIFY:
  136. switch (((NMHDR FAR *) lParam)->code)
  137. {
  138. case PSN_KILLACTIVE:
  139. SetWindowLong(hDlg, DWLP_MSGRESULT, ErrorFlag ? TRUE : FALSE);
  140. return 1;
  141. break;
  142. case PSN_RESET:
  143. // reset to the original values
  144. lstrcpy(szIme_Name, _TEXT(""));
  145. lstrcpy(szFile_Out_Name, _TEXT(""));
  146. SetWindowLong(hDlg, DWLP_MSGRESULT, FALSE);
  147. break;
  148. case PSN_SETACTIVE:
  149. hwndMain = hDlg;
  150. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
  151. SendMessage(GetDlgItem(hDlg,0x3024 ), BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, MAKELONG(FALSE, 0));
  152. //SendMessage(GetParent(hDlg), DM_SETDEFID, (WPARAM)IDC_BUTTON1, 0);
  153. SendMessage(GetDlgItem(hDlg, IDD_IME_NAME), WM_SETTEXT, 0, (LPARAM)szIme_Name);
  154. SendMessage(GetDlgItem(hDlg, IDD_IME_FILE_NAME), WM_SETTEXT, 0, (LPARAM)szFile_Out_Name);
  155. break;
  156. case PSN_WIZNEXT:
  157. // the Next button was pressed
  158. // check ime name
  159. SendDlgItemMessage(hDlg, IDD_IME_NAME, WM_GETTEXT, (WPARAM)IME_NAME_LEN_TOOL, (LPARAM)szIme_Name);
  160. if(szIme_Name[0] == 0 || !is_DBCS(*((LPUNAWORD)szIme_Name)))
  161. {
  162. MessageBeep(0);
  163. ErrMsg(IDS_ERR_IMENAME, IDS_ERR_ERROR);
  164. SetFocus(GetDlgItem(hDlg, IDD_IME_NAME));
  165. ErrorFlag = 1;
  166. break;
  167. }
  168. // check file name
  169. ErrorFlag = !CheckImeFileName(hDlg);
  170. break;
  171. default:
  172. return FALSE;
  173. }
  174. break;
  175. case WM_HELP:
  176. HtmlHelp(((LPHELPINFO) lParam)->hItemHandle, HELP_FILE,
  177. HH_TP_HELP_WM_HELP, (DWORD_PTR)(LPTSTR) aLCtoolHelpIDs);
  178. break;
  179. case WM_CONTEXTMENU: // right mouse click
  180. HtmlHelp((HWND) wParam, HELP_FILE, HH_TP_HELP_CONTEXTMENU,
  181. (DWORD_PTR)(LPVOID) aLCtoolHelpIDs);
  182. break;
  183. default:
  184. return FALSE;
  185. }
  186. return TRUE;
  187. }
  188. INT_PTR APIENTRY ImeTable(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  189. {
  190. switch (message)
  191. {
  192. case WM_INITDIALOG:
  193. hwndMain = hDlg;
  194. //lstrcpy(szTab_Name, _TEXT(""));
  195. break;
  196. case WM_COMMAND:
  197. switch(LOWORD(wParam))
  198. {
  199. case IDD_BROWSE:
  200. GetOpenFile(hDlg);
  201. break;
  202. case IDD_TABLE_NAME:
  203. if(HIWORD(wParam) == EN_SETFOCUS)
  204. ImmSetAlphanumMode((HWND)lParam);
  205. else if(HIWORD(wParam) == EN_KILLFOCUS)
  206. ImmSetNativeMode((HWND)lParam);
  207. break;
  208. }
  209. break;
  210. case WM_NOTIFY:
  211. switch (((NMHDR FAR *) lParam)->code)
  212. {
  213. case PSN_KILLACTIVE:
  214. SetWindowLong(hDlg, DWLP_MSGRESULT, ErrorFlag ? TRUE : FALSE);
  215. return 1;
  216. break;
  217. case PSN_RESET:
  218. // rest to the original values
  219. lstrcpy(szTab_Name, _TEXT(""));
  220. SetWindowLong(hDlg, DWLP_MSGRESULT, FALSE);
  221. break;
  222. case PSN_SETACTIVE:
  223. hwndMain = hDlg;
  224. SendMessage(GetDlgItem(hDlg, IDD_TABLE_NAME), WM_SETTEXT, 0, (LPARAM)szTab_Name);
  225. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  226. break;
  227. case PSN_WIZBACK:
  228. SendDlgItemMessage(hDlg, IDD_TABLE_NAME, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)szTab_Name);
  229. ErrorFlag = 0;
  230. break;
  231. case PSN_WIZNEXT:
  232. SendDlgItemMessage(hDlg, IDD_TABLE_NAME, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)szTab_Name);
  233. if(szTab_Name[0] == 0)
  234. {
  235. MessageBeep(0);
  236. SetFocus(GetDlgItem(hDlg, IDD_TABLE_NAME));
  237. ErrorFlag = 1;
  238. return FALSE;
  239. }
  240. ErrorFlag = 0;
  241. break;
  242. default:
  243. return FALSE;
  244. }
  245. break;
  246. case WM_HELP:
  247. HtmlHelp(((LPHELPINFO) lParam)->hItemHandle, HELP_FILE,
  248. HH_TP_HELP_WM_HELP, (DWORD_PTR)(LPTSTR) aLCtoolHelpIDs);
  249. break;
  250. case WM_CONTEXTMENU: // right mouse click
  251. HtmlHelp((HWND) wParam, HELP_FILE, HH_TP_HELP_CONTEXTMENU,
  252. (DWORD_PTR)(LPVOID) aLCtoolHelpIDs);
  253. break;
  254. default:
  255. return FALSE;
  256. }
  257. return TRUE;
  258. }
  259. INT_PTR APIENTRY ImeParam(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  260. {
  261. switch (message)
  262. {
  263. case WM_INITDIALOG:
  264. hwndMain = hDlg;
  265. //lstrcpy(szKey_Num_Str, _TEXT("4"));
  266. //bCandBeep = TRUE;
  267. SendDlgItemMessage(hDlg, IDD_ROOT_NUM, EM_SETLIMITTEXT, KEY_NUM_STR_LEN-1, 0);
  268. SendDlgItemMessage(hDlg, IDD_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hDlg, IDD_ROOT_NUM), 0);
  269. SendDlgItemMessage(hDlg, IDD_SPIN, UDM_SETBASE, 10, 0);
  270. SendDlgItemMessage(hDlg, IDD_SPIN, UDM_SETRANGE, 0, (LPARAM)(MAKELONG(8, 1)));
  271. SendDlgItemMessage(hDlg, IDD_SPIN, UDM_SETPOS, 0, (LPARAM)(MAKELONG(4, 0)));
  272. break;
  273. case WM_COMMAND:
  274. if(LOWORD(wParam) == IDD_ROOT_NUM)
  275. {
  276. switch(HIWORD(wParam))
  277. {
  278. case EN_SETFOCUS:
  279. ImmSetAlphanumMode((HWND)lParam);
  280. break;
  281. case EN_KILLFOCUS:
  282. ImmSetNativeMode((HWND)lParam);
  283. break;
  284. }
  285. }
  286. break;
  287. case WM_NOTIFY:
  288. switch (((NMHDR FAR *) lParam)->code)
  289. {
  290. case PSN_KILLACTIVE:
  291. SetWindowLong(hDlg, DWLP_MSGRESULT, ErrorFlag ? TRUE : FALSE);
  292. return 1;
  293. break;
  294. case PSN_RESET:
  295. // rest to the original values
  296. lstrcpy(szKey_Num_Str, _TEXT("4"));
  297. bCandBeep = TRUE;
  298. SetWindowLong(hDlg, DWLP_MSGRESULT, FALSE);
  299. break;
  300. case PSN_SETACTIVE:
  301. hwndMain = hDlg;
  302. SendMessage(GetDlgItem(hDlg, IDD_ROOT_NUM), WM_SETTEXT, 0, (LPARAM)szKey_Num_Str);
  303. if(bCandBeep)
  304. SendMessage(GetDlgItem(hDlg, IDD_CANDBEEP_YES), BM_SETCHECK, 1, 0L);
  305. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
  306. break;
  307. case PSN_WIZBACK:
  308. ErrorFlag = 0;
  309. SendDlgItemMessage(hDlg, IDD_ROOT_NUM, WM_GETTEXT, (WPARAM)KEY_NUM_STR_LEN, (LPARAM)szKey_Num_Str);
  310. if(SendDlgItemMessage(hDlg, IDD_CANDBEEP_YES, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
  311. bCandBeep=TRUE;
  312. else
  313. bCandBeep=FALSE;
  314. break;
  315. case PSN_WIZFINISH:
  316. // check param
  317. if(SendDlgItemMessage(hDlg, IDD_CANDBEEP_YES, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
  318. bCandBeep=TRUE;
  319. else
  320. bCandBeep=FALSE;
  321. SendDlgItemMessage(hDlg, IDD_ROOT_NUM, WM_GETTEXT, (WPARAM)KEY_NUM_STR_LEN, (LPARAM)szKey_Num_Str);
  322. if(szKey_Num_Str[0] < _TEXT('1'))
  323. szKey_Num_Str[0] = _TEXT('1');
  324. else if(szKey_Num_Str[0] > _TEXT('8'))
  325. szKey_Num_Str[0] = _TEXT('8');
  326. szKey_Num_Str[1] = 0;
  327. // finish
  328. ErrorFlag = 0;
  329. bFinish = 1;
  330. break;
  331. default:
  332. return FALSE;
  333. }
  334. break;
  335. case WM_HELP:
  336. HtmlHelp(((LPHELPINFO) lParam)->hItemHandle, HELP_FILE,
  337. HH_TP_HELP_WM_HELP, (DWORD_PTR)(LPTSTR) aLCtoolHelpIDs);
  338. break;
  339. case WM_CONTEXTMENU: // right mouse click
  340. HtmlHelp((HWND) wParam, HELP_FILE, HH_TP_HELP_CONTEXTMENU,
  341. (DWORD_PTR)(LPVOID) aLCtoolHelpIDs);
  342. break;
  343. default:
  344. return FALSE;
  345. }
  346. return TRUE;
  347. }
  348. void FillInPropertyPage( PROPSHEETPAGE* psp, int idDlg, LPTSTR pszProc, DLGPROC pfnDlgProc)
  349. {
  350. psp->dwSize = sizeof(PROPSHEETPAGE);
  351. psp->dwFlags = PSP_USEHICON;
  352. psp->hInstance = hInst;
  353. psp->pszTemplate = MAKEINTRESOURCE(idDlg);
  354. psp->hIcon = LoadIcon(hInst, _TEXT("UIMETOOL"));
  355. psp->pfnDlgProc = pfnDlgProc;
  356. psp->pszTitle = pszProc;
  357. psp->lParam = 0;
  358. }
  359. int CreateWizard(HWND hwndOwner, HINSTANCE hInst)
  360. {
  361. PROPSHEETPAGE psp[NUM_PAGES];
  362. PROPSHEETHEADER psh;
  363. FillInPropertyPage( &psp[0], IDD_IMENAME, _TEXT("�q��J�k�W��"), ImeName);
  364. FillInPropertyPage( &psp[1], IDD_IMETABLE, _TEXT("�D�n���Ӫ�"), ImeTable);
  365. FillInPropertyPage( &psp[2], IDD_IMEPARAM, _TEXT("���J�k�Ѽ�"), ImeParam);
  366. psh.dwSize = sizeof(PROPSHEETHEADER);
  367. psh.dwFlags = PSH_PROPSHEETPAGE | PSH_WIZARD | PSH_NOAPPLYNOW | PSH_USEHICON;
  368. psh.hwndParent = hwndOwner;
  369. psh.hInstance = hInst;
  370. psh.hIcon = LoadIcon(hInst, _TEXT("UIMETOOL"));
  371. psh.pszCaption = _TEXT("�q�ο��J�k�إߺ��F");
  372. psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  373. psh.nStartPage = nWizStratPage;
  374. psh.ppsp = (LPCPROPSHEETPAGE) &psp;
  375. return (int)(PropertySheet(&psh));
  376. }
  377. BOOL CheckImeFileName(HWND hDlg)
  378. {
  379. int i, len;
  380. TCHAR szTitle[MAX_PATH];
  381. SendDlgItemMessage(hDlg, IDD_IME_FILE_NAME, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)szFile_Out_Name);
  382. if(szFile_Out_Name[0] == 0)
  383. goto ERROR1;
  384. // Check drive name, path name, extention name exist ?
  385. len = lstrlen(szFile_Out_Name);
  386. for(i = 0; i < len; i++)
  387. {
  388. if(szFile_Out_Name[i] == _TEXT('.'))
  389. break;
  390. }
  391. if(i != len)
  392. szFile_Out_Name[i] = 0;
  393. if(GetFileTitle(szFile_Out_Name, szTitle, sizeof(szTitle)))
  394. {
  395. SetFocus(GetDlgItem(hDlg, IDD_IME_FILE_NAME));
  396. ERROR1:
  397. MessageBeep(0);
  398. return FALSE;
  399. }
  400. lstrcpy(szFile_Out_Name, szTitle);
  401. SendMessage(GetDlgItem(hDlg, IDD_IME_FILE_NAME), WM_SETTEXT, 0, (LPARAM)szFile_Out_Name);
  402. return TRUE;
  403. }
  404. void ImmSetAlphanumMode(HWND hwnd)
  405. {
  406. DWORD fdwConversion, fdwSentence;
  407. HIMC hIMC = ImmGetContext(hwnd);
  408. ImmGetConversionStatus(hIMC, &fdwConversion, &fdwSentence);
  409. ImmSetConversionStatus(hIMC, fdwConversion & ~IME_CMODE_NATIVE,
  410. fdwSentence);
  411. }
  412. void ImmSetNativeMode(HWND hwnd)
  413. {
  414. DWORD fdwConversion, fdwSentence;
  415. HIMC hIMC = ImmGetContext(hwnd);
  416. ImmGetConversionStatus(hIMC, &fdwConversion, &fdwSentence);
  417. ImmSetConversionStatus(hIMC, fdwConversion | IME_CMODE_NATIVE,
  418. fdwSentence);
  419. }
  420. // <=== @E01
  421. HWND hWndProgress;
  422. UINT uMin, uMax;
  423. LRESULT APIENTRY ProgressWndProc(HWND hWnd, UINT message,
  424. UINT wParam,
  425. LONG lParam);
  426. BOOL InitProgressMsg(void)
  427. {
  428. WNDCLASS wcProgress;
  429. int x, y, width, height;
  430. TCHAR szTitle[MAX_PATH];
  431. wcProgress.style = 0;
  432. wcProgress.lpfnWndProc = (WNDPROC)ProgressWndProc;
  433. wcProgress.cbClsExtra = 0;
  434. wcProgress.cbWndExtra = 0;
  435. wcProgress.hInstance = hInst;
  436. wcProgress.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(256));
  437. wcProgress.hCursor = LoadCursor(NULL, IDC_ARROW);
  438. wcProgress.hbrBackground = GetStockObject(LTGRAY_BRUSH);
  439. wcProgress.lpszMenuName = NULL;
  440. wcProgress.lpszClassName = _TEXT("ProgressWClass");
  441. //if (!RegisterClass(&wcProgress))
  442. // return FALSE;
  443. RegisterClass(&wcProgress);
  444. width = 300;
  445. height = 100;
  446. x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
  447. y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2;
  448. LoadString (hInst, IDS_BUILDTITLE, szTitle, sizeof(szTitle) / sizeof(TCHAR));
  449. hProgMain = CreateWindowEx(
  450. 0,
  451. _TEXT("ProgressWClass"),
  452. szTitle, //_TEXT("�q�ο��J�k�إߤ�..."),
  453. WS_BORDER | WS_CAPTION,
  454. x, y, width, height,
  455. NULL,
  456. NULL,
  457. hInst,
  458. NULL);
  459. if (!hProgMain)
  460. return (FALSE);
  461. ShowWindow(hProgMain, SW_SHOW);
  462. UpdateWindow(hProgMain);
  463. return TRUE;
  464. }
  465. BOOL ProgressMsg(void)
  466. {
  467. MSG msg;
  468. while (GetMessage(&msg,
  469. NULL,
  470. 0,
  471. 0))
  472. {
  473. TranslateMessage(&msg);
  474. DispatchMessage(&msg);
  475. }
  476. return (BOOL)(msg.wParam);
  477. }
  478. LRESULT APIENTRY ProgressWndProc(
  479. HWND hWnd, /* window handle */
  480. UINT message, /* type of message */
  481. UINT wParam, /* additional information */
  482. LONG lParam) /* additional information */
  483. {
  484. HDC hdc;
  485. PAINTSTRUCT ps;
  486. static UINT uCurrent;
  487. switch (message)
  488. {
  489. case WM_CREATE:
  490. hWndProgress = CreateWindowEx(
  491. 0,
  492. PROGRESS_CLASS,
  493. _TEXT("Position"),
  494. WS_CHILD | WS_VISIBLE, // | PBS_SHOWPOS,
  495. 50,18,205,20,
  496. hWnd,
  497. NULL,
  498. hInst,
  499. NULL);
  500. if (hWndProgress == NULL)
  501. {
  502. MessageBox (NULL, _TEXT("Progress Bar not created!"), NULL, MB_OK );
  503. break;
  504. }
  505. uMin=0;
  506. uMax=20;
  507. uCurrent = uMin;
  508. SendMessage(hWndProgress, PBM_SETRANGE, 0L, MAKELONG(uMin, uMax));
  509. SendMessage(hWndProgress, PBM_SETSTEP, 1L, 0L);
  510. SetTimer(hWnd, 1000, 500, NULL);
  511. break;
  512. case WM_PAINT:
  513. {
  514. hdc = BeginPaint(hWnd, &ps);
  515. EndPaint(hWnd, &ps);
  516. }
  517. break;
  518. case WM_TIMER:
  519. if (uCurrent < uMax)
  520. {
  521. SendMessage(hWndProgress, PBM_STEPIT,0L,0L);
  522. uCurrent++;
  523. }
  524. else
  525. {
  526. uCurrent = uMin;
  527. }
  528. break;
  529. case WM_DESTROY: /* message: window being destroyed */
  530. KillTimer(hWnd, 1000);
  531. PostQuitMessage(0);
  532. break;
  533. default:
  534. return (DefWindowProc(hWnd, message, wParam, lParam));
  535. }
  536. return (0);
  537. }