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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   source\owl\chooseco.cpp
  4. //   Implementation of Choose Color Common Dialog class
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <owl\chooseco.h>
  8.  
  9. UINT TChooseColorDialog::SetRGBMsgId = 0;
  10.  
  11. DEFINE_RESPONSE_TABLE1(TChooseColorDialog, TCommonDialog)
  12. END_RESPONSE_TABLE;
  13.  
  14. IMPLEMENT_CASTABLE(TChooseColorDialog);
  15.  
  16. TChooseColorDialog::TChooseColorDialog(TWindow*        parent,
  17.                                        TData&          data,
  18.                                        TResId          templateId,
  19.                                        const char far* title,
  20.                                        TModule*        module)
  21.   : TCommonDialog(parent, title, module), 
  22.     Data(data)
  23. {
  24.   if (!SetRGBMsgId)
  25.     SetRGBMsgId = ::RegisterWindowMessage(SETRGBSTRING);
  26.  
  27.   memset(&cc, 0, sizeof(CHOOSECOLOR));
  28.   cc.lStructSize = sizeof(CHOOSECOLOR);
  29.   cc.hwndOwner = Parent ? Parent->HWindow : 0;
  30.   cc.hInstance = (HWND)(HINSTANCE)*GetModule();
  31.   cc.Flags = CC_ENABLEHOOK | Data.Flags;
  32.   if (templateId) {
  33.     cc.lpTemplateName = templateId;
  34.     cc.Flags |= CC_ENABLETEMPLATE;
  35.   } else
  36.     cc.Flags &= ~CC_ENABLETEMPLATE;
  37.   cc.lpfnHook = 0;
  38.  
  39.   cc.rgbResult = Data.Color;
  40.   cc.lpCustColors = (COLORREF far*)Data.CustColors;
  41. }
  42.  
  43. BOOL
  44. TChooseColorDialog::DialogFunction(UINT msg, WPARAM wParam, LPARAM lParam)
  45. {
  46.   return TCommonDialog::DialogFunction(msg, wParam, lParam);
  47. }
  48.  
  49. int
  50. TChooseColorDialog::DoExecute()
  51. {
  52.   (DLGPROC)cc.lpfnHook = (DLGPROC)(FARPROC)StdDlgProcInstance;
  53.   int ret = ::ChooseColor(&cc);
  54.   if (ret) {
  55.     Data.Flags = cc.Flags;
  56.     Data.Error = 0;
  57.     Data.Color = cc.rgbResult;
  58.   } else {
  59.     Data.Error = ::CommDlgExtendedError();
  60.   }
  61.   return ret ? IDOK : IDCANCEL;
  62. }
  63.