Leaked source code of windows server 2003
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.

857 lines
22 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: wndstuff.cpp
  3. *
  4. * This file contains the code to support a simple window that has
  5. * a menu with a single item called "Test". When "Test" is selected
  6. * vTest(HWND) is called.
  7. *
  8. * Created: 09-Dec-1992 10:44:31
  9. * Author: Kirk Olynyk [kirko]
  10. *
  11. * Copyright (c) 1991 Microsoft Corporation
  12. *
  13. \**************************************************************************/
  14. #include <tchar.h>
  15. #include <stdio.h>
  16. #include "precomp.hpp"
  17. #include "wndstuff.h"
  18. #include "../gpinit.inc"
  19. // globals
  20. HINSTANCE ghInst;
  21. HWND ghWndMain;
  22. HWND ghwndDebug;
  23. HBRUSH ghbrWhite;
  24. HINSTANCE ghGdiplus = NULL;
  25. FN_GDIPDRAWGLYPHS gfnGdipDrawGlyphs = NULL;
  26. FN_GDIPPATHADDGLYPHS gfnGdipPathAddGlyphs = NULL;
  27. FN_GDIPSETTEXTRENDERINGHINT gfnGdipSetTextRenderingHint = NULL;
  28. /***************************************************************************\
  29. * lMainWindowProc(hwnd, message, wParam, lParam)
  30. *
  31. * Processes all messages for the main window.
  32. *
  33. * History:
  34. * 04-07-91 -by- KentD
  35. * Wrote it.
  36. \***************************************************************************/
  37. LONG_PTR
  38. lMainWindowProc(
  39. HWND hwnd,
  40. UINT message,
  41. WPARAM wParam,
  42. LPARAM lParam
  43. )
  44. {
  45. PAINTSTRUCT ps;
  46. switch (message)
  47. {
  48. case WM_CREATE:
  49. if (ghGdiplus || (ghGdiplus = LoadLibrary("gdiplus.dll")))
  50. {
  51. gfnGdipDrawGlyphs =(FN_GDIPDRAWGLYPHS) GetProcAddress(ghGdiplus, "GdipDrawGlyphs");
  52. gfnGdipPathAddGlyphs = (FN_GDIPPATHADDGLYPHS) GetProcAddress(ghGdiplus, "GdipPathAddGlyphs");
  53. gfnGdipSetTextRenderingHint =(FN_GDIPSETTEXTRENDERINGHINT) GetProcAddress(ghGdiplus, "GdipSetTextRenderingHint");
  54. }
  55. // if (gfnGdipDrawGlyphs == NULL)
  56. // EnableMenuItem(GetMenu(hwnd), IDM_DRAWGLYPHS, MF_GRAYED);
  57. if (gfnGdipPathAddGlyphs == NULL)
  58. EnableMenuItem(GetMenu(hwnd), IDM_PATHGLYPHS, MF_GRAYED);
  59. break;
  60. case WM_COMMAND:
  61. switch(LOWORD(wParam))
  62. {
  63. case IDM_TEST:
  64. Test(hwnd);
  65. break;
  66. case IDM_CREATEFONT:
  67. ShowDialogBox(CreateFontDlgProc, IDD_CREATEFONT);
  68. break;
  69. case IDM_DRAWGLYPHS:
  70. ShowDialogBox(DrawGlyphsDlgProc, IDD_DRAWGLYPHS);
  71. break;
  72. case IDM_PATHGLYPHS:
  73. ShowDialogBox(PathGlyphsDlgProc, IDD_DRAWGLYPHS);
  74. break;
  75. case ID_ADDFONTFILE:
  76. ShowDialogBox(AddFontFileDlgProc, IDD_ADDFONTFILE);
  77. break;
  78. case ID_REMOVEFONTFILE:
  79. ShowDialogBox(RemoveFontDlgProc, IDD_REMOVEFONT);
  80. break;
  81. case ID_ANTIALIAS_ON:
  82. TestTextAntiAliasOn();
  83. break;
  84. case ID_ANTIALIAS_OFF:
  85. TestTextAntiAliasOff();
  86. break;
  87. default:
  88. break;
  89. }
  90. break;
  91. case WM_DESTROY:
  92. DeleteObject(ghbrWhite);
  93. if (gFont)
  94. delete gFont;
  95. PostQuitMessage(0);
  96. return(DefWindowProc(hwnd, message, wParam, lParam));
  97. default:
  98. return(DefWindowProc(hwnd, message, wParam, lParam));
  99. }
  100. return(0);
  101. }
  102. /***************************************************************************\
  103. * bInitApp()
  104. *
  105. * Initializes app.
  106. *
  107. * History:
  108. * 04-07-91 -by- KentD
  109. * Wrote it.
  110. \***************************************************************************/
  111. BOOL bInitApp(VOID)
  112. {
  113. WNDCLASS wc;
  114. if (!gGdiplusInitHelper.IsValid())
  115. {
  116. return(FALSE);
  117. }
  118. ghbrWhite = CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
  119. wc.style = 0;
  120. wc.lpfnWndProc = lMainWindowProc;
  121. wc.cbClsExtra = 0;
  122. wc.cbWndExtra = 0;
  123. wc.hInstance = ghInst;
  124. wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  125. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  126. wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  127. wc.lpszMenuName = MAKEINTRESOURCE(IDM_MAINMENU);
  128. wc.lpszClassName = _T("TestClass");
  129. if (!RegisterClass(&wc))
  130. {
  131. return(FALSE);
  132. }
  133. ghWndMain =
  134. CreateWindowEx(
  135. 0,
  136. _T("TestClass"),
  137. _T("Gdiplus Font Test"),
  138. WS_OVERLAPPED |
  139. WS_CAPTION |
  140. WS_BORDER |
  141. WS_THICKFRAME |
  142. WS_MAXIMIZEBOX |
  143. WS_MINIMIZEBOX |
  144. WS_CLIPCHILDREN |
  145. WS_VISIBLE |
  146. WS_SYSMENU,
  147. 80,
  148. 70,
  149. 500,
  150. 500,
  151. NULL,
  152. NULL,
  153. ghInst,
  154. NULL);
  155. if (ghWndMain == NULL)
  156. {
  157. return(FALSE);
  158. }
  159. SetFocus(ghWndMain);
  160. ghwndDebug = CreateWindow(
  161. "LISTBOX",
  162. "GdiplusFontTest Debugging",
  163. WS_VISIBLE | WS_SYSMENU | WS_VSCROLL | WS_THICKFRAME | WS_MINIMIZEBOX,
  164. 600, 70, 400, 700,
  165. NULL,
  166. NULL,
  167. ghInst,
  168. NULL);
  169. if (ghwndDebug)
  170. {
  171. SendMessage(ghwndDebug, WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), (LPARAM)FALSE);
  172. SendMessage(ghwndDebug, LB_RESETCONTENT, (WPARAM) FALSE, (LPARAM) 0);
  173. ShowWindow(ghwndDebug, SW_NORMAL);
  174. UpdateWindow(ghwndDebug);
  175. }
  176. return(TRUE);
  177. }
  178. INT_PTR ShowDialogBox(DLGPROC DialogProc, int iResource)
  179. {
  180. INT_PTR rc = -1;
  181. //DLGPROC lpProc;
  182. //if (lpProc = MakeProcInstance(DialogProc, ghInst))
  183. //{
  184. // rc = DialogBox(ghInst,
  185. // MAKEINTRESOURCE(iResource),
  186. // ghWndMain,
  187. // (DLGPROC) lpProc);
  188. //}
  189. //FreeProcInstance( lpProc );
  190. rc = DialogBox( ghInst,
  191. MAKEINTRESOURCE(iResource),
  192. ghWndMain,
  193. DialogProc);
  194. return rc;
  195. }
  196. /***************************************************************************\
  197. * main(argc, argv[])
  198. *
  199. * Sets up the message loop.
  200. *
  201. * History:
  202. * 04-07-91 -by- KentD
  203. * Wrote it.
  204. \***************************************************************************/
  205. _cdecl
  206. main(
  207. INT argc,
  208. PCHAR argv[])
  209. {
  210. MSG msg;
  211. HACCEL haccel;
  212. CHAR* pSrc;
  213. CHAR* pDst;
  214. ghInst = GetModuleHandle(NULL);
  215. if (!bInitApp())
  216. {
  217. return(0);
  218. }
  219. haccel = LoadAccelerators(ghInst, MAKEINTRESOURCE(1));
  220. while (GetMessage(&msg, NULL, 0, 0))
  221. {
  222. if (!TranslateAccelerator(msg.hwnd, haccel, &msg))
  223. {
  224. TranslateMessage(&msg);
  225. DispatchMessage(&msg);
  226. }
  227. }
  228. return(1);
  229. }
  230. //*****************************************************************************
  231. //******************* G E T D L G I T E M F L O A T *******************
  232. //*****************************************************************************
  233. FLOAT
  234. GetDlgItemFLOAT(
  235. HWND hdlg
  236. , int id
  237. )
  238. {
  239. char ach[50];
  240. memset(ach,0,sizeof(ach));
  241. return((FLOAT)(GetDlgItemText(hdlg,id,ach,sizeof(ach))?atof(ach):0.0));
  242. }
  243. //*****************************************************************************
  244. //******************* S E T D L G I T E M F L O A T *******************
  245. //*****************************************************************************
  246. void
  247. SetDlgItemFLOAT(
  248. HWND hdlg
  249. , int id
  250. , FLOAT e
  251. )
  252. {
  253. static char ach[25];
  254. ach[0] = '\0';
  255. sprintf(ach, "%f", e);
  256. SetDlgItemText(hdlg, id, ach);
  257. }
  258. ///////////////////////////////////////////////////////////////////////////////
  259. // CreateFontDlgProc()
  260. //
  261. // History:
  262. //
  263. // Aug-1999 Xudong Wu [tessiew]
  264. // Wrote it.
  265. ///////////////////////////////////////////////////////////////////////////////
  266. INT_PTR CALLBACK CreateFontDlgProc(
  267. HWND hdlg,
  268. UINT msg,
  269. WPARAM wParam,
  270. LPARAM lParam)
  271. {
  272. static char szName[MAX_PATH];
  273. LPSTR name;
  274. FLOAT size;
  275. FontStyle style;
  276. Unit unit;
  277. switch(msg)
  278. {
  279. case WM_INITDIALOG:
  280. SetDlgItemText(hdlg, IDC_FONT_FAMILYNAME, "Arial");
  281. SendDlgItemMessage(hdlg, IDC_FONT_FAMILYNAME, EM_LIMITTEXT, sizeof(szName), 0);
  282. SetDlgItemFLOAT(hdlg, IDC_FONT_SIZE, 30);
  283. CheckRadioButton(hdlg, IDC_FONT_REGULAR, IDC_FONT_ITALIC, IDC_FONT_REGULAR);
  284. CheckRadioButton(hdlg, IDC_UNITWORLD, IDC_UNITMM, IDC_UNITWORLD);
  285. return TRUE;
  286. case WM_COMMAND:
  287. switch(LOWORD(wParam))
  288. {
  289. case IDOK:
  290. szName[0] = 0;
  291. GetDlgItemText(hdlg, IDC_FONT_FAMILYNAME, szName, sizeof(szName));
  292. if (lstrlen(szName))
  293. {
  294. size = GetDlgItemFLOAT(hdlg, IDC_FONT_SIZE);
  295. if (size)
  296. {
  297. if (IsDlgButtonChecked(hdlg, IDC_FONT_REGULAR))
  298. style = FontStyleRegular;
  299. else if (IsDlgButtonChecked(hdlg, IDC_FONT_BOLD))
  300. style = FontStyleBold;
  301. else if (IsDlgButtonChecked(hdlg, IDC_FONT_ITALIC))
  302. style = FontStyleItalic;
  303. else if (IsDlgButtonChecked(hdlg, IDC_FONT_BOLDITALIC))
  304. style = FontStyleBoldItalic;
  305. if (IsDlgButtonChecked(hdlg, IDC_UNITWORLD))
  306. unit = UnitWorld;
  307. else if (IsDlgButtonChecked(hdlg, IDC_UNITDISPLAY))
  308. {
  309. // ASSERT(0); // UnitDisplay not valid !!!
  310. unit = UnitPixel;
  311. }
  312. else if (IsDlgButtonChecked(hdlg, IDC_UNITPIXEL))
  313. unit = UnitPixel;
  314. else if (IsDlgButtonChecked(hdlg, IDC_UNITPT))
  315. unit = UnitPoint;
  316. else if (IsDlgButtonChecked(hdlg, IDC_UNITINCH))
  317. unit = UnitInch;
  318. else if (IsDlgButtonChecked(hdlg, IDC_UNITDOC))
  319. unit = UnitDocument;
  320. else if (IsDlgButtonChecked(hdlg, IDC_UNITMM))
  321. unit = UnitMillimeter;
  322. CreateNewFont(szName, size, style, unit);
  323. }
  324. }
  325. EndDialog(hdlg, TRUE);
  326. return TRUE;
  327. case IDCANCEL:
  328. EndDialog(hdlg, FALSE);
  329. return TRUE;
  330. }
  331. break;
  332. case WM_CLOSE:
  333. EndDialog(hdlg, FALSE);
  334. return TRUE;
  335. }
  336. return FALSE;
  337. }
  338. ///////////////////////////////////////////////////////////////////////////////
  339. // GetNumber
  340. //
  341. // History:
  342. //
  343. // Aug-1999 Xudong Wu [tessiew]
  344. // Wrote it.
  345. ///////////////////////////////////////////////////////////////////////////////
  346. BOOL GetNumber(char* numstr, PVOID out, INT* count, INT flag)
  347. {
  348. char *pchar = numstr;
  349. INT i, num = 0;
  350. FLOAT numf = 0, *pf;
  351. UINT16 *puint16;
  352. INT *pint;
  353. if (*pchar != 0)
  354. {
  355. num = atoi(numstr);
  356. numf = (FLOAT)atof(numstr);
  357. if (num == 0 || numf == 0)
  358. {
  359. return FALSE;
  360. }
  361. if (flag == CONVERTTOUINT16)
  362. {
  363. puint16 = (UINT16*) out;
  364. puint16 += *count;
  365. *puint16 = (UINT16)num;
  366. }
  367. else if (flag == CONVERTTOINT)
  368. {
  369. pint = (INT*) out;
  370. pint += *count;
  371. *pint = num;
  372. }
  373. else
  374. {
  375. pf = (FLOAT*) out;
  376. pf += *count;
  377. *pf = numf;
  378. }
  379. *count = *count + 1;
  380. }
  381. return TRUE;
  382. }
  383. ///////////////////////////////////////////////////////////////////////////////
  384. // ParseStrToNumbers
  385. //
  386. // History:
  387. //
  388. // Aug-1999 Xudong Wu [tessiew]
  389. // Wrote it.
  390. ///////////////////////////////////////////////////////////////////////////////
  391. BOOL ParseStrToNumbers(char* str, PVOID out, INT* count, INT flag)
  392. {
  393. char *pchar = str, *pnum;
  394. char anum[30];
  395. BOOL bRet = TRUE;
  396. *count = 0;
  397. pnum = anum;
  398. *pnum = 0;
  399. while (*pchar)
  400. {
  401. if (*pchar == ' ' || *pchar == ',')
  402. {
  403. *pnum = 0;
  404. if (!GetNumber(anum, out, count, flag))
  405. return FALSE;
  406. pnum = anum;
  407. *pnum = 0;
  408. pchar++;
  409. }
  410. else if (*str < '0' || *str > '9')
  411. {
  412. return FALSE;
  413. }
  414. else
  415. {
  416. *pnum ++ = *pchar ++;
  417. }
  418. }
  419. *pnum = 0;
  420. if (!GetNumber(anum, out, count, flag))
  421. bRet = FALSE;;
  422. return bRet;
  423. }
  424. ///////////////////////////////////////////////////////////////////////////////
  425. // DrawGlyphsDlgProc
  426. //
  427. // History:
  428. //
  429. // Aug-1999 -by- Xudong Wu [tessiew]
  430. // Wrote it.
  431. ///////////////////////////////////////////////////////////////////////////////
  432. INT_PTR CALLBACK DrawGlyphsDlgProc(
  433. HWND hdlg,
  434. UINT msg,
  435. WPARAM wParam,
  436. LPARAM lParam)
  437. {
  438. UINT16 glyphIndices[MAX_GLYPH_COUNT];
  439. INT count, xycount;
  440. INT px[MAX_GLYPH_COUNT];
  441. INT py[MAX_GLYPH_COUNT];
  442. INT flags;
  443. char glyphStr[4*MAX_GLYPH_COUNT];
  444. switch(msg)
  445. {
  446. case WM_INITDIALOG:
  447. SetDlgItemText(hdlg, IDC_DG_GLYPHINDICES, "55, 72, 86, 87");
  448. SetDlgItemText(hdlg, IDC_DG_PX, "1600, 1920, 2240, 2560");
  449. SetDlgItemText(hdlg, IDC_DG_PY, "1600, 1600, 1600, 1600");
  450. return TRUE;
  451. case WM_COMMAND:
  452. switch(LOWORD(wParam))
  453. {
  454. case IDOK:
  455. glyphStr[0] = 0;
  456. GetDlgItemText(hdlg, IDC_DG_GLYPHINDICES, glyphStr, sizeof(glyphStr));
  457. if (ParseStrToNumbers(glyphStr, (PVOID)glyphIndices, &count, CONVERTTOUINT16))
  458. {
  459. glyphStr[0] = 0;
  460. GetDlgItemText(hdlg, IDC_DG_PX, glyphStr, sizeof(glyphStr));
  461. if (ParseStrToNumbers(glyphStr, (PVOID)px, &xycount, CONVERTTOINT))
  462. {
  463. glyphStr[0] = 0;
  464. GetDlgItemText(hdlg, IDC_DG_PY, glyphStr, sizeof(glyphStr));
  465. if (ParseStrToNumbers(glyphStr, (PVOID)py, &xycount, CONVERTTOINT))
  466. {
  467. if (IsDlgButtonChecked(hdlg, IDC_DG_GDIPLUS))
  468. flags |= DG_NOGDI;
  469. TestDrawGlyphs(ghWndMain, glyphIndices, count, px, py, flags);
  470. }
  471. }
  472. }
  473. EndDialog(hdlg, TRUE);
  474. return TRUE;
  475. case IDCANCEL:
  476. EndDialog(hdlg, FALSE);
  477. return TRUE;
  478. }
  479. break;
  480. case WM_CLOSE:
  481. EndDialog(hdlg, FALSE);
  482. return TRUE;
  483. }
  484. return FALSE;
  485. }
  486. ///////////////////////////////////////////////////////////////////////////////
  487. // PathGlyphsDlgProc
  488. //
  489. // History:
  490. //
  491. // Aug-1999 -by- Xudong Wu [tessiew]
  492. // Wrote it.
  493. ///////////////////////////////////////////////////////////////////////////////
  494. INT_PTR CALLBACK PathGlyphsDlgProc(
  495. HWND hdlg,
  496. UINT msg,
  497. WPARAM wParam,
  498. LPARAM lParam)
  499. {
  500. UINT16 glyphIndices[MAX_GLYPH_COUNT];
  501. INT count, xycount;
  502. INT px[MAX_GLYPH_COUNT];
  503. INT py[MAX_GLYPH_COUNT];
  504. INT flags;
  505. char glyphStr[4*MAX_GLYPH_COUNT];
  506. REAL prx[MAX_GLYPH_COUNT];
  507. REAL pry[MAX_GLYPH_COUNT];
  508. switch(msg)
  509. {
  510. case WM_INITDIALOG:
  511. SetDlgItemText(hdlg, IDC_DG_GLYPHINDICES, "55, 72, 86, 87");
  512. SetDlgItemText(hdlg, IDC_DG_PX, "100, 120, 140, 160");
  513. SetDlgItemText(hdlg, IDC_DG_PY, "100, 100, 100, 100");
  514. return TRUE;
  515. case WM_COMMAND:
  516. switch(LOWORD(wParam))
  517. {
  518. case IDOK:
  519. glyphStr[0] = 0;
  520. GetDlgItemText(hdlg, IDC_DG_GLYPHINDICES, glyphStr, sizeof(glyphStr));
  521. if (ParseStrToNumbers(glyphStr, (PVOID)glyphIndices, &count, CONVERTTOUINT16))
  522. {
  523. glyphStr[0] = 0;
  524. GetDlgItemText(hdlg, IDC_DG_PX, glyphStr, sizeof(glyphStr));
  525. if (ParseStrToNumbers(glyphStr, (PVOID)px, &xycount, CONVERTTOINT))
  526. {
  527. glyphStr[0] = 0;
  528. GetDlgItemText(hdlg, IDC_DG_PY, glyphStr, sizeof(glyphStr));
  529. if (ParseStrToNumbers(glyphStr, (PVOID)py, &xycount, CONVERTTOINT))
  530. {
  531. // Generate REAL glyph psitions
  532. for (INT i=0; i<count; i++)
  533. {
  534. prx[i] = REAL(px[i]);
  535. pry[i] = REAL(py[i]);
  536. }
  537. flags = 0;
  538. TestPathGlyphs(ghWndMain, glyphIndices, count, prx, pry, flags);
  539. }
  540. }
  541. }
  542. EndDialog(hdlg, TRUE);
  543. return TRUE;
  544. case IDCANCEL:
  545. EndDialog(hdlg, FALSE);
  546. return TRUE;
  547. }
  548. break;
  549. case WM_CLOSE:
  550. EndDialog(hdlg, FALSE);
  551. return TRUE;
  552. }
  553. return FALSE;
  554. }
  555. ////////////////////////////////////////////////////////////////
  556. // GetGlyphMetricsDlgProc
  557. //
  558. // History:
  559. //
  560. // Aug-18-1999 -by- Xudong Wu [tessiew]
  561. // Wrote it.
  562. ///////////////////////////////////////////////////////////////
  563. INT_PTR CALLBACK GetGlyphMetricsDlgProc(
  564. HWND hdlg,
  565. UINT msg,
  566. WPARAM wParam,
  567. LPARAM lParam)
  568. {
  569. UINT16 glyphIndices[MAX_GLYPH_COUNT];
  570. INT count, xycount;
  571. INT px[MAX_GLYPH_COUNT];
  572. INT py[MAX_GLYPH_COUNT];
  573. INT flags;
  574. char glyphStr[4*MAX_GLYPH_COUNT];
  575. switch(msg)
  576. {
  577. case WM_INITDIALOG:
  578. SetDlgItemText(hdlg, IDC_GGM_GLYPHINDICES, "55, 72, 86, 87");
  579. CheckRadioButton(hdlg, IDC_GGM_FL_DEFAULT, IDC_GGM_FL_SIMITALIC, IDC_GGM_FL_DEFAULT);
  580. return TRUE;
  581. case WM_COMMAND:
  582. switch(LOWORD(wParam))
  583. {
  584. case IDOK:
  585. glyphStr[0] = 0;
  586. GetDlgItemText(hdlg, IDC_GGM_GLYPHINDICES, glyphStr, sizeof(glyphStr));
  587. if (ParseStrToNumbers(glyphStr, (PVOID)glyphIndices, &count, CONVERTTOUINT16))
  588. {
  589. if (IsDlgButtonChecked(hdlg, IDC_GGM_FL_DEFAULT))
  590. flags = 0;
  591. else if (IsDlgButtonChecked(hdlg, IDC_GGM_FL_VMTX))
  592. flags = 1;
  593. else if (IsDlgButtonChecked(hdlg, IDC_GGM_FL_SIMBOLD))
  594. flags = 2;
  595. else if (IsDlgButtonChecked(hdlg, IDC_GGM_FL_SIMITALIC))
  596. flags = 3;
  597. }
  598. EndDialog(hdlg, TRUE);
  599. return TRUE;
  600. case IDCANCEL:
  601. EndDialog(hdlg, FALSE);
  602. return TRUE;
  603. }
  604. break;
  605. case WM_CLOSE:
  606. EndDialog(hdlg, FALSE);
  607. return TRUE;
  608. }
  609. return FALSE;
  610. }
  611. ///////////////////////////////////////////////////////////////////////////////
  612. // CreateFontDlgProc()
  613. //
  614. // History:
  615. //
  616. // Nov-1999 Xudong Wu [tessiew]
  617. // Wrote it.
  618. ///////////////////////////////////////////////////////////////////////////////
  619. INT_PTR CALLBACK AddFontFileDlgProc(
  620. HWND hdlg,
  621. UINT msg,
  622. WPARAM wParam,
  623. LPARAM lParam)
  624. {
  625. static char szName[MAX_PATH];
  626. LPSTR name;
  627. INT flag;
  628. BOOL loadAsImage = FALSE;
  629. switch(msg)
  630. {
  631. case WM_INITDIALOG:
  632. CheckRadioButton(hdlg, IDC_PUBLIC, IDC_NOTENUM, IDC_PUBLIC);
  633. return TRUE;
  634. case WM_COMMAND:
  635. switch(LOWORD(wParam))
  636. {
  637. case IDOK:
  638. szName[0] = 0;
  639. GetDlgItemText(hdlg, IDC_FONTFILENAME, szName, sizeof(szName));
  640. if (IsDlgButtonChecked(hdlg, IDC_PUBLIC))
  641. flag = AddFontFlagPublic;
  642. else
  643. flag = AddFontFlagNotEnumerate;
  644. if (IsDlgButtonChecked(hdlg, IDD_LOADASIMAGE))
  645. loadAsImage = TRUE;
  646. if (lstrlen(szName))
  647. {
  648. TestAddFontFile(szName, flag, loadAsImage);
  649. }
  650. EndDialog(hdlg, TRUE);
  651. return TRUE;
  652. case IDCANCEL:
  653. EndDialog(hdlg, FALSE);
  654. return TRUE;
  655. }
  656. break;
  657. case WM_CLOSE:
  658. EndDialog(hdlg, FALSE);
  659. return TRUE;
  660. }
  661. return FALSE;
  662. }
  663. ///////////////////////////////////////////////////////////////////////////////
  664. // RemoveFontDlgProc()
  665. //
  666. // History:
  667. //
  668. // Dec-1999 Xudong Wu [tessiew]
  669. // Wrote it.
  670. ///////////////////////////////////////////////////////////////////////////////
  671. INT_PTR CALLBACK RemoveFontDlgProc(
  672. HWND hdlg,
  673. UINT msg,
  674. WPARAM wParam,
  675. LPARAM lParam)
  676. {
  677. char ach[50];
  678. switch(msg)
  679. {
  680. case WM_COMMAND:
  681. switch(LOWORD(wParam))
  682. {
  683. case IDOK:
  684. GetDlgItemText(hdlg, IDC_FILEPATH, ach, sizeof(ach));
  685. TestRemoveFontFile(ach);
  686. EndDialog(hdlg, TRUE);
  687. return TRUE;
  688. case IDCANCEL:
  689. EndDialog(hdlg, FALSE);
  690. return TRUE;
  691. }
  692. break;
  693. case WM_CLOSE:
  694. EndDialog(hdlg, FALSE);
  695. return TRUE;
  696. }
  697. return FALSE;
  698. }
  699. /******************************Public*Routine******************************\
  700. * Dbgprintf
  701. *
  702. * ListBox printf implementation.
  703. *
  704. * History:
  705. * Aug-18-1999 -by- Xudong Wu [tessiew]
  706. * Wrote it.
  707. \**************************************************************************/
  708. void Dbgprintf(PCH msg, ...)
  709. {
  710. va_list ap;
  711. char buffer[256];
  712. va_start(ap, msg);
  713. vsprintf(buffer, msg, ap);
  714. if (ghwndDebug)
  715. {
  716. SendMessage(ghwndDebug, LB_ADDSTRING, (WPARAM) 0, (LPARAM) buffer);
  717. SendMessage(ghwndDebug, WM_SETREDRAW, (WPARAM) TRUE, (LPARAM) 0);
  718. InvalidateRect(ghwndDebug, NULL, TRUE);
  719. UpdateWindow(ghwndDebug);
  720. }
  721. va_end(ap);
  722. }