00001 // This code is a part of the NanoSoft NSViews C++ Library. 00002 // Copyright (C) 1996 NanoSoft Corporation. All rights reserved. 00003 00004 #ifndef __NSFlexDialog_h__ 00005 #define __NSFlexDialog_h__ 00006 00007 #include "NSViewsAfxExt.h" 00008 #include "NSFlexConstraints.h" 00009 00010 class CNSFlexConstraintList; 00011 00012 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00013 00014 // CNSFlexDialog turns a normal CDialog into a "flexible" dialog that 00015 // automatically repositions its controls when the dialog window is resized. 00016 // The class also supports an Apply button and provides a convenient virtual 00017 // function called OnApplyChanges() to handle the application of changes to a 00018 // subject whenever the Apply or OK button is pressed. 00019 00020 // See the MFC CDialog documentation for additional information. 00021 00022 class AFX_EXT_NSVIEWS CNSFlexDialog : public CDialog 00023 { 00024 00025 DECLARE_DYNAMIC(CNSFlexDialog) 00026 00027 // -------------------------------------------------------------------------- 00028 00029 public: 00030 00031 // Constructors. 00032 CNSFlexDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL, 00033 void* pSubject = NULL); 00034 CNSFlexDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL, 00035 void* pSubject = NULL); 00036 // nIDTemplate - Contains the ID number of a dialog-box template resource. 00037 // lpszTemplateName - Contains a null-terminated string that is the name 00038 // of a dialog-box template resource. 00039 // pParentWnd - Points to the parent or owner window object (of type CWnd) 00040 // to which the dialog object belongs. If it is NULL, the dialog 00041 // object’s parent window is set to the main application window. 00042 // pSubject - Pointer to subject that will be passed to OnApplyChanges(). 00043 00044 // Destructor. 00045 virtual ~CNSFlexDialog(); 00046 00047 // Add horizontal and vertical positioning constraints to a specified 00048 // control that will be applied when the window is resized. 00049 void AddFlexConstraint(UINT nControlID, 00050 const CNSFlexHorizontalConstraint& HorizontalConstraint, 00051 const CNSFlexVerticalConstraint& VerticalConstraint); 00052 // nControlID - ID of specified dialog control. 00053 // HorizontalConstraint - Horizontal positioning constraint. 00054 // Vertical Constraint - Vertical positioning constraint. 00055 00056 // Returns the subject pointer that was set in the constructor or using 00057 // SetSubject(); 00058 void* GetSubject() const; 00059 00060 // Called when either the Apply or OK button is pressed after dialog 00061 // data has been validated. Provides a nice place to handle the application 00062 // of changes to a subject. Nonzero TRUE return indicates changes were 00063 // successfully applied. Zero FALSE return indicates application of 00064 // changes failed. 00065 virtual BOOL OnApplyChanges(void* pSubject); 00066 // pSubject - Pointer to subject that was set in the constructor or using 00067 // SetSubject(). 00068 00069 // Enable or disable the Apply button. 00070 void SetModified(BOOL bChanged = TRUE); 00071 // bChanged - TRUE to indicate that the dialog settings have been modified 00072 // since the last time they were applied; FALSE to indicate that the 00073 // dialog settings have been applied, or should be ignored. 00074 00075 // Set the dialog subject pointer that gets passed to OnApplyChanges. 00076 // The typical time to call this function is after the CNSFlexDialog has 00077 // been constructed, but before calling DoModal(). 00078 virtual void SetSubject(void* pSubject); 00079 // pSubject - Pointer to subject that will be passed to OnApplyChanges(). 00080 00081 // -------------------------------------------------------------------------- 00082 00083 public: 00084 00085 // ClassWizard 00086 //{{AFX_VIRTUAL(CNSFlexDialog) 00087 //}}AFX_VIRTUAL 00088 00089 virtual void OnOK(); 00090 00091 protected: 00092 00093 // ClassWizard 00094 //{{AFX_MSG(CNSFlexDialog) 00095 afx_msg void OnSize(UINT nType, int cx, int cy); 00096 afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); 00097 virtual BOOL OnInitDialog(); 00098 //}}AFX_MSG 00099 afx_msg void OnApply(); 00100 DECLARE_MESSAGE_MAP() 00101 00102 private: 00103 00104 CNSFlexConstraintList* m_pFlexConstraintList; 00105 int m_nMinTrackingWidth; 00106 int m_nMinTrackingHeight; 00107 BOOL m_bModified; 00108 void* m_pSubject; 00109 00110 }; 00111 00112 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00113 00114 #endif
1.5.1