// XTPBrowseEdit.h : interface for the CXTPBrowseEdit class. // // This file is a part of the XTREME CONTROLS MFC class library. // (c)1998-2012 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// //{{AFX_CODEJOCK_PRIVATE #if !defined(__XTPBROWSEEDIT_H__) #define __XTPBROWSEEDIT_H__ //}}AFX_CODEJOCK_PRIVATE #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 class CXTPBrowseEdit; #define XTP_IDC_LBOX_EDIT 101 // -------------------------------------------------------------------- // Summary: // CXTPBrowseButton is a CXTPButton derived class that is used // by CXTPBrowseEdit to create the browse button that is used to // display file dialogs and popup menus. // -------------------------------------------------------------------- class _XTP_EXT_CLASS CXTPBrowseButton : public CXTPButton { DECLARE_DYNAMIC(CXTPBrowseButton) public: // ---------------------------------------------- // Summary: // Constructs a CXTPBrowseButton object // ---------------------------------------------- CXTPBrowseButton(); // ----------------------------------------------------------------- // Summary: // Destroys a CXTPBrowseButton object, handles cleanup and // deallocation // ----------------------------------------------------------------- virtual ~CXTPBrowseButton(); public: // ---------------------------------------------------------------------- // Summary: // This member function is called to create the browse button used by // the edit control. // Parameters: // pEditWnd - [in] Parent edit control. // dwBStyle - [in] Search type // nID - [in] Resource id for push button // nMenu - [in] Popup menu id // nSubMenuIndx - [in] Index of popup submenu. // Returns: // TRUE if successful, otherwise FALSE. // ---------------------------------------------------------------------- virtual BOOL Create(CXTPBrowseEdit* pEditWnd, DWORD dwBStyle, UINT nID, UINT nMenu = (UINT)-1, UINT nSubMenuIndx = (UINT)-1); // ---------------------------------------------------------------------------- // Summary: // This member function will set the browse style for the button. // Parameters: // dwxStyle - Specifies the browse style. The button style can be defined // as one or more of the styles listed in the Remarks section. // Remarks: // The CXTPBrowseButton can be set to use one or more of the following // styles: // * BES_XTP_CHOOSEDIR Display the choose folder dialog. // * BES_XTP_CHOOSEFILE Display the choose file dialog. // * BES_XTP_POPUPMENU Display a user defined context menu. // See Also: // SetXButtonStyle // ---------------------------------------------------------------------------- void SetBrowseStyle(DWORD dwxStyle); protected: //{{AFX_CODEJOCK_PRIVATE DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPItemEdit) virtual BOOL PreTranslateMessage(MSG* pMsg); virtual void OnClicked(); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPBrowseButton) afx_msg void OnEnable(BOOL bEnable); afx_msg void OnBtnClicked(); //}}AFX_MSG //}}AFX_CODEJOCK_PRIVATE private: BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); BOOL Create(LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); protected: DWORD m_dwBStyle; // Search type UINT m_nID; // Resource id for push button UINT m_nMenu; // Popup menu id UINT m_nSubMenuIndx; // Index of popup submenu. CXTPBrowseEdit* m_pEditWnd; // Parent edit control. friend class CXTPBrowseEdit; }; // -------------------------------------------------------------------- // Summary: // CXTPBrowseEdit is a CXTPEdit derived class. This class also // has a push button associated with it. The control can be used to // search for directories and files or activate a popup menu. // -------------------------------------------------------------------- class _XTP_EXT_CLASS CXTPBrowseEdit : public CXTPEdit { DECLARE_DYNAMIC(CXTPBrowseEdit) public: // -------------------------------------------- // Summary: // Constructs a CXTPBrowseEdit object // -------------------------------------------- CXTPBrowseEdit(); // --------------------------------------------------------------- // Summary: // Destroys a CXTPBrowseEdit object, handles cleanup and // deallocation // --------------------------------------------------------------- virtual ~CXTPBrowseEdit(); public: // ----------------------------------------------------------------------- // Summary: // Call this member function to determine if the browse edit control // is in the middle of a browse operation. // Returns: // true if the control is displaying a File Open dialog or popup menu. // ----------------------------------------------------------------------- bool IsBrowsing(); // ------------------------------------------------------------------------------- // Summary: // Call this member function to set the gap between the browse button // and the edit window. // Parameters: // nGap - [in] Gap, in pixels, between the browse button and the edit window. // ------------------------------------------------------------------------------- void SetGap(int nGap); // ------------------------------------------------------------------------------ // Summary: // This member function will set a CFileDialog derived class object to // be the file open dialog. // Parameters: // pFileDialog - [in] Points to the CFileDialog object that will replace the // standard File Open dialog. // ------------------------------------------------------------------------------ virtual void SetFileDialog(CFileDialog* pFileDialog); // ------------------------------------------------------------------------------- // Summary: // This member function will set the File Open dialog style. // Parameters: // bOpenFileDialog - [in] Set to TRUE to construct a File Open dialog box, or // FALSE to construct a File Save as dialog box. // ------------------------------------------------------------------------------- virtual void SetDlgOpenFile(BOOL bOpenFileDialog = TRUE); // ----------------------------------------------------------------------------- // Summary: // This member function sets the default extension for the File Open // dialog. // Parameters: // lpszDefExt - [in] Points to a NULL terminated string that represents the // default file extension to be used with the File Open dialog. // ----------------------------------------------------------------------------- void SetDlgDefExt(LPCTSTR lpszDefExt = NULL); // ------------------------------------------------------------------------------ // Summary: // This member function sets the default file name for the File Open // dialog. // Parameters: // lpszFileName - [in] Points to a NULL terminated string that represents the // default file name to be used with the File Open dialog. // ------------------------------------------------------------------------------ void SetDlgFileName(LPCTSTR lpszFileName = NULL); // --------------------------------------------------------------------- // Summary: // This member function sets the style flags for the File Open // dialog. // Parameters: // dwFlags - [in] The desired OFN_ styles for the File Open dialog. // --------------------------------------------------------------------- virtual void SetDlgStyle(DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT); // ---------------------------------------------------------------------------- // Summary: // This member function sets the file filter for the File Open // dialog. // Parameters: // lpszFilter - [in] Points to a NULL terminated string that represents the // \file filter used by the File Open dialog. // ---------------------------------------------------------------------------- void SetDlgFilter(LPCTSTR lpszFilter = NULL); // -------------------------------------------------------------------------- // Summary: // This member function sets the title for the directory dialog. // Parameters: // lpszTitle - [in] Points to a NULL terminated string the represents the // title of the "browse for directory" dialog. // -------------------------------------------------------------------------- void SetDlgTitle(LPCTSTR lpszTitle = NULL); // -------------------------------------------------------------------------- // Summary: // This member function sets the initial directory for the directory dialog. // Parameters: // lpszInitialDir - [in] Points to a NULL terminated string the represents the // initial directory of the dialog. // -------------------------------------------------------------------------- void SetDlgInitialDir(LPCTSTR lpszInitialDir); // ----------------------------------------------------------------------------- // Summary: // This member function is called to initialize the browse edit // control. // Parameters: // pParentWnd - [in] Pointer to the parent of the edit control. // dwBStyle - [in] A DWORD value that represents the type of // search to perform. It can be any one of the styles listed // in the remarks section. // nMenu - [in] If dwBStyle contains the BES_XTP_POPUPMENU flag, // then nMenu represents the resource ID of a popup // menu. Otherwise this value is ignored. // nSubMenuIndx - [in] Index of submenu to display. // Remarks: // The Initialize function must be called once for each browse edit // control to complete initialization. This should be done after you // have subclassed or created the browse edit control.
// // The browse edit control can be defined to use any of the following // styles: // * BES_XTP_CHOOSEDIR Display the choose folder dialog. // * BES_XTP_CHOOSEFILE Display the choose file dialog. // * BES_XTP_POPUPMENU Display a user defined context menu. // // The single argument version of Initialize will call the CXTPEdit // base class to initialize the edit portion of the control only, // generally you would not want to use this override for standard // initialization. // Example: // The following example demonstrates the use of Initialize. //
// BOOL CBrowseEditDlg::OnInitDialog()
// {
// CXTPResizeDialog::OnInitDialog();
// ...
// // Initialize browse edit controls.
// m_edit1.Initialize(this, BES_XTP_POPUPMENU, IDR_POPUP);
// m_edit2.Initialize(this, BES_XTP_CHOOSEDIR);
// m_edit3.Initialize(this, BES_XTP_CHOOSEFILE);
//
// return TRUE; // return TRUE unless you set the focus to a control
// }
//
// Returns:
// TRUE if initialization was successful, otherwise FALSE.
// -----------------------------------------------------------------------------
virtual bool Initialize(CWnd* pParentWnd, DWORD dwBStyle, UINT nMenu = 0, int nSubMenuIndx = 0);
virtual bool Initialize(CWnd* pParentWnd); //