为了实现像工具栏一样的对话框。我看了vc技术内幕,创建一个Dialog但是没有创建其类,而是把Dialog加到CMainFrame里面。
看不到任何关于Dialog 资源的Class .然后在CMainFrame Create 成功了。
然后通过class wizzard,可以在view类里面触发消息,可是就是不能添加对应的控件变量。
如CEdit等等。
怎么办?
如果要实现同样的功能还有其他方法吗?
看不到任何关于Dialog 资源的Class .然后在CMainFrame Create 成功了。
然后通过class wizzard,可以在view类里面触发消息,可是就是不能添加对应的控件变量。
如CEdit等等。
怎么办?
如果要实现同样的功能还有其他方法吗?
然后在CMainFrame里面创建。
可以加变量和消息,现在有两个问题。
第一个,我该按钮已经添加了消息函数,但是该按钮还是灰色的。
第二个,我好像不能像编辑控件中输入(不能用UpdateData函数,将出现终止错误)。
#define AFX_NAVIGATORDLG_H__EB3341B3_D421_4E46_9B40_2B82C2158DE7__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// NavigatorDlg.h : header file
//#include "Path.h"/////////////////////////////////////////////////////////////////////////////
// CNavigatorDlg dialogclass CNavigatorDlg : public CDialogBar
{
// Construction
public:
CPath m_Path;
CNavigatorDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data
//{{AFX_DATA(CNavigatorDlg)
enum { IDD = IDD_NAVIGATOR };
CComboBox m_PathNameCombo;
CButton m_CreatePathButton;
CString m_strPathName;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNavigatorDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected: // Generated message map functions
//{{AFX_MSG(CNavigatorDlg)
afx_msg void OnEditchangeSelectpath();
afx_msg void OnCreateNewPath();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_NAVIGATORDLG_H__EB3341B3_D421_4E46_9B40_2B82C2158DE7__INCLUDED_)
//#include "stdafx.h"
#include "face.h"
#include "NavigatorDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CNavigatorDlg dialog
CNavigatorDlg::CNavigatorDlg(CWnd* pParent /*=NULL*/)
// CDialogBar(CNavigatorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNavigatorDlg)
m_strPathName = _T("");
//}}AFX_DATA_INIT
}
void CNavigatorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogBar::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNavigatorDlg)
DDX_Control(pDX, IDC_SELECTPATH, m_PathNameCombo);
DDX_Control(pDX, IDC_CREATE_NEW_PATH, m_CreatePathButton);
DDX_CBString(pDX, IDC_SELECTPATH, m_strPathName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNavigatorDlg, CDialogBar)
//{{AFX_MSG_MAP(CNavigatorDlg)
ON_CBN_EDITCHANGE(IDC_SELECTPATH, OnEditchangeSelectpath)
ON_BN_CLICKED(IDC_CREATE_NEW_PATH, OnCreateNewPath)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CNavigatorDlg message handlers
void CNavigatorDlg::OnEditchangeSelectpath()
{
UpdateData(FALSE);
if(m_strPathName.IsEmpty())
{
m_CreatePathButton.EnableWindow(FALSE);
}
}void CNavigatorDlg::OnCreateNewPath()
{
if(m_strPathName.IsEmpty())
{
AfxMessageBox("路径名不能为空");
return ;
} if(m_PathNameCombo.FindStringExact(-1,m_strPathName) >= 0)
{
AfxMessageBox("路径名不能重名");
return;
} m_Path.AddNewPath(m_strPathName);//加入路径名
}