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.

1283 lines
31 KiB

  1. /**************************************************/
  2. /* */
  3. /* */
  4. /* Registry Process */
  5. /* (Dialog) */
  6. /* */
  7. /* */
  8. /* Copyright (c) 1997-1999 Microsoft Corporation. */
  9. /**************************************************/
  10. #include "stdafx.h"
  11. #include "eudcedit.h"
  12. #include "assocdlg.h"
  13. #include "registry.h"
  14. #include "ttfstruc.h"
  15. #include "extfunc.h"
  16. #include "util.h"
  17. #include "gagedlg.h"
  18. #define LSPACE 2
  19. #define RSPACE 2
  20. #define LCSPACE 17
  21. #define NUMITEM 3
  22. #define DBCSCHK 0
  23. #define EUDCCHK 1
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static char BASED_CODE THIS_FILE[] = __FILE__;
  27. #endif
  28. SELECTEUDC SelectEUDC;
  29. static HDC hDC;
  30. static HWND hWnd;
  31. static HICON tIcon;
  32. static HGLOBAL hMem;
  33. static int nTypeFace, nIdx, CheckFlg;
  34. static TCHAR FontName[LF_FACESIZE];
  35. static LPASSOCIATIONREG lpAssociationReg;
  36. static int CheckTTF( LOGFONT);
  37. static BOOL CheckCharSet( int CharSet);
  38. static BOOL IsEUDCTTF( TCHAR *ttffile);
  39. static BOOL CheckFileName( LPTSTR FileStr);
  40. static int CALLBACK EnumFontFamProc(
  41. ENUMLOGFONT FAR*, NEWTEXTMETRIC FAR*, int, LPARAM);
  42. static int CALLBACK EnumFontNumber(
  43. ENUMLOGFONT FAR*, NEWTEXTMETRIC FAR*, int, LPARAM);
  44. extern BOOL SetCountryInfo( UINT LocalCP);
  45. /****************************************/
  46. /* */
  47. /* Constructor */
  48. /* */
  49. /****************************************/
  50. CAssocDlg::CAssocDlg(
  51. CWnd* pParent) : CDialog(CAssocDlg::IDD, pParent)
  52. {
  53. m_pParent = pParent;
  54. //{{AFX_DATA_INIT(CAssocDlg)
  55. //}}AFX_DATA_INIT
  56. }
  57. /****************************************/
  58. /* */
  59. /* MESSAGE "WM_INITDIALOG" */
  60. /* */
  61. /****************************************/
  62. BOOL
  63. CAssocDlg::OnInitDialog()
  64. {
  65. CString DlgTtl;
  66. long WindowStyle;
  67. CDialog::OnInitDialog();
  68. WindowStyle = GetWindowLong( this->GetSafeHwnd(), GWL_EXSTYLE);
  69. WindowStyle |= WS_EX_CONTEXTHELP;
  70. SetWindowLong( this->GetSafeHwnd(), GWL_EXSTYLE, WindowStyle);
  71. DlgTtl.LoadString( IDS_ASSOCIATE_DLGTITLE);
  72. this->SetWindowText( DlgTtl);
  73. // Set Dialog subclass
  74. m_RegListBox.SubclassDlgItem( IDC_REGISTLIST, this);
  75. m_RegListBox.EnableScrollBar( SB_VERT, ESB_DISABLE_BOTH);
  76. CheckFlg = EUDCCHK;
  77. this->SendDlgItemMessage( IDC_RADIO_SYSTEM, BM_SETCHECK, (WPARAM)1, 0);
  78. hMem = NULL;
  79. if( !SetAssociationFontType()){
  80. this->MessageBox( NotMemMsg, NotMemTtl, MB_OK |
  81. MB_ICONHAND | MB_SYSTEMMODAL);
  82. return FALSE;
  83. }
  84. tIcon = AfxGetApp()->LoadIcon( IDI_TRUETYPE);
  85. return TRUE;
  86. }
  87. /****************************************/
  88. /* */
  89. /* Set TTF and WIFE font */
  90. /* */
  91. /****************************************/
  92. BOOL
  93. CAssocDlg::SetAssociationFontType()
  94. {
  95. LPASSOCIATIONREG lpAssociationRegTmp;
  96. int aFontCount[] = {0,0,0};
  97. int StartIdx = 0;
  98. int sts;
  99. nTypeFace = nIdx = 0;
  100. hWnd = this->GetSafeHwnd();
  101. hDC = ::GetDC( hWnd);
  102. sts = EnumFontFamilies( hDC, NULL,
  103. (FONTENUMPROC)EnumFontNumber, (LPARAM)aFontCount);
  104. if( hMem != NULL){
  105. GlobalUnlock( hMem);
  106. GlobalFree( hMem);
  107. }
  108. hMem = GlobalAlloc(GHND, sizeof(ASSOCIATIONREG) * nTypeFace);
  109. if( hMem == NULL){
  110. ::ReleaseDC( hWnd, hDC);
  111. return FALSE;
  112. }
  113. lpAssociationReg = (LPASSOCIATIONREG)GlobalLock( hMem);
  114. lpAssociationRegTmp = lpAssociationReg;
  115. sts = EnumFontFamilies( hDC, NULL,
  116. (FONTENUMPROC)EnumFontFamProc, (LPARAM)aFontCount);
  117. ::ReleaseDC( hWnd, hDC);
  118. lpAssociationRegTmp = lpAssociationReg;
  119. for( int i = 0; i < nTypeFace; i++){
  120. sts = m_RegListBox.AddString(
  121. (LPCTSTR)lpAssociationRegTmp->szFaceName);
  122. m_RegListBox.SetItemData(sts, i);
  123. if( sts == LB_ERR || sts == LB_ERRSPACE){
  124. GlobalUnlock( hMem);
  125. GlobalFree( hMem);
  126. return FALSE;
  127. }
  128. if( !lstrcmp(lpAssociationRegTmp->szFaceName, SelectEUDC.m_Font)){
  129. StartIdx = i;
  130. }
  131. lpAssociationRegTmp++;
  132. }
  133. m_RegListBox.SetCurSel( StartIdx);
  134. return TRUE;
  135. }
  136. /****************************************/
  137. /* */
  138. /* Callback */
  139. /* */
  140. /****************************************/
  141. static int
  142. CALLBACK EnumFontNumber(
  143. ENUMLOGFONT FAR *lplf,
  144. NEWTEXTMETRIC FAR* lptm,
  145. int FontType,
  146. LPARAM lParam)
  147. {
  148. int sts;
  149. if( FontType == TRUETYPE_FONTTYPE){
  150. sts = CheckTTF( lplf->elfLogFont);
  151. if( sts == 1 && CheckCharSet( lplf->elfLogFont.lfCharSet)){
  152. nTypeFace++;
  153. }else if( sts == -1){
  154. return 0;
  155. }else ;
  156. }else if( FontType == 0x8 && lplf->elfLogFont.lfFaceName[0] != '@' &&
  157. CheckCharSet( lplf->elfLogFont.lfCharSet)){
  158. nTypeFace++;
  159. }
  160. return 1;
  161. }
  162. /****************************************/
  163. /* */
  164. /* Callback */
  165. /* */
  166. /****************************************/
  167. static int
  168. CALLBACK EnumFontFamProc(
  169. ENUMLOGFONT FAR *lplf,
  170. NEWTEXTMETRIC FAR* lptm,
  171. int FontType,
  172. LPARAM lParam)
  173. {
  174. LPASSOCIATIONREG lpAssociationRegTmp;
  175. TCHAR FileTitle[MAX_PATH];
  176. TCHAR *FilePtr;
  177. int sts;
  178. TCHAR FileSbstName[LF_FACESIZE];
  179. if( FontType == TRUETYPE_FONTTYPE){
  180. sts = CheckTTF( lplf->elfLogFont);
  181. if( sts == 1 && CheckCharSet( lplf->elfLogFont.lfCharSet)){
  182. FindFontSubstitute(lplf->elfLogFont.lfFaceName, FileSbstName);
  183. lpAssociationRegTmp = lpAssociationReg + nIdx;
  184. lstrcpy((TCHAR *)lpAssociationRegTmp->szFaceName,
  185. FileSbstName);
  186. if(!InqTypeFace(lpAssociationRegTmp->szFaceName,
  187. lpAssociationRegTmp->szFileName,
  188. sizeof( lpAssociationRegTmp->szFileName)/sizeof(TCHAR))){
  189. GetStringRes(
  190. (TCHAR *)lpAssociationRegTmp->szFileName,
  191. IDS_NOTSELECT_STR);
  192. lstrcpy( lpAssociationRegTmp->szFileTitle,
  193. lpAssociationRegTmp->szFileName);
  194. }else{
  195. lstrcpy(FileTitle,lpAssociationRegTmp->szFileName);
  196. if(( FilePtr=Mytcsrchr( FileTitle, '\\')) != NULL)
  197. FilePtr++;
  198. else{
  199. FilePtr = Mytcsrchr( FileTitle,':');
  200. if( FilePtr != NULL){
  201. FilePtr++;
  202. }else FilePtr = FileTitle;
  203. }
  204. lstrcpy(lpAssociationRegTmp->szFileTitle,
  205. FilePtr);
  206. }
  207. lpAssociationRegTmp->FontTypeFlg = TRUE;
  208. lpAssociationRegTmp->UpdateFlg = FALSE;
  209. nIdx++;
  210. }else if( sts == -1){
  211. return 0;
  212. }else ;
  213. }else if( FontType == 0x8 && lplf->elfLogFont.lfFaceName[0] != '@' &&
  214. CheckCharSet( lplf->elfLogFont.lfCharSet)){
  215. FindFontSubstitute(lplf->elfLogFont.lfFaceName, FileSbstName);
  216. lpAssociationRegTmp = lpAssociationReg + nIdx;
  217. lstrcpy((TCHAR *)lpAssociationRegTmp->szFaceName,
  218. FileSbstName);
  219. if( !InqTypeFace(lpAssociationRegTmp->szFaceName,
  220. lpAssociationRegTmp->szFileName,
  221. sizeof(lpAssociationRegTmp->szFileName)/sizeof(TCHAR))){
  222. GetStringRes((TCHAR *)lpAssociationRegTmp->szFileName,
  223. IDS_NOTSELECT_STR);
  224. lstrcpy(lpAssociationRegTmp->szFileTitle,
  225. lpAssociationRegTmp->szFileName);
  226. }else{
  227. lstrcpy(FileTitle,
  228. lpAssociationRegTmp->szFileName);
  229. if(( FilePtr=Mytcsrchr( FileTitle, '\\')) != NULL)
  230. FilePtr++;
  231. else{
  232. FilePtr = Mytcsrchr( FileTitle,':');
  233. if( FilePtr != NULL){
  234. FilePtr++;
  235. }else FilePtr = FileTitle;
  236. }
  237. lstrcpy(lpAssociationRegTmp->szFileTitle,
  238. FilePtr);
  239. }
  240. lpAssociationRegTmp->FontTypeFlg = FALSE;
  241. lpAssociationRegTmp->UpdateFlg = FALSE;
  242. nIdx++;
  243. }
  244. return 1;
  245. }
  246. /****************************************/
  247. /* */
  248. /* Check Character Set */
  249. /* */
  250. /****************************************/
  251. static BOOL
  252. CheckCharSet(
  253. int CharSet)
  254. {
  255. if( CountryInfo.CharacterSet != CharSet)
  256. return FALSE;
  257. else return TRUE;
  258. }
  259. /****************************************/
  260. /* */
  261. /* COMMAND "IDOK" */
  262. /* */
  263. /****************************************/
  264. void
  265. CAssocDlg::OnOK()
  266. {
  267. LPASSOCIATIONREG lpAssociationRegTmp;
  268. TCHAR FileList[MAX_PATH];
  269. TCHAR TTFPath[MAX_PATH];
  270. TCHAR BMPPath[MAX_PATH];
  271. TCHAR *FilePtr;
  272. int nIndex = m_RegListBox.GetCurSel();
  273. if( nIndex == -1){
  274. OutputMessageBox( this->GetSafeHwnd(),
  275. IDS_ASSOCIATE_DLGTITLE,
  276. IDS_NOTSELTYPEFACE_MSG, TRUE);
  277. m_RegListBox.SetFocus();
  278. return;
  279. }
  280. // The code is to fix the related bug #421829 & #438677
  281. // It delays 1 second to call EnabelEUDC(FALSE).
  282. DWORD dwStart = GetTickCount();
  283. // Stop if this has taken too long
  284. while (1)
  285. {
  286. if( GetTickCount() - dwStart >= 1000 )
  287. break;
  288. }
  289. EnableEUDC( FALSE);
  290. lpAssociationRegTmp = lpAssociationReg;
  291. GetStringRes( FileList, IDS_NOTSELECT_STR);
  292. nIndex = (int)m_RegListBox.GetItemData(nIndex);
  293. for( int i = 0; i < nTypeFace; i++)
  294. {
  295. if( i == nIndex)
  296. {
  297. //
  298. // Treat as an error, if the eudc font file name is not
  299. // specified, yet.
  300. //
  301. if( !lstrcmp((LPCTSTR)lpAssociationRegTmp->szFileName,FileList) &&
  302. (CheckFlg == DBCSCHK))
  303. {
  304. this->SendMessage(WM_COMMAND, IDC_MODIFY, NULL);
  305. if( !lstrcmp((LPCTSTR)lpAssociationRegTmp->szFileName,FileList))
  306. {
  307. m_RegListBox.SetFocus();
  308. EnableEUDC(TRUE);
  309. return;
  310. }
  311. }
  312. lstrcpy(SelectEUDC.m_Font, lpAssociationRegTmp->szFaceName);
  313. lstrcpy(SelectEUDC.m_File, lpAssociationRegTmp->szFileName);
  314. lstrcpy(SelectEUDC.m_FileTitle, lpAssociationRegTmp->szFileTitle);
  315. SelectEUDC.m_FontTypeFlg = lpAssociationRegTmp->FontTypeFlg;
  316. }
  317. if(!lstrcmp((LPCTSTR)lpAssociationRegTmp->szFileName,FileList)){
  318. if (lpAssociationRegTmp->UpdateFlg)
  319. DeleteReg(lpAssociationRegTmp->szFaceName);
  320. lpAssociationRegTmp++;
  321. continue;
  322. }
  323. lstrcpy( (LPTSTR)TTFPath, (LPCTSTR)lpAssociationRegTmp->szFileName);
  324. lstrcpy( BMPPath, TTFPath);
  325. if(( FilePtr = Mytcsrchr( BMPPath, '.')) != NULL)
  326. *FilePtr = '\0';
  327. lstrcat( BMPPath, TEXT(".EUF"));
  328. if( OExistTTF( TTFPath))
  329. {
  330. #if (WINVER >= 0x0500)
  331. if (IsWin95EUDCBmp(BMPPath))
  332. {
  333. if (!HandleImportWin95(TTFPath, BMPPath,nIndex ))
  334. {
  335. //#for fix of 408428 -- allow user to proceed to register fontlink
  336. //even if there's no correct euf
  337. // EnableEUDC( TRUE);
  338. // return;
  339. }
  340. }
  341. #endif
  342. }
  343. if( !lpAssociationRegTmp->UpdateFlg){
  344. lpAssociationRegTmp++;
  345. continue;
  346. }
  347. if( !RegistTypeFace(
  348. lpAssociationRegTmp->szFaceName,
  349. lpAssociationRegTmp->szFileName))
  350. {
  351. EnableEUDC( TRUE);
  352. return;
  353. }
  354. lpAssociationRegTmp++;
  355. }
  356. EnableEUDC( TRUE);
  357. if( CheckFlg != DBCSCHK){
  358. if (!InitSystemFontAssoc())
  359. {
  360. return;
  361. }
  362. }
  363. GlobalUnlock( hMem);
  364. GlobalFree( hMem);
  365. EndDialog(IDOK);
  366. }
  367. BOOL
  368. CAssocDlg::InitSystemFontAssoc()
  369. {
  370. TCHAR DefaultFace[LF_FACESIZE];
  371. TCHAR DefaultFile[MAX_PATH];
  372. TCHAR TTFPath[MAX_PATH];
  373. TCHAR BMPPath[MAX_PATH];
  374. TCHAR *FilePtr;
  375. GetStringRes(DefaultFace, IDS_SYSTEMEUDCFONT_STR);
  376. GetStringRes(DefaultFile, IDS_DEFAULTFILENAME);
  377. // if the registry data for SystemEUDC font is already there, just use that.
  378. if (!InqTypeFace(DefaultFace,TTFPath,MAX_PATH)) {
  379. GetSystemWindowsDirectory( TTFPath, MAX_PATH);
  380. #ifdef IN_FONTS_DIR // CAssocDlg::OnOK()
  381. lstrcat( TTFPath, TEXT("\\FONTS\\"));
  382. #else
  383. lstrcat( TTFPath, TEXT("\\"));
  384. #endif // IN_FONTS_DIR
  385. lstrcat( TTFPath, DefaultFile);
  386. }
  387. lstrcpy( BMPPath, TTFPath);
  388. if(( FilePtr = Mytcsrchr( BMPPath, '.')) != NULL)
  389. *FilePtr = '\0';
  390. lstrcat( BMPPath, TEXT(".EUF"));
  391. // The code is to fix the related bug #421829 & #438677
  392. // It delays 1 second to call EnabelEUDC(FALSE).
  393. DWORD dwStart = GetTickCount();
  394. // Stop if this has taken too long
  395. while (1)
  396. {
  397. if( GetTickCount() - dwStart >= 1000 )
  398. break;
  399. }
  400. EnableEUDC( FALSE);
  401. if(OExistTTF( TTFPath))
  402. {
  403. #if (WINVER >= 0x0500)
  404. if (IsWin95EUDCBmp(BMPPath))
  405. {
  406. if (!HandleImportWin95(TTFPath, BMPPath, -1))
  407. {
  408. EnableEUDC( TRUE);
  409. return FALSE;
  410. }
  411. }
  412. #endif
  413. }
  414. SelectEUDC.m_FontTypeFlg = TRUE;
  415. lstrcpy(SelectEUDC.m_Font,(const TCHAR *)DefaultFace);
  416. lstrcpy(SelectEUDC.m_File,(const TCHAR *)TTFPath);
  417. lstrcpy(SelectEUDC.m_FileTitle,(const TCHAR *)DefaultFile);
  418. if( !RegistTypeFace(DefaultFace, TTFPath)){
  419. EnableEUDC( TRUE);
  420. return FALSE;
  421. }
  422. EnableEUDC( TRUE);
  423. return TRUE;
  424. }
  425. /****************************************/
  426. /* */
  427. /* MESSAGE "WM_DBLCLKS" */
  428. /* */
  429. /****************************************/
  430. void
  431. CAssocDlg::OnDblclkRegistlist()
  432. {
  433. this->SendMessage(WM_COMMAND, IDC_MODIFY, 0);
  434. }
  435. /****************************************/
  436. /* */
  437. /* COMMAND "IDCANCEL" */
  438. /* */
  439. /****************************************/
  440. void
  441. CAssocDlg::OnCancel()
  442. {
  443. GlobalUnlock( hMem);
  444. GlobalFree( hMem);
  445. EndDialog( IDCANCEL);
  446. }
  447. /****************************************/
  448. /* */
  449. /* COMMAND "Modify" */
  450. /* */
  451. /****************************************/
  452. void
  453. CAssocDlg::OnModify()
  454. {
  455. LPASSOCIATIONREG lpAssociationRegTmp;
  456. OPENFILENAME ofn;
  457. CString sFilter;
  458. CWnd *cWnd;
  459. TCHAR chReplace;
  460. CString szDlgTtl;
  461. TCHAR szFilter[MAX_PATH];
  462. TCHAR szFileName[MAX_PATH];
  463. TCHAR szTitleName[MAX_PATH];
  464. TCHAR szDirName[MAX_PATH];
  465. int nIndex = m_RegListBox.GetCurSel();
  466. if( nIndex == -1){
  467. OutputMessageBox( this->GetSafeHwnd(),
  468. IDS_ASSOCIATE_DLGTITLE,
  469. IDS_NOTSELTYPEFACE_MSG, TRUE);
  470. m_RegListBox.SetFocus();
  471. return;
  472. }
  473. //lpAssociationRegTmp = lpAssociationReg + nIndex;
  474. lpAssociationRegTmp = lpAssociationReg + m_RegListBox.GetItemData(nIndex);
  475. // Set filter of file( from string table)
  476. GetStringRes(szFilter, IDS_EUDCTTF_FILTER);
  477. int StringLength = lstrlen( szFilter);
  478. chReplace = szFilter[StringLength-1];
  479. for( int i = 0; szFilter[i]; i++){
  480. if( szFilter[i] == chReplace)
  481. szFilter[i] = '\0';
  482. }
  483. GetSystemWindowsDirectory( szDirName, sizeof(szDirName)/sizeof(TCHAR));
  484. #ifdef IN_FONTS_DIR // CAssocDlg::OnModify()
  485. lstrcat( szDirName, TEXT("\\FONTS\\"));
  486. #endif // IN_FONTS_DIR
  487. lstrcpy( szFileName, TEXT("*.TTE"));
  488. szDlgTtl.LoadString( IDS_MODIFY_DLGTITLE);
  489. // Set data in structure of OPENFILENAME
  490. ofn.lStructSize = sizeof( OPENFILENAME);
  491. ofn.hInstance = AfxGetInstanceHandle();
  492. ofn.hwndOwner = this->GetSafeHwnd();
  493. ofn.lpstrFilter = szFilter;
  494. ofn.lpstrCustomFilter = NULL;
  495. ofn.nMaxCustFilter = 0;
  496. ofn.nFilterIndex = 0;
  497. ofn.lpstrFile = szFileName;
  498. ofn.lpstrFileTitle = szTitleName;
  499. ofn.nMaxFileTitle = sizeof( szTitleName) / sizeof(TCHAR);
  500. ofn.nMaxFile = sizeof( szFileName) / sizeof(TCHAR);
  501. ofn.lpstrInitialDir = szDirName;
  502. ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR
  503. | OFN_PATHMUSTEXIST ;
  504. // there's no direct overwrite issue here, the file will be re-cycled.
  505. //| OFN_OVERWRITEPROMPT;
  506. ofn.lpstrDefExt = TEXT("tte");
  507. ofn.lpstrTitle = szDlgTtl;
  508. if( !GetSaveFileName( &ofn)){
  509. return;
  510. }
  511. TCHAR tmpName[MAX_PATH];
  512. lstrcpy(tmpName, szDirName);
  513. lstrcat(tmpName, TEXT("eudc.tte"));
  514. if( !lstrcmpi(ofn.lpstrFile, tmpName) ) {
  515. OutputMessageBox( this->GetSafeHwnd(),
  516. IDS_MODIFY_DLGTITLE,
  517. IDS_NOUSEEUDCFILE_MSG, TRUE);
  518. return;
  519. }
  520. if( !CheckFileName( ofn.lpstrFile)){
  521. OutputMessageBox( this->GetSafeHwnd(),
  522. IDS_MODIFY_DLGTITLE,
  523. IDS_ILLEGALFILE_MSG, TRUE);
  524. return;
  525. }
  526. if( OExistTTF( ofn.lpstrFile)){
  527. if( !IsEUDCTTF( ofn.lpstrFile)){
  528. OutputMessageBox( this->GetSafeHwnd(),
  529. IDS_MODIFY_DLGTITLE,
  530. IDS_NOTEUDCFILE_MSG, TRUE);
  531. return;
  532. }
  533. }
  534. lstrcpy(lpAssociationRegTmp->szFileName, ofn.lpstrFile);
  535. lstrcpy(lpAssociationRegTmp->szFileTitle,
  536. ofn.lpstrFileTitle);
  537. lpAssociationRegTmp->UpdateFlg = TRUE;
  538. m_RegListBox.InsertString( nIndex,
  539. (LPCTSTR)lpAssociationRegTmp->szFaceName);
  540. m_RegListBox.SetItemData(nIndex, m_RegListBox.GetItemData(nIndex+1));
  541. m_RegListBox.DeleteString( nIndex + 1);
  542. m_RegListBox.SetCurSel( nIndex);
  543. cWnd = GetDlgItem( IDC_REGISTLIST);
  544. GotoDlgCtrl( cWnd);
  545. }
  546. /****************************************/
  547. /* */
  548. /* COMMAND "Remove" */
  549. /* */
  550. /****************************************/
  551. void
  552. CAssocDlg::OnRemove()
  553. {
  554. LPASSOCIATIONREG lpAssociationRegTmp;
  555. TCHAR Tmp[MAX_PATH];
  556. int nIndex = m_RegListBox.GetCurSel();
  557. if( nIndex == -1){
  558. OutputMessageBox( this->GetSafeHwnd(),
  559. IDS_ASSOCIATE_DLGTITLE,
  560. IDS_NOTSELTYPEFACE_MSG, TRUE);
  561. m_RegListBox.SetFocus();
  562. return;
  563. }
  564. GetStringRes( Tmp, IDS_NOTSELECT_STR);
  565. //lpAssociationRegTmp = lpAssociationReg + nIndex;
  566. lpAssociationRegTmp = lpAssociationReg + m_RegListBox.GetItemData(nIndex);
  567. lstrcpy(lpAssociationRegTmp->szFileName, (const TCHAR *)Tmp);
  568. lstrcpy(lpAssociationRegTmp->szFileTitle, (const TCHAR *)Tmp);
  569. lpAssociationRegTmp->UpdateFlg = TRUE;
  570. m_RegListBox.InsertString( nIndex,
  571. lpAssociationRegTmp->szFaceName);
  572. m_RegListBox.SetItemData(nIndex, m_RegListBox.GetItemData(nIndex+1));
  573. m_RegListBox.DeleteString( nIndex + 1);
  574. m_RegListBox.SetCurSel( nIndex);
  575. // DeleteReg(lpAssociationRegTmp->szFaceName);
  576. CWnd *cWnd = GetDlgItem( IDC_REGISTLIST);
  577. GotoDlgCtrl( cWnd);
  578. }
  579. /****************************************/
  580. /* */
  581. /* Check .TTF */
  582. /* */
  583. /****************************************/
  584. static int
  585. CheckTTF(
  586. LOGFONT LogFont)
  587. {
  588. struct NamingTable *Ntbl;
  589. struct NameRecord *NameRec;
  590. HGLOBAL hglb;
  591. DWORD dwSize = 0L;
  592. DWORD dwTable = 0L;
  593. LPSTR lpBuffer, lpTable;
  594. HFONT hFont = NULL;
  595. HGDIOBJ OldFont = NULL;
  596. short nRec = 0;
  597. int sysLCID;
  598. // Check "tategaki" or not
  599. if( LogFont.lfFaceName[0] == '@')
  600. return 0;
  601. // Get current font to Inquire ttf file
  602. hFont = ::CreateFontIndirect( &LogFont);
  603. if( hFont ) {
  604. OldFont = ::SelectObject( hDC, hFont);
  605. }
  606. // Get name table in ttf file
  607. lpTable = "name";
  608. dwTable = *(LPDWORD)lpTable;
  609. dwSize = ::GetFontData( hDC, dwTable, 0L, NULL, 0L);
  610. if( dwSize == GDI_ERROR){
  611. if( OldFont ) ::SelectObject(hDC, OldFont);
  612. if( hFont ) ::DeleteObject(hFont);
  613. return 0;
  614. }
  615. hglb = GlobalAlloc( GHND, dwSize);
  616. if( hglb == NULL){
  617. if( OldFont ) ::SelectObject(hDC, OldFont);
  618. if( hFont ) ::DeleteObject(hFont);
  619. return -1;
  620. }
  621. lpBuffer = (LPSTR)GlobalLock( hglb);
  622. ::GetFontData( hDC, dwTable, 0L, (LPVOID)lpBuffer, dwSize);
  623. if( OldFont ) ::SelectObject(hDC, OldFont);
  624. if( hFont ) ::DeleteObject(hFont);
  625. Ntbl = (struct NamingTable *)lpBuffer;
  626. sitom( &Ntbl->NRecs);
  627. nRec = Ntbl->NRecs;
  628. lpBuffer += sizeof(struct NamingTable);
  629. sysLCID = (int) LANGIDFROMLCID(GetSystemDefaultLCID());
  630. while( nRec-- > 0){
  631. NameRec = (struct NameRecord *)lpBuffer;
  632. sitom( &NameRec->PlatformID);
  633. sitom( &NameRec->PlatformSpecEncID);
  634. sitom( &NameRec->LanguageID);
  635. #ifdef BUILD_ON_WINNT
  636. // Unicode TTF
  637. if( CountryInfo.bUnicodeMode ){
  638. // if( NameRec->PlatformID == 3 &&
  639. // NameRec->LanguageID == sysLCID){
  640. GlobalUnlock( hglb);
  641. GlobalFree( hglb);
  642. return 1;
  643. // }
  644. }
  645. #endif //BUILD_ON_WINNT
  646. // Japanese TTF
  647. if( CountryInfo.LangID == EUDC_JPN){
  648. if( NameRec->PlatformID == 3 &&
  649. NameRec->LanguageID == EUDC_JPN){
  650. GlobalUnlock( hglb);
  651. GlobalFree( hglb);
  652. return 1;
  653. }
  654. }
  655. // Chinese Taipei TTF
  656. if( CountryInfo.LangID == EUDC_CHT){
  657. if( NameRec->PlatformID == 3 &&
  658. NameRec->LanguageID == EUDC_CHT){
  659. GlobalUnlock( hglb);
  660. GlobalFree( hglb);
  661. return 1;
  662. }
  663. }
  664. // Chinese GB TTF
  665. if( CountryInfo.LangID == EUDC_CHS){
  666. if( NameRec->PlatformID == 3 &&
  667. NameRec->LanguageID == EUDC_CHS){
  668. GlobalUnlock( hglb);
  669. GlobalFree( hglb);
  670. return 1;
  671. }
  672. }
  673. // Korea TTF(WANSUNG)
  674. if( CountryInfo.LangID == EUDC_KRW){
  675. if( NameRec->PlatformID == 3 &&
  676. NameRec->LanguageID == EUDC_KRW){
  677. GlobalUnlock( hglb);
  678. GlobalFree( hglb);
  679. return 1;
  680. }
  681. }
  682. /*
  683. // Hebrew TTF
  684. if( CountryInfo.LangID == EUDC_HEBREW) {
  685. if( NameRec->PlatformID == 1 &&
  686. NameRec->LanguageID == 0 ) {
  687. GlobalUnlock( hglb);
  688. GlobalFree( hglb);
  689. return 1;
  690. }
  691. }
  692. */
  693. lpBuffer += sizeof(struct NameRecord);
  694. }
  695. GlobalUnlock( hglb);
  696. GlobalFree( hglb);
  697. return 0;
  698. }
  699. /****************************************/
  700. /* */
  701. /* Radio DBCS Clicked */
  702. /* */
  703. /****************************************/
  704. void
  705. CAssocDlg::OnRadioDbcs()
  706. {
  707. CWnd *cWnd;
  708. if( CheckFlg != DBCSCHK){
  709. CheckFlg = DBCSCHK;
  710. m_RegListBox.EnableWindow( TRUE);
  711. m_RegListBox.EnableScrollBar( SB_VERT, ESB_ENABLE_BOTH);
  712. m_RegListBox.UpdateWindow();
  713. cWnd = this->GetDlgItem( IDC_MODIFY);
  714. cWnd->EnableWindow( TRUE);
  715. cWnd = this->GetDlgItem( IDC_REMOVE);
  716. cWnd->EnableWindow( TRUE);
  717. }
  718. }
  719. /****************************************/
  720. /* */
  721. /* Radio SYSTEM Clicked */
  722. /* */
  723. /****************************************/
  724. void
  725. CAssocDlg::OnRadioSystem()
  726. {
  727. CWnd *cWnd;
  728. if( CheckFlg != EUDCCHK){
  729. CheckFlg = EUDCCHK;
  730. m_RegListBox.EnableWindow( FALSE);
  731. m_RegListBox.EnableScrollBar( SB_VERT, ESB_DISABLE_BOTH);
  732. cWnd = this->GetDlgItem( IDC_MODIFY);
  733. cWnd->EnableWindow( FALSE);
  734. cWnd = this->GetDlgItem( IDC_REMOVE);
  735. cWnd->EnableWindow( FALSE);
  736. }
  737. }
  738. /****************************************/
  739. /* */
  740. /* Inquire into file( EUDC or not) */
  741. /* */
  742. /****************************************/
  743. static BOOL
  744. IsEUDCTTF(
  745. TCHAR *ttffile)
  746. {
  747. struct NamingTable *nTbl;
  748. struct NameRecord *nRec;
  749. unsigned int BufSiz;
  750. char *TableBuf, *SearchOfs;
  751. char TTFName[MAX_CODE];
  752. HANDLE fHdl = CreateFile(ttffile,
  753. GENERIC_READ,
  754. FILE_SHARE_READ | FILE_SHARE_WRITE,
  755. NULL,
  756. OPEN_EXISTING,
  757. FILE_ATTRIBUTE_NORMAL,
  758. NULL);
  759. if ( fHdl == INVALID_HANDLE_VALUE)
  760. return FALSE;
  761. if( TTFReadVarTable( fHdl, &TableBuf, &BufSiz, "name")){
  762. CloseHandle( fHdl);
  763. return FALSE;
  764. }
  765. SearchOfs = TableBuf;
  766. nTbl = (struct NamingTable *)TableBuf;
  767. sitom( &nTbl->OfsToStr);
  768. SearchOfs += sizeof(struct NamingTable);
  769. SearchOfs += sizeof(struct NameRecord);
  770. nRec = (struct NameRecord *)SearchOfs;
  771. sitom( &nRec->StringOfs);
  772. SearchOfs = TableBuf + nTbl->OfsToStr + nRec->StringOfs;
  773. SearchOfs += sizeof(char);
  774. for( short Inc = 0; Inc < MAX_CODE - 1; Inc++){
  775. TTFName[Inc] = (char)*SearchOfs;
  776. SearchOfs += sizeof(char)*2;
  777. }
  778. TTFName[Inc] = '\0';
  779. if( lstrcmpA( TTFName, "EUDC") == 0){
  780. free( TableBuf);
  781. CloseHandle( fHdl);
  782. return TRUE;
  783. }
  784. free( TableBuf);
  785. CloseHandle( fHdl);
  786. return FALSE;
  787. }
  788. /****************************************/
  789. /* */
  790. /* Inquire into filename */
  791. /* */
  792. /****************************************/
  793. static BOOL
  794. CheckFileName(
  795. LPTSTR FileStr)
  796. {
  797. TCHAR FileTmp[MAX_PATH];
  798. TCHAR Tmp[MAX_PATH];
  799. TCHAR *FilePtr;
  800. FilePtr = FileStr;
  801. while( *FilePtr == ' ')
  802. FilePtr++;
  803. if( *FilePtr == '.' || *FilePtr == '\0')
  804. return FALSE;
  805. int i = 0;
  806. while( *FilePtr != '\0'){
  807. FileTmp[i] = *FilePtr;
  808. FilePtr++;
  809. i++;
  810. }
  811. FileTmp[i] = '\0';
  812. if(( FilePtr = Mytcsrchr( FileTmp, '.')) == NULL)
  813. lstrcat( FileTmp, TEXT(".tte"));
  814. else{
  815. #ifdef BUILD_ON_WINNT
  816. if( lstrcmpi( FilePtr, TEXT(".TTE")))
  817. #else
  818. if( stricmp( FilePtr, ".TTE"))
  819. #endif // BUILD_ON_WINNT
  820. return FALSE;
  821. }
  822. lstrcpy(Tmp, FileTmp);
  823. if( lstrlen(Tmp) >= MAX_PATH)
  824. return FALSE;
  825. lstrcpy( FileStr, FileTmp);
  826. return TRUE;
  827. }
  828. static DWORD aIds[] =
  829. {
  830. IDC_MODIFY, IDH_EUDC_MODIFY,
  831. IDC_REMOVE, IDH_EUDC_REMOVE,
  832. IDC_REGISTLIST, IDH_EUDC_ASSO_LIST,
  833. IDC_RADIO_SYSTEM, IDH_EUDC_ASSO_STANDARD,
  834. IDC_RADIO_DBCS, IDH_EUDC_ASSO_TYPEFACE,
  835. 0,0
  836. };
  837. /****************************************/
  838. /* */
  839. /* Window Procedure */
  840. /* */
  841. /****************************************/
  842. LRESULT
  843. CAssocDlg::WindowProc(
  844. UINT message,
  845. WPARAM wParam,
  846. LPARAM lParam)
  847. {
  848. if( message == WM_HELP){
  849. ::WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle,
  850. HelpPath, HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  851. return(0);
  852. }
  853. if( message == WM_CONTEXTMENU){
  854. ::WinHelp((HWND)wParam, HelpPath,
  855. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)aIds);
  856. return(0);
  857. }
  858. return CDialog::WindowProc(message, wParam, lParam);
  859. }
  860. BEGIN_MESSAGE_MAP(CAssocDlg, CDialog)
  861. //{{AFX_MSG_MAP(CAssocDlg)
  862. ON_LBN_DBLCLK(IDC_REGISTLIST, OnDblclkRegistlist)
  863. ON_BN_CLICKED(IDC_MODIFY, OnModify)
  864. ON_BN_CLICKED(IDC_REMOVE, OnRemove)
  865. ON_BN_CLICKED(IDC_RADIO_DBCS, OnRadioDbcs)
  866. ON_BN_CLICKED(IDC_RADIO_SYSTEM, OnRadioSystem)
  867. //}}AFX_MSG_MAP
  868. END_MESSAGE_MAP()
  869. /****************************************/
  870. /* */
  871. /* MeasureItem */
  872. /* */
  873. /****************************************/
  874. void
  875. CRegistListBox::MeasureItem(
  876. LPMEASUREITEMSTRUCT lpMIS)
  877. {
  878. CRect ListBoxRect;
  879. this->GetClientRect( &ListBoxRect);
  880. ItemHeight = ListBoxRect.Height() /NUMITEM;
  881. lpMIS->itemHeight = ItemHeight;
  882. }
  883. /****************************************/
  884. /* */
  885. /* Draw Item */
  886. /* */
  887. /****************************************/
  888. void
  889. CRegistListBox::DrawItem(
  890. LPDRAWITEMSTRUCT lpDIS)
  891. {
  892. LPASSOCIATIONREG lpAssociationRegTmp;
  893. LOGFONT LogFont;
  894. CSize CharSize, FontSize, cSize;
  895. TCHAR FileTmp[MAX_PATH], NotSel[MAX_PATH];
  896. int Offset;
  897. CDC* pDC = CDC::FromHandle( lpDIS->hDC);
  898. if( lpDIS->itemAction & ODA_DRAWENTIRE){
  899. CBrush fBrush;
  900. fBrush.CreateSolidBrush(GetSysColor(COLOR_WINDOW)); // COLOR_WIN);
  901. pDC->FillRect( &lpDIS->rcItem, &fBrush);
  902. fBrush.DeleteObject();
  903. pDC->SetBkColor( GetSysColor(COLOR_WINDOW)); //COLOR_WIN);
  904. //lpAssociationRegTmp = lpAssociationReg + lpDIS->itemID;
  905. lpAssociationRegTmp = lpAssociationReg + lpDIS->itemData;
  906. if( CheckFlg == DBCSCHK)
  907. pDC->SetTextColor( GetSysColor(COLOR_WINDOWTEXT)); //COLOR_BLACK);
  908. else pDC->SetTextColor( GetSysColor(COLOR_GRAYTEXT)); //COLOR_SHADOW);
  909. GetFont()->GetObject( sizeof(LOGFONT), &LogFont);
  910. if( abs( LogFont.lfHeight) < ItemHeight)
  911. Offset = ( ItemHeight - abs( LogFont.lfHeight)) /2;
  912. else Offset = 0;
  913. if( lpAssociationRegTmp->FontTypeFlg){
  914. pDC->DrawIcon( lpDIS->rcItem.left + LSPACE,
  915. lpDIS->rcItem.top + Offset, tIcon);
  916. }
  917. lstrcpy(FileTmp,
  918. (const TCHAR *)lpAssociationRegTmp->szFileTitle);
  919. GetStringRes( NotSel, IDS_NOTSELECT_STR);
  920. if( FileTmp[0] == '\0' ||
  921. !lstrcmp((const TCHAR *)FileTmp,(const TCHAR *)NotSel)){
  922. }else{
  923. TCHAR *FilePtr;
  924. if(( FilePtr = Mytcsrchr( FileTmp, '.')) != NULL)
  925. *FilePtr = '\0';
  926. if( lstrlen((const TCHAR *)FileTmp) > 20){
  927. FileTmp[20] = '\0';
  928. lstrcat((TCHAR *)FileTmp, TEXT(".."));
  929. }
  930. }
  931. GetTextExtentPoint32( pDC->GetSafeHdc(),
  932. (const TCHAR *)FileTmp,
  933. lstrlen((const TCHAR *)FileTmp), &CharSize);
  934. pDC->ExtTextOut( lpDIS->rcItem.right - CharSize.cx - RSPACE,
  935. lpDIS->rcItem.top + Offset, 0, 0,
  936. (const TCHAR *)FileTmp,
  937. lstrlen((const TCHAR *)FileTmp), NULL);
  938. int FontWidth;
  939. lstrcpy(FontName,
  940. (const TCHAR *)lpAssociationRegTmp->szFaceName);
  941. FontWidth = lpDIS->rcItem.right - lpDIS->rcItem.left
  942. - LCSPACE - RSPACE - CharSize.cx;
  943. GetTextExtentPoint32( pDC->GetSafeHdc(),
  944. (const TCHAR *)FontName,
  945. lstrlen((const TCHAR *)FontName), &FontSize);
  946. if( FontWidth <= FontSize.cx){
  947. int i;
  948. GetTextExtentPoint32( pDC->GetSafeHdc(),TEXT("<<"),2, &cSize);
  949. i = ( FontWidth /cSize.cx) * 2;
  950. FontName[i-2] = '.';
  951. FontName[i-1] = '.';
  952. FontName[i] = '\0';
  953. }
  954. pDC->ExtTextOut(lpDIS->rcItem.left + LCSPACE,
  955. lpDIS->rcItem.top + Offset, 0, 0,
  956. FontName,
  957. lstrlen(FontName), NULL);
  958. }
  959. if(( lpDIS->itemState & ODS_SELECTED) &&
  960. ( lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))){
  961. CBrush fBrush;
  962. if( CheckFlg == DBCSCHK)
  963. fBrush.CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
  964. else fBrush.CreateSolidBrush(GetSysColor(COLOR_WINDOW)); // COLOR_WIN);
  965. pDC->FillRect( &lpDIS->rcItem, &fBrush);
  966. fBrush.DeleteObject();
  967. //lpAssociationRegTmp = lpAssociationReg + lpDIS->itemID;
  968. lpAssociationRegTmp = lpAssociationReg + lpDIS->itemData;
  969. if( CheckFlg == DBCSCHK){
  970. pDC->SetBkColor(::GetSysColor( COLOR_HIGHLIGHT));
  971. pDC->SetTextColor(::GetSysColor( COLOR_HIGHLIGHTTEXT));
  972. }else{
  973. pDC->SetBkColor(GetSysColor(COLOR_WINDOW)); // COLOR_WIN);
  974. pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT)); // COLOR_SHADOW);
  975. }
  976. GetFont()->GetObject( sizeof(LOGFONT), &LogFont);
  977. if( abs( LogFont.lfHeight) < ItemHeight)
  978. Offset = ( ItemHeight - abs( LogFont.lfHeight)) /2;
  979. else Offset = 0;
  980. if( lpAssociationRegTmp->FontTypeFlg){
  981. pDC->DrawIcon( lpDIS->rcItem.left + LSPACE,
  982. lpDIS->rcItem.top + Offset, tIcon);
  983. }
  984. lstrcpy(FileTmp,
  985. lpAssociationRegTmp->szFileTitle);
  986. GetStringRes( NotSel, IDS_NOTSELECT_STR);
  987. if( FileTmp[0] == '\0' ||
  988. !lstrcmp(FileTmp,NotSel)){
  989. }else{
  990. TCHAR *FilePtr;
  991. if(( FilePtr = Mytcsrchr( FileTmp, '.')) != NULL)
  992. *FilePtr = '\0';
  993. if( lstrlen(FileTmp) > 20){
  994. FileTmp[20] = '\0';
  995. lstrcat(FileTmp, TEXT(".."));
  996. }
  997. }
  998. GetTextExtentPoint32( pDC->GetSafeHdc(),
  999. FileTmp,
  1000. lstrlen(FileTmp), &CharSize);
  1001. pDC->ExtTextOut( lpDIS->rcItem.right - CharSize.cx - RSPACE,
  1002. lpDIS->rcItem.top + Offset, 0, 0,
  1003. FileTmp,
  1004. lstrlen(FileTmp), NULL);
  1005. int FontWidth;
  1006. lstrcpy(FontName,
  1007. lpAssociationRegTmp->szFaceName);
  1008. FontWidth = lpDIS->rcItem.right - lpDIS->rcItem.left
  1009. - LCSPACE - RSPACE - CharSize.cx;
  1010. GetTextExtentPoint32( pDC->GetSafeHdc(),
  1011. FontName,
  1012. lstrlen(FontName), &FontSize);
  1013. if( FontWidth <= FontSize.cx){
  1014. int i;
  1015. GetTextExtentPoint32( pDC->GetSafeHdc(),TEXT("<<"),2, &cSize);
  1016. i = ( FontWidth /cSize.cx) * 2;
  1017. FontName[i-2] = '.';
  1018. FontName[i-1] = '.';
  1019. FontName[i] = '\0';
  1020. }
  1021. pDC->ExtTextOut( lpDIS->rcItem.left + LCSPACE,
  1022. lpDIS->rcItem.top + Offset, 0, 0,
  1023. FontName,
  1024. lstrlen(FontName), NULL);
  1025. }
  1026. if( !(lpDIS->itemState & ODS_SELECTED) &&
  1027. ( lpDIS->itemAction & ODA_SELECT)){
  1028. CBrush fBrush;
  1029. fBrush.CreateSolidBrush(GetSysColor(COLOR_WINDOW)); // COLOR_WIN);
  1030. pDC->FillRect( &lpDIS->rcItem, &fBrush);
  1031. fBrush.DeleteObject();
  1032. //lpAssociationRegTmp = lpAssociationReg + lpDIS->itemID;
  1033. lpAssociationRegTmp = lpAssociationReg + lpDIS->itemData;
  1034. pDC->SetBkColor(GetSysColor(COLOR_WINDOW)); // COLOR_WIN);
  1035. if( CheckFlg == DBCSCHK)
  1036. pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); // COLOR_BLACK);
  1037. else pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT)); // COLOR_SHADOW);
  1038. GetFont()->GetObject( sizeof(LOGFONT), &LogFont);
  1039. if( abs( LogFont.lfHeight) < ItemHeight)
  1040. Offset = ( ItemHeight - abs( LogFont.lfHeight)) /2;
  1041. else Offset = 0;
  1042. if( lpAssociationRegTmp->FontTypeFlg){
  1043. pDC->DrawIcon( lpDIS->rcItem.left + LSPACE,
  1044. lpDIS->rcItem.top + Offset, tIcon);
  1045. }
  1046. lstrcpy( FileTmp,
  1047. lpAssociationRegTmp->szFileTitle);
  1048. GetStringRes( NotSel, IDS_NOTSELECT_STR);
  1049. if( FileTmp[0] == '\0' ||
  1050. !lstrcmp(FileTmp,NotSel)){
  1051. }else{
  1052. TCHAR *FilePtr;
  1053. if(( FilePtr = Mytcsrchr( FileTmp, '.')) != NULL)
  1054. *FilePtr = '\0';
  1055. if( lstrlen(FileTmp) > 20){
  1056. FileTmp[20] = '\0';
  1057. lstrcat(FileTmp, TEXT(".."));
  1058. }
  1059. }
  1060. GetTextExtentPoint32( pDC->GetSafeHdc(),
  1061. FileTmp,
  1062. lstrlen(FileTmp), &CharSize);
  1063. pDC->ExtTextOut( lpDIS->rcItem.right - CharSize.cx - RSPACE,
  1064. lpDIS->rcItem.top + Offset, 0, 0,
  1065. FileTmp,
  1066. lstrlen(FileTmp), NULL);
  1067. int FontWidth;
  1068. lstrcpy(FontName,
  1069. lpAssociationRegTmp->szFaceName);
  1070. FontWidth = lpDIS->rcItem.right - lpDIS->rcItem.left
  1071. - LCSPACE - RSPACE - CharSize.cx;
  1072. GetTextExtentPoint32( pDC->GetSafeHdc(),
  1073. FontName,
  1074. lstrlen(FontName), &FontSize);
  1075. if( FontWidth <= FontSize.cx){
  1076. int i;
  1077. GetTextExtentPoint32( pDC->GetSafeHdc(),TEXT("<<"),2, &cSize);
  1078. i = ( FontWidth /cSize.cx) * 2;
  1079. FontName[i-2] = '.';
  1080. FontName[i-1] = '.';
  1081. FontName[i] = '\0';
  1082. }
  1083. pDC->ExtTextOut( lpDIS->rcItem.left + LCSPACE,
  1084. lpDIS->rcItem.top + Offset, 0, 0,
  1085. FontName,
  1086. lstrlen(FontName), NULL);
  1087. }
  1088. }
  1089. int CRegistListBox::CompareItem(LPCOMPAREITEMSTRUCT lpCIS)
  1090. {
  1091. TCHAR TmpFontName1[LF_FACESIZE], TmpFontName2[LF_FACESIZE];
  1092. LPASSOCIATIONREG lpAssociationRegTmp1,lpAssociationRegTmp2;
  1093. lpAssociationRegTmp1 = lpAssociationReg + lpCIS->itemData1;
  1094. lpAssociationRegTmp2 = (LPASSOCIATIONREG) (lpCIS->itemData2);
  1095. lstrcpy(TmpFontName1, lpAssociationRegTmp1->szFaceName);
  1096. lstrcpy(TmpFontName2, lpAssociationRegTmp2->szFaceName);
  1097. return (lstrcmp(TmpFontName1, TmpFontName2));
  1098. }
  1099. BOOL CAssocDlg::HandleImportWin95(
  1100. LPTSTR TTFPath,
  1101. LPTSTR BMPPath,
  1102. int Idx)
  1103. {
  1104. TCHAR UserFont[MAX_PATH];
  1105. LPTSTR FilePtr;
  1106. TCHAR szTmpDir[MAX_PATH];
  1107. GetTempPath(MAX_PATH, szTmpDir);
  1108. if (!GetTempFileName(szTmpDir, TEXT("EUF"), 0, UserFont))
  1109. {
  1110. lstrcpy(UserFont, BMPPath);
  1111. if(( FilePtr = Mytcsrchr( UserFont, '\\')) != NULL)
  1112. *FilePtr = '\0';
  1113. lstrcpy(UserFont, TEXT("EUF.tmp"));
  1114. }
  1115. if (!MoveFileEx(BMPPath, UserFont, MOVEFILE_REPLACE_EXISTING))
  1116. {
  1117. return FALSE;
  1118. }
  1119. CGageDlg dlg(this, UserFont, BMPPath, TTFPath, TRUE);
  1120. dlg.DoModal();
  1121. return TRUE;
  1122. }