home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / CHOOSEFO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.1 KB  |  70 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   source\owl\choosefo.cpp
  4. //   Implementation of Choose Font Common Dialog class
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <owl\choosefo.h>
  8. #if !defined(ctlFirst)
  9.   #include <dlgs.h>
  10. #endif
  11.  
  12. DEFINE_RESPONSE_TABLE1(TChooseFontDialog, TCommonDialog)
  13. END_RESPONSE_TABLE;
  14.  
  15. IMPLEMENT_CASTABLE(TChooseFontDialog);
  16.  
  17. TChooseFontDialog::TChooseFontDialog(TWindow*        parent,
  18.                                      TData&          data,
  19.                                      TResId          templateId,
  20.                                      const char far* title,
  21.                                      TModule*        module)
  22.   : TCommonDialog(parent, title, module),
  23.     Data(data)
  24. {
  25.   memset(&cf, 0, sizeof(CHOOSEFONT));
  26.   cf.lStructSize = sizeof(CHOOSEFONT);
  27.   cf.hwndOwner = Parent ? Parent->HWindow : 0;
  28.   cf.hInstance = *GetModule();
  29.   cf.Flags = CF_ENABLEHOOK | Data.Flags;
  30.   if (templateId) {
  31.     cf.lpTemplateName = templateId;
  32.     cf.Flags |= CF_ENABLETEMPLATE;
  33.   } else
  34.     cf.Flags &= ~CF_ENABLETEMPLATE;
  35.   cf.lpfnHook = 0;
  36.  
  37.   cf.hDC = Data.DC;
  38.   cf.lpLogFont = &Data.LogFont;
  39.   cf.iPointSize = Data.PointSize;
  40.   cf.rgbColors = Data.Color;
  41.   cf.lpszStyle = Data.Style;
  42.   cf.nFontType = Data.FontType;
  43.   cf.nSizeMin = Data.SizeMin;
  44.   cf.nSizeMax = Data.SizeMax;
  45. }
  46.  
  47. BOOL
  48. TChooseFontDialog::DialogFunction(UINT msg, WPARAM wParam, LPARAM lParam)
  49. {
  50.   return TCommonDialog::DialogFunction(msg, wParam, lParam);
  51. }
  52.  
  53. int
  54. TChooseFontDialog::DoExecute()
  55. {
  56.   (DLGPROC)cf.lpfnHook = (DLGPROC)(FARPROC)StdDlgProcInstance;
  57.   int ret = ::ChooseFont(&cf);
  58.   if (ret) {
  59.     Data.Flags = cf.Flags;
  60.     Data.Error = 0;
  61.     Data.PointSize = cf.iPointSize;
  62.     Data.Color = cf.rgbColors;
  63.     Data.Style = cf.lpszStyle;
  64.     Data.FontType = cf.nFontType;
  65.   } else {
  66.     Data.Error = ::CommDlgExtendedError();
  67.   }
  68.   return ret ? IDOK : IDCANCEL;
  69. }
  70.