home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WCOMDLG.HPP < prev    next >
C/C++ Source or Header  |  1996-11-19  |  7KB  |  241 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WCommonDialog -- Base CommonDialog class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       Change --
  19.  *
  20.  *       Close --
  21.  *
  22.  *       Create --
  23.  *
  24.  *       Destroy --
  25.  *
  26.  *       Help --
  27.  *
  28.  *       InitializationDone --
  29.  *
  30.  *       MessageHook --
  31.  *
  32.  *************************************************************************/
  33.  
  34. #ifndef _WCOMDLG_HPP_INCLUDED
  35. #define _WCOMDLG_HPP_INCLUDED
  36.  
  37. #ifndef _WNO_PRAGMA_PUSH
  38. #pragma pack(push,8);
  39. #pragma enum int;
  40. #endif
  41.  
  42. #ifndef _WEVENTD_HPP_INCLUDED
  43. #include "weventd.hpp"
  44. #endif
  45.  
  46. #ifndef _WFILPATH_HPP_INCLUDED
  47. #include "wfilpath.hpp"
  48. #endif
  49.  
  50. #ifndef _WRESID_HPP_INCLUDED
  51. #include "wresid.hpp"
  52. #endif
  53.  
  54. #ifndef _WMODULE_HPP_INCLUDED
  55. #include "wmodule.hpp"
  56. #endif
  57.  
  58. class WWindow;
  59. class WModelessDialog;
  60. class WDialog;
  61. class WModule;
  62.  
  63.  
  64. enum WCommonDialogError {
  65.     // WCommonDialog general errors
  66.     WCDCDErrorNoError           = 0x0000,
  67.     WCDCDErrorGeneralCodes      = 0x0000,
  68.     WCDCDErrorStructSize        = 0x0001,
  69.     WCDCDErrorInitialization    = 0x0002,
  70.     WCDCDErrorNoTemplate        = 0x0003,
  71.     WCDCDErrorNoHINSTANCE       = 0x0004,
  72.     WCDCDErrorLoadStrFailure    = 0x0005,
  73.     WCDCDErrorFindResFailure    = 0x0006,
  74.     WCDCDErrorLoadResFailure    = 0x0007,
  75.     WCDCDErrorLockResFailure    = 0x0008,
  76.     WCDCDErrorMemAllocFailure   = 0x0009,
  77.     WCDCDErrorMemLockFailure    = 0x000A,
  78.     WCDCDErrorNoHook            = 0x000B,
  79.     WCDCDErrorRegisterMsgFail   = 0x000C,
  80.     WCDCDErrorDialogFailure     = 0xFFFF,
  81.  
  82.     // WPrintDialog specific errors
  83.     WCDPDErrorPrinterCodes      = 0x1000,
  84.     WCDPDErrorSetupFailure      = 0x1001,
  85.     WCDPDErrorParseFailure      = 0x1002,
  86.     WCDPDErrorRetDefFailure     = 0x1003,
  87.     WCDPDErrorLoadDrvFailure    = 0x1004,
  88.     WCDPDErrorGetDevModeFail    = 0x1005,
  89.     WCDPDErrorInitFailure       = 0x1006,
  90.     WCDPDErrorNoDevices         = 0x1007,
  91.     WCDPDErrorNoDefaultPrn      = 0x1008,
  92.     WCDPDErrorDNDMMismatch      = 0x1009,
  93.     WCDPDErrorCreateICFailure   = 0x100A,
  94.     WCDPDErrorPrinterNotFound   = 0x100B,
  95.     WCDPDErrorDefaultDifferent  = 0x100C,
  96.  
  97.     // WFontDialog specific errors
  98.     WCDCFErrorChooseFontCodes   = 0x2000,
  99.     WCDCFErrorNoFonts           = 0x2001,
  100.     WCDCFErrorMaxLessThanMin    = 0x2002,
  101.  
  102.     // WFileDialog specific errors
  103.     WCDFNErrorFileNameCodes     = 0x3000,
  104.     WCDFNErrorSubclassFailure   = 0x3001,
  105.     WCDFNErrorInvalidFileName   = 0x3002,
  106.     WCDFNErrorBufferTooSmall    = 0x3003,
  107.  
  108.     // WFindReplaceDialog specific errors
  109.     WCDFRErrorFindReplaceCodes  = 0x4000,
  110.     WCDFRErrorBufferLengthZero  = 0x4001,
  111.  
  112.     // WColorDialog specific errors
  113.     WCDCCErrorChooseColorCodes  = 0x5000,
  114. };
  115.  
  116. struct WSharingViolationEventData : public WEventData {
  117.     WChar *             fileName;
  118. };
  119.  
  120. //
  121. // WCommonDialog
  122. //
  123.  
  124. class WCMCLASS WCommonDialog : public WEventGenerator {
  125.     WDeclareSubclass( WCommonDialog, WEventGenerator );
  126.  
  127.     public:
  128.         WCommonDialog();
  129.  
  130.         ~WCommonDialog();
  131.  
  132.         /********************************************************
  133.          * Properties
  134.          ********************************************************/
  135.  
  136.         // Dialog
  137.         //
  138.         //    Returns a pointer to a WDialog that can be used to
  139.         //    manipulate the common dialog.  For modal dialogs
  140.         //    this property only returns non-NULL when the
  141.         //    dialog is being displayed and thus is typically only
  142.         //    used within events.
  143.  
  144.         WDialog *GetDialog();
  145.  
  146.         // Error
  147.  
  148.         WCommonDialogError GetError() const;
  149.  
  150.         // ModelessDialog
  151.         //
  152.  
  153.         WModelessDialog *GetModelessDialog();
  154.  
  155.         // Owner
  156.         //
  157.         //    Sets/gets the form that owns the dialog.
  158.  
  159.         WWindow *GetOwner() const;
  160.         WBool    SetOwner( WWindow *owner );
  161.  
  162.         // TemplateID
  163.         //
  164.         //    Sets/gets the resource ID that defines the template
  165.         //    to use for the dialog.  0 means no template is used.
  166.  
  167.         WResourceID GetTemplateID() const;
  168.         WBool       SetTemplateID( WResourceID id );
  169.  
  170.         // TemplateModule
  171.         //
  172.         //    Sets/gets the module for the template.  A value of
  173.         //    NULL means use the application module.
  174.  
  175.         WModule GetTemplateModule() const;
  176.         WBool   SetTemplateModule( const WModule & module );
  177.  
  178.         // Title
  179.         //
  180.         //    The title used when displaying the dialog.  The
  181.         //    title may be a null string, in which case a default
  182.         //    value is used.
  183.  
  184.         WString GetTitle() const;
  185.         WBool   SetTitle( const WChar *title );
  186.  
  187.         /********************************************************
  188.          * Methods
  189.          ********************************************************/
  190.  
  191.         // Abort
  192.         //
  193.         //    Causes the dialog to be closed as if the user had
  194.         //    cancelled it.
  195.  
  196.         WBool Abort() const;
  197.  
  198.         /********************************************************
  199.          * Notifications
  200.          ********************************************************/
  201.  
  202.         void OnDialogInitialize( WWindowHandle hWnd, WWindowHandle focus,
  203.                                  WBool modal=TRUE );
  204.         void OnDialogDestroy();
  205.  
  206.         /********************************************************
  207.          * Event handlers
  208.          ********************************************************/
  209.  
  210.         WBool MessageHookEventHandler( WCommonDialog * dialog,
  211.                                        WMessageHookEventData * event );
  212.  
  213.         /********************************************************
  214.          * Data members
  215.          ********************************************************/
  216.  
  217.     protected:
  218.         WWindowHandle    _hWnd;
  219.         WBool            _isModal;
  220.         WDialog         *_dialog;
  221.         WModelessDialog *_modelessDialog;
  222.         WWindow         *_owner;
  223.         WModule          _templateModule;
  224.         WResourceID      _templateID;
  225.         WBool            _hasUserHook;
  226.         WString          _title;
  227.  
  228.     // Internal use only
  229.  
  230.     public:
  231.         WBool HasUserHook() const { return _hasUserHook; }
  232. };
  233.  
  234.  
  235. #ifndef _WNO_PRAGMA_PUSH
  236. #pragma enum pop;
  237. #pragma pack(pop);
  238. #endif
  239.  
  240. #endif // _WCOMDLG_HPP_INCLUDED
  241.