home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / CHOOSEFO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  2.1 KB  |  74 lines

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