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.

312 lines
8.0 KiB

  1. /**************************************************/
  2. /* */
  3. /* */
  4. /* Convert from bmp to ttf */
  5. /* (Dialogbox) */
  6. /* */
  7. /* */
  8. /* Copyright (c) 1997-1999 Microsoft Corporation. */
  9. /**************************************************/
  10. #include "stdafx.h"
  11. #include "eudcedit.h"
  12. #include "imprtdlg.h"
  13. #include "ttfstruc.h"
  14. #include "extfunc.h"
  15. #include "util.h"
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char BASED_CODE THIS_FILE[] = __FILE__;
  19. #endif
  20. TCHAR UserFont[MAX_PATH];
  21. TCHAR EUDCTTF[MAX_PATH];
  22. TCHAR EUDCBMP[MAX_PATH];
  23. /****************************************/
  24. /* */
  25. /* Default Constructor */
  26. /* */
  27. /****************************************/
  28. CImportDlg::CImportDlg( CWnd* pParent)
  29. : CDialog(CImportDlg::IDD, pParent)
  30. {
  31. //{{AFX_DATA_INIT(CImportDlg)
  32. //}}AFX_DATA_INIT
  33. }
  34. /****************************************/
  35. /* */
  36. /* MESSAGE "WM_INITDIALOG" */
  37. /* */
  38. /****************************************/
  39. BOOL
  40. CImportDlg::OnInitDialog()
  41. {
  42. CString DlgTitle;
  43. CDialog::OnInitDialog();
  44. // Implement "?" in this dialogbox.
  45. // LONG WindowStyle = GetWindowLong( this->GetSafeHwnd(), GWL_EXSTYLE);
  46. // WindowStyle |= WS_EX_CONTEXTHELP;
  47. // SetWindowLong( this->GetSafeHwnd(), GWL_EXSTYLE, WindowStyle);
  48. // Set dialog title name.
  49. DlgTitle.LoadString( IDS_IMPORT_DLGTITLE);
  50. this->SetWindowText( DlgTitle);
  51. return TRUE;
  52. }
  53. /****************************************/
  54. /* */
  55. /* COMMAND "BROWSE" */
  56. /* */
  57. /****************************************/
  58. void
  59. CImportDlg::OnFileBrowse()
  60. {
  61. OPENFILENAME ofn;
  62. CString DlgTtl, DlgMsg;
  63. CString sFilter;
  64. CWnd *cWnd;
  65. TCHAR chReplace;
  66. TCHAR szFilter[MAX_PATH];
  67. TCHAR szFileName[MAX_PATH];
  68. TCHAR szTitleName[MAX_PATH];
  69. TCHAR szDirName[MAX_PATH];
  70. if( CountryInfo.LangID == EUDC_JPN){
  71. // Set filter of file( from string table)
  72. GetStringRes(szFilter, IDS_IMPORT_JAPAN_FILTER);
  73. int StringLength = lstrlen( szFilter);
  74. chReplace = szFilter[StringLength-1];
  75. for( int i = 0; szFilter[i]; i++){
  76. if( szFilter[i] == chReplace)
  77. szFilter[i] = '\0';
  78. }
  79. GetSystemWindowsDirectory( szDirName, sizeof(szDirName)/sizeof(TCHAR));
  80. lstrcpy( szFileName, TEXT("USERFONT.FON"));
  81. DlgTtl.LoadString( IDS_BROWSEUSER_DLGTITLE);
  82. // Set data in structure of OPENFILENAME
  83. ofn.lStructSize = sizeof( OPENFILENAME);
  84. ofn.hInstance = AfxGetInstanceHandle();
  85. ofn.hwndOwner = this->GetSafeHwnd();
  86. ofn.lpstrFilter = szFilter;
  87. ofn.lpstrCustomFilter = NULL;
  88. ofn.nMaxCustFilter = 0;
  89. ofn.nFilterIndex = 0;
  90. ofn.lpstrFile = szFileName;
  91. ofn.lpstrFileTitle = szTitleName;
  92. ofn.nMaxFileTitle = sizeof( szTitleName) / sizeof(TCHAR);
  93. ofn.nMaxFile = sizeof( szFileName) / sizeof(TCHAR);
  94. ofn.lpstrInitialDir = szDirName;
  95. ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR
  96. | OFN_PATHMUSTEXIST;
  97. ofn.lpstrDefExt = NULL;
  98. ofn.lpstrTitle = DlgTtl;
  99. if( !GetOpenFileName( &ofn)){
  100. return;
  101. }
  102. memcpy( UserFont, ofn.lpstrFile, sizeof( UserFont));
  103. this->SetDlgItemText( IDC_BMP_IMPUT, ofn.lpstrFile);
  104. #ifdef BUILD_ON_WINNT
  105. if( OExistUserFont( UserFont) != 1){
  106. OutputMessageBoxEx( this->GetSafeHwnd(),
  107. IDS_IMPORT_DLGTITLE,
  108. AFX_IDP_FAILED_INVALID_PATH, TRUE, UserFont);
  109. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  110. GotoDlgCtrl( cWnd);
  111. return;
  112. }
  113. #endif // BUILD_ON_WINNT
  114. if( isW31JEUDCBMP( UserFont) != 1){
  115. OutputMessageBox( this->GetSafeHwnd(),
  116. IDS_IMPORT_DLGTITLE,
  117. IDS_NOTUSERFONT_MSG, TRUE);
  118. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  119. GotoDlgCtrl( cWnd);
  120. return;
  121. }
  122. cWnd = GetDlgItem( IDOK);
  123. GotoDlgCtrl( cWnd);
  124. }else if( CountryInfo.LangID == EUDC_CHT ||
  125. CountryInfo.LangID == EUDC_CHS ){
  126. // Set filter of file( from string table)
  127. GetStringRes(szFilter, IDS_IMPORT_CHINA_FILTER);
  128. int StringLength = lstrlen( szFilter);
  129. chReplace = szFilter[StringLength-1];
  130. for( int i = 0; szFilter[i]; i++){
  131. if( szFilter[i] == chReplace)
  132. szFilter[i] = '\0';
  133. }
  134. GetSystemWindowsDirectory( szDirName, sizeof(szDirName)/sizeof(TCHAR));
  135. lstrcpy( szFileName, TEXT("*.*"));
  136. DlgTtl.LoadString( IDS_BROWSEUSER_DLGTITLE);
  137. // Set data in structure of OPENFILENAME
  138. ofn.lStructSize = sizeof( OPENFILENAME);
  139. ofn.hwndOwner = this->GetSafeHwnd();
  140. ofn.hInstance = AfxGetInstanceHandle();
  141. ofn.lpstrFilter = szFilter;
  142. ofn.lpstrCustomFilter = NULL;
  143. ofn.nMaxCustFilter = 0;
  144. ofn.nFilterIndex = 0;
  145. ofn.lpstrFileTitle = szTitleName;
  146. ofn.nMaxFileTitle = sizeof( szTitleName) / sizeof(TCHAR);
  147. ofn.lpstrFile = szFileName;
  148. ofn.nMaxFile = sizeof( szFileName) / sizeof(TCHAR);
  149. ofn.lpstrInitialDir = szDirName;
  150. ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR
  151. | OFN_PATHMUSTEXIST;
  152. ofn.lpstrDefExt = NULL;
  153. ofn.lpstrTitle = DlgTtl;
  154. if( !GetOpenFileName( &ofn))
  155. return;
  156. memcpy( UserFont, ofn.lpstrFile, sizeof( UserFont));
  157. this->SetDlgItemText( IDC_BMP_IMPUT, ofn.lpstrFile);
  158. #ifdef BUILD_ON_WINNT
  159. if( OExistUserFont( UserFont) != 1){
  160. OutputMessageBoxEx( this->GetSafeHwnd(),
  161. IDS_IMPORT_DLGTITLE,
  162. AFX_IDP_FAILED_INVALID_PATH, TRUE, UserFont);
  163. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  164. GotoDlgCtrl( cWnd);
  165. return;
  166. }
  167. #endif // BUILD_ON_WINNT
  168. if( isETENBMP( UserFont) != 1){
  169. OutputMessageBox( this->GetSafeHwnd(),
  170. IDS_IMPORT_DLGTITLE,
  171. IDS_NOTUSERFONT_MSG, TRUE);
  172. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  173. GotoDlgCtrl( cWnd);
  174. return;
  175. }
  176. cWnd = GetDlgItem( IDOK);
  177. GotoDlgCtrl( cWnd);
  178. }
  179. }
  180. /****************************************/
  181. /* */
  182. /* COMMAND "IDOK" */
  183. /* */
  184. /****************************************/
  185. void
  186. CImportDlg::OnOK()
  187. {
  188. TCHAR *FilePtr;
  189. CWnd *cWnd;
  190. lstrcpy(EUDCTTF,SelectEUDC.m_File);
  191. lstrcpy( EUDCBMP, EUDCTTF);
  192. if(( FilePtr = Mytcsrchr( EUDCBMP, '.')) != NULL)
  193. *FilePtr = '\0';
  194. lstrcat( EUDCBMP, TEXT(".EUF"));
  195. if( !this->GetDlgItemText(IDC_BMP_IMPUT, UserFont, MAX_PATH)){
  196. OutputMessageBox( this->GetSafeHwnd(),
  197. IDS_IMPORT_DLGTITLE,
  198. IDS_NOTUSERFONT_MSG, TRUE);
  199. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  200. GotoDlgCtrl( cWnd);
  201. return;
  202. }
  203. if( CountryInfo.LangID == EUDC_JPN){
  204. #ifdef BUILD_ON_WINNT
  205. if( OExistUserFont( UserFont) != 1){
  206. OutputMessageBoxEx( this->GetSafeHwnd(),
  207. IDS_IMPORT_DLGTITLE,
  208. AFX_IDP_FAILED_INVALID_PATH, TRUE, UserFont);
  209. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  210. GotoDlgCtrl( cWnd);
  211. return;
  212. }
  213. #endif // BUILD_ON_WINNT
  214. if( isW31JEUDCBMP( UserFont) != 1){
  215. OutputMessageBox( this->GetSafeHwnd(),
  216. IDS_IMPORT_DLGTITLE,
  217. IDS_NOTUSERFONT_MSG, TRUE);
  218. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  219. GotoDlgCtrl( cWnd);
  220. return;
  221. }
  222. }else{
  223. #ifdef BUILD_ON_WINNT
  224. if( OExistUserFont( UserFont) != 1){
  225. OutputMessageBoxEx( this->GetSafeHwnd(),
  226. IDS_IMPORT_DLGTITLE,
  227. AFX_IDP_FAILED_INVALID_PATH, TRUE, UserFont);
  228. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  229. GotoDlgCtrl( cWnd);
  230. return;
  231. }
  232. #endif // BUILD_ON_WINNT
  233. if( isETENBMP( UserFont) != 1){
  234. OutputMessageBox( this->GetSafeHwnd(),
  235. IDS_IMPORT_DLGTITLE,
  236. IDS_NOTUSERFONT_MSG, TRUE);
  237. cWnd = this->GetDlgItem( IDC_BMP_IMPUT);
  238. GotoDlgCtrl( cWnd);
  239. return;
  240. }
  241. }
  242. EndDialog(IDOK);
  243. }
  244. static DWORD aIds[] =
  245. {
  246. IDC_STATICBMP, IDH_EUDC_IMPOBMP,
  247. IDC_BMP_IMPUT, IDH_EUDC_IMPOBMP,
  248. IDC_FILE_BROWSE, IDH_EUDC_BROWSE,
  249. 0,0
  250. };
  251. /****************************************/
  252. /* */
  253. /* Window procedure */
  254. /* */
  255. /****************************************/
  256. LRESULT
  257. CImportDlg::WindowProc(
  258. UINT message,
  259. WPARAM wParam,
  260. LPARAM lParam)
  261. {/*
  262. if( message == WM_HELP){
  263. ::WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle,
  264. HelpPath, HELP_WM_HELP, (DWORD_PTR)(LPTSTR)aIds);
  265. return(0);
  266. }
  267. if( message == WM_CONTEXTMENU){
  268. ::WinHelp((HWND)wParam, HelpPath,
  269. HELP_CONTEXTMENU, (DWORD_PTR)(LPTSTR)aIds);
  270. return(0);
  271. }
  272. */
  273. return CDialog::WindowProc(message, wParam, lParam);
  274. }
  275. BEGIN_MESSAGE_MAP(CImportDlg, CDialog)
  276. //{{AFX_MSG_MAP(CImportDlg)
  277. ON_BN_CLICKED(IDC_FILE_BROWSE, OnFileBrowse)
  278. //}}AFX_MSG_MAP
  279. END_MESSAGE_MAP()