home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / GETF.ZIP / MyFontDialog.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-01  |  3.3 KB  |  124 lines

  1. /************************************
  2.   REVISION LOG ENTRY
  3.   Revision By: Mihai Filimon
  4.   Revised on 2/1/99 2:27:44 PM
  5.   Comments: MyFontDialog.cpp : implementation file
  6.  ************************************/
  7.  
  8. #include "stdafx.h"
  9. #include "GetF.h"
  10. #include "MyFontDialog.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMyFontDialog
  20.  
  21. IMPLEMENT_DYNAMIC(CMyFontDialog, CFontDialog)
  22.  
  23. CMyFontDialog::CMyFontDialog(LPLOGFONT lplfInitial, DWORD dwFlags, CDC* pdcPrinter, CWnd* pParentWnd) : 
  24.     CFontDialog(lplfInitial, dwFlags, pdcPrinter, pParentWnd)
  25. {
  26. }
  27.  
  28.  
  29. BEGIN_MESSAGE_MAP(CMyFontDialog, CFontDialog)
  30.     //{{AFX_MSG_MAP(CMyFontDialog)
  31.     ON_WM_TIMER()
  32.     //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34.  
  35.  
  36. #include <dlgs.h>
  37. // Function name    : CMyFontDialog::OnInitDialog
  38. // Description        : 
  39. // Return type        : BOOL 
  40. BOOL CMyFontDialog::OnInitDialog() 
  41. {
  42.     CFontDialog::OnInitDialog();
  43.     
  44.     m_edit.Create(WS_BORDER | WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_CENTER, CRect(0,0,0,0), this, 0);
  45.     m_edit.SetFont(GetFont());
  46.     CRect rect; GetDlgItem(stc6)->GetWindowRect(rect);
  47.     ScreenToClient(&rect);
  48.     m_edit.MoveWindow(rect);
  49.     
  50.     return TRUE;  // return TRUE unless you set the focus to a control
  51.                   // EXCEPTION: OCX Property Pages should return FALSE
  52. }
  53.  
  54. // Function name    : = 
  55. // Description        : Just set the new text for edit.
  56. // Return type        : void CMyFontDialog::operator 
  57. // Argument         : LPCTSTR lpszNewText
  58. void CMyFontDialog::operator = (LPCTSTR lpszNewText)
  59. {
  60.     ASSERT( m_edit.GetSafeHwnd() );
  61.     m_edit.SetWindowText(lpszNewText);
  62. }
  63.  
  64. // Function name    : CMyFontDialog::OnCommand
  65. // Description        : 
  66. // Return type        : BOOL 
  67. // Argument         :  WPARAM wParam
  68. // Argument         : LPARAM lParam
  69. BOOL CMyFontDialog::OnCommand( WPARAM wParam, LPARAM lParam )
  70. {
  71.     BOOL bResult = CFontDialog::OnCommand(wParam, lParam);
  72.     if (LOWORD(wParam) != m_edit.GetDlgCtrlID())
  73.         SetTimer(0, 100, NULL);
  74.     return bResult;
  75. }
  76.  
  77.  
  78. CString CMyFontDialog::GetLong(long l)
  79. {
  80.     CString sResult;
  81.     sResult.Format(_T("%i,"), l);
  82.     return sResult;
  83. }
  84.  
  85. // Function name    : CMyFontDialog::GetCurrentFontAsString
  86. // Description        : 
  87. // Return type        : CString 
  88. CString CMyFontDialog::GetCurrentFontAsString()
  89. {
  90.     LOGFONT logFont;
  91.     GetCurrentFont(&logFont);
  92.     CString sResult;
  93.     sResult += GetLong(logFont.lfHeight);
  94.     sResult += GetLong(logFont.lfWidth);
  95.     sResult += GetLong(logFont.lfEscapement);
  96.     sResult += GetLong(logFont.lfOrientation);
  97.     sResult += GetLong(logFont.lfWeight);
  98.     sResult += GetLong(logFont.lfItalic);
  99.     sResult += GetLong(logFont.lfUnderline);
  100.     sResult += GetLong(logFont.lfStrikeOut);
  101.     sResult += GetLong(logFont.lfCharSet);
  102.     sResult += GetLong(logFont.lfOutPrecision);
  103.     sResult += GetLong(logFont.lfClipPrecision);
  104.     sResult += GetLong(logFont.lfQuality);
  105.     sResult += GetLong(logFont.lfPitchAndFamily);
  106.     sResult += logFont.lfFaceName;
  107.     return sResult;
  108. }
  109.  
  110. // Function name    : CMyFontDialog::OnTimer
  111. // Description        : 
  112. // Return type        : void 
  113. // Argument         : UINT nIDEvent
  114. void CMyFontDialog::OnTimer(UINT nIDEvent) 
  115. {
  116.     if (!nIDEvent)
  117.     {
  118.         *this = GetCurrentFontAsString();
  119.         KillTimer(nIDEvent);
  120.     }
  121.     
  122.     CFontDialog::OnTimer(nIDEvent);
  123. }
  124.