我有.H文件和.Cpp文件用于对话框打印包含两个按钮打印机1和打印机2,我想在按下打印机1时调用另一个类功能中的方法。 .H文件
#pragma once
#ifndef PRINTCHOOSEDLG_H
#define PRINTCHOOSEDLG_H
class CPrintChooseDlg : public CTungstenDlg
{
public:
CPrintChooseDlg(CWnd* pParent = NULL);
enum { IDD = IDD_PRINTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
afx_msg void OnPrinter1();
afx_msg void OnPrinter2();
//virtual void OnPrinter1();
//virtual void OnPrinter2();
DECLARE_MESSAGE_MAP()
};
#endif
.CPP
#include "stdafx.h"
#include "Tungsten.h"
#include "PrintChooseDlg.h"
CPrintChooseDlg::CPrintChooseDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPrintChooseDlg::IDD, pParent)
{
}
void CPrintChooseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CPrintChooseDlg, CDialog)
ON_BN_CLICKED(IDC_PRINTER1,OnPrinter1)
ON_BN_CLICKED(IDC_PRINTER2,OnPrinter2)
END_MESSAGE_MAP()
void CPrintChooseDlg::OnPrinter1()
{
CTungstenDlg aux;
aux.OnOK();
}
void CPrintChooseDlg::OnPrinter2()
{
CTungstenDlg aux;
aux.OnOK();
}
如何在函数CTungsten::OnOK
CPrintChooseDlg::OnPrinter1()
它当然给了我一个错误,因为它没有在PrintChooseDlg.cpp中定义
我尝试的是:在标题中包含警卫并在评论中使用建议的解决方案 在此先感谢