16,473
社区成员
发帖
与我相关
我的任务
分享
void CLeftFindDlg::OnBnClickedLeftfindButton()
{
MessageBox(_T("test"));
}
BEGIN_MESSAGE_MAP(CLeftFindDlg, CDHtmlDialog)
ON_BN_CLICKED(IDC_LeftFind_Button, &CLeftFindDlg::OnBnClickedLeftfindButton)
END_MESSAGE_MAP()
#pragma once
#ifdef _WIN32_WCE
#error "CDHtmlDialog is not supported for Windows CE."
#endif
// CLeftFindDlg dialog
class CLeftFindDlg : public CDHtmlDialog
{
DECLARE_DYNCREATE(CLeftFindDlg)
public:
CLeftFindDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CLeftFindDlg();
// Overrides
HRESULT OnButtonOK(IHTMLElement *pElement);
HRESULT OnButtonCancel(IHTMLElement *pElement);
// Dialog Data
enum { IDD = IDD_LeftFind_Dialog, IDH = IDR_HTML_LEFTFINDDLG3 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
DECLARE_DHTML_EVENT_MAP()
public:
DECLARE_EVENTSINK_MAP()
afx_msg void OnBnClickedLeftfindButton();
};
CDialog* dlg = new CDialog;
dlg->Create(MAKEINTRESOURCE(IDD_LeftFind_Dialog));
dlg->ShowWindow(1);
改成这种方式就好了:
CLeftFindDlg dlg;
dlg.DoModal();
至于为什么就不知道了
#pragma once
// CLeftFindDlg dialog
class CLeftFindDlg : public CDialog
{
DECLARE_DYNAMIC(CLeftFindDlg)
public:
CLeftFindDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CLeftFindDlg();
// Dialog Data
enum { IDD = IDD_LeftFind_Dialog };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedLeftfindButton();
virtual BOOL OnInitDialog();
};
.cpp:
// LeftFindDlg.cpp : implementation file
//
#include "stdafx.h"
#include "net_test2.h"
#include "LeftFindDlg.h"
// CLeftFindDlg dialog
IMPLEMENT_DYNAMIC(CLeftFindDlg, CDialog)
CLeftFindDlg::CLeftFindDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLeftFindDlg::IDD, pParent)
{
}
CLeftFindDlg::~CLeftFindDlg()
{
}
void CLeftFindDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CLeftFindDlg, CDialog)
ON_BN_CLICKED(IDCANCEL, &CLeftFindDlg::OnBnClickedCancel)
ON_BN_CLICKED(IDC_LeftFind_Button, &CLeftFindDlg::OnBnClickedLeftfindButton)
END_MESSAGE_MAP()
// CLeftFindDlg message handlers
void CLeftFindDlg::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
OnCancel();
}
void CLeftFindDlg::OnBnClickedLeftfindButton()
{
// TODO: Add your control notification handler code here
MessageBox(_T("test"));
}
BOOL CLeftFindDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
class CLeftFindDlg : public CDialog
{
DECLARE_DYNCREATE(CLeftFindDlg)
public:
CLeftFindDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CLeftFindDlg();
// Dialog Data
enum { IDD = IDD_LeftFind_Dialog};
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedLeftfindButton();
};
cpp中你对应着.h自己改吧 enum { IDD = IDD_LeftFind_Dialog, IDH = IDR_HTML_LEFTFINDDLG3 };
可能是这句有问题吗?