/***********************************************************************/ /* Copyright (C) 2002 Definitive Solutions, Inc. All Rights Reserved. */ /* THIS COMPUTER PROGRAM IS PROPRIETARY AND CONFIDENTIAL TO DEFINITIVE */ /* SOLUTIONS, INC. AND ITS LICENSORS AND CONTAINS TRADE SECRETS OF */ /* DEFINITIVE SOLUTIONS, INC. THAT ARE PROVIDED PURSUANT TO A WRITTEN */ /* AGREEMENT CONTAINING RESTRICTIONS ON USE AND DISCLOSURE. ANY USE, */ /* REPRODUCTION, OR TRANSFER EXCEPT AS PROVIDED IN SUCH AGREEMENT */ /* IS STRICTLY PROHIBITED. */ /***********************************************************************/ ///////////////////////////////////////////////////////////////////////////// // How to add this class to your application. // // Add MyDialog.cpp and MyDialog.h to your project in the usual folders. // // Be sure that in StdAfx.h, is included: /* #ifndef _AFX_NO_AFXCMN_SUPPORT #include // MFC support for Windows Common Controls #endif */ // // To convert a standard CDialog-dervied class into a MyDialog-derived one: // // 1). Replace all occurances of "CDialog" with "MyDialog" in your dialog's // H and CPP files. // // 2). Change your dialog's constructor to look like this: // // : MyDialog(YourDlg::IDD, "YourDlg", sRegPlacementsKey, pParent) // // 3). At the top of your dialog's InitDialog(), add the following: // // // You MUST set the controls before you call the base OnInitDialog! // SetControlInfo(IDC_STATIC_SOMETHING, ANCHOR_LEFT | ANCHOR_TOP | RESIZE_BOTH); // // 4). Make sure all the controls in your dialog have an ID (that is, none of // them can be IDC_STATIC, for example). // // 5). Add a string table entry for each control (this will be that control's // tooltip. Static items that don't need a tip must be set to a tip of // a single space (no tip will be shown). // // 6). Add the icons to the buttons if desired after the call to the base class // MyDialog::OnInitDialog(): // // // Set icons on buttons. // m_buttonSomething.SetIcon(IDI_SOMETHING, 32, 32); // m_buttonOk.SetIcon(IDI_MYBUTTON_OK, 32, 32); // m_buttonCancel.SetIcon(IDI_MYBUTTON_CANCEL, 32, 32); // // 7). Add this to the top of your dialog's header file: // // #include "MyDialog.h" // // 8). Set the dialog template's "Border Style" to "Resizing". // // Optionally, call this in your InitInstance() to set the icon for all // dialogs in your app (this can be overriden for individual dialogs via // the MyDialog constructor): // // MyDialog::m_uiDialogIcon = IDR_YOURDIALOGRESOURCEID; // // // Add, if needed, the MyRegistry, MyApp, MyLog, MyHyperlink, and Generic // classes to the project. Be sure to check each of these classes' *.H file // for instructions on how to include them in your project. ///////////////////////////////////////////////////////////////////////////// #if !defined(MYDIALOGH_6782DEA1_2798_11d6_8AC8_00B0D0529ED2_INCLUDED_) #define MYDIALOGH_6782DEA1_2798_11d6_8AC8_00B0D0529ED2_INCLUDED_ #pragma once #include "MyToolTipCtrl.h" ///////////////////////////////////////////////////////////////////////////// // ToolTipLParam - needed by non-member function EnumChildProc(). struct ToolTipLParam { MyToolTipCtrl* m_pToolTip; // Points to the tooltip. CWnd* m_pControl; // Points to the control (button, etc.) // to be "tool-tipped", }; ///////////////////////////////////////////////////////////////////////////// // ControlInfo structure - needed to do control size and position handling struct ControlInfo { bool m_bSetExternally; // Did the client programmer set // this from their dialog's // OnInitDialog( )? UINT uiID; // The resource id of this control. UINT uiInfo; // The size and position constants. CRect rcClient; // The *old* rectangle where this // control was. CString sClassName; // Name of the window class. }; ///////////////////////////////////////////////////////////////////////////// // MyDialog // Declare the class depending on this file is in an EXE project or a DLL one. class #ifdef _WINDLL AFX_EXT_CLASS #endif MyDialog : public CDialog { // Construction. public: MyDialog(UINT uiResourceID, const CString& sName, const CString& sRegPlacementsKey, CWnd* pParent = NULL, bool bHidden = false, UINT uiDialogIcon = 0U); MyDialog(LPCTSTR lpszResourceID, const CString& sName, const CString& sRegPlacementsKey, CWnd* pParent = NULL, bool bHidden = false, UINT uiDialogIcon = 0U); virtual ~MyDialog(); // Declared but not defined. private: MyDialog(const MyDialog& rhs); MyDialog& operator=(const MyDialog& rhs); // Interface. public: // How is control to be sized and positioned when the dialog is stretched? #define ANCHOR_LEFT 0x0 // Maintain distance from left side. #define ANCHOR_TOP 0x0 // Maintain distance from top side. #define ANCHOR_RIGHT 0x1 // Maintain distance from right side. #define ANCHOR_BOTTOM 0x2 // Maintain distance from bottom side. #define RESIZE_HORZ 0x4 // Stretch/shrink along width. #define RESIZE_VERT 0x8 // Stretch/shrink along height. #define RESIZE_BOTH (RESIZE_HORZ | RESIZE_VERT) // Set size and position request for a control. void SetControlInfo(UINT uiCtrlID, UINT uiCtrlInfo); // Public data. public: static UINT m_uiDialogIcon; // Optional icon value for all // dailog boxes in this app. Can // be overridden in the ctor. // Dialog Data protected: //{{AFX_DATA(MyDialog) //}}AFX_DATA //{{AFX_VIRTUAL(MyDialog) public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void DoDataExchange(CDataExchange* pDX); //}}AFX_VIRTUAL // Implementation. protected: //{{AFX_MSG(MyDialog) virtual BOOL OnInitDialog(); afx_msg void OnDestroy(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); afx_msg void OnPaint(); afx_msg UINT OnNcHitTest(CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() // Implementation. private: void SetControlInfoInternal(UINT uiCtrlID, UINT uiCtrlInfo); void CommonConstruct(); bool AddTipToControl(CWnd* pControl); ControlInfo* GetControlInfo(UINT uiID) const; void SetDefaultControlInfos(); void DoControlsAffectedByHorzStretch(UINT uiIDHorz); void DoControlsAffectedByVertStretch(UINT uiIDHorz); // Data. private: CString m_sName; // The name of this dialog box (used // for the Registry). CString m_sRegPlacementsKey;// Key name to store the placement of // this dialog box in the Registry. MyToolTipCtrl m_ToolTip; // Tool tip for dialog box's controls. CPtrList m_plControlInfo; // Info structure for each control. int m_nOldCx; // Size of the dialog last time; // provides a basis of comparison. int m_nOldCy; // Size of the dialog last time; // provides a basis of comparison. int m_nMinWidth; // The original (and min. allowable) // size of the dialog. int m_nMinHeight; // The original (and min. allowable) // size of the dialog. bool m_bHidden; // This dialog should never be visible. // Used for tray applications.) }; #endif // MYDIALOGH_6782DEA1_2798_11d6_8AC8_00B0D0529ED2_INCLUDED_