// E1605Dlg.h : header file
//#if !defined(AFX_E1605DLG_H__D2E69D95_9397_4BA5_80EB_F977CC5F6815__INCLUDED_)
#define AFX_E1605DLG_H__D2E69D95_9397_4BA5_80EB_F977CC5F6815__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000/////////////////////////////////////////////////////////////////////////////
// CE1605Dlg dialog
#define WM_RESULT (WM_USER+100)class CE1605Dlg : public CDialog
{
// Construction
public:
CE1605Dlg(CWnd* pParent = NULL); // standard constructor
UINT CalcThreadProc(LPVOID pParam);
// Dialog Data
//{{AFX_DATA(CE1605Dlg)
enum { IDD = IDD_E1605_DIALOG };
int m_n1;
int m_n2;
int m_result;
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CE1605Dlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
HICON m_hIcon; // Generated message map functions
//{{AFX_MSG(CE1605Dlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg LONG OnResult(WPARAM wParam,LPARAM lParam);
afx_msg void OnButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_E1605DLG_H__D2E69D95_9397_4BA5_80EB_F977CC5F6815__INCLUDED_)===================================================================================// E1605Dlg.cpp : implementation file
//#include "stdafx.h"
#include "E1605.h"
#include "E1605Dlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
{
public:
CAboutDlg();// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
ON_MESSAGE(WM_RESULT,OnResult) //------error(A)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CE1605Dlg dialogCE1605Dlg::CE1605Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CE1605Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CE1605Dlg)
m_n1 = 0;
m_n2 = 0;
m_result = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CE1605Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CE1605Dlg)
DDX_Text(pDX, IDC_EDIT1, m_n1);
DDX_Text(pDX, IDC_EDIT2, m_n2);
DDX_Text(pDX, IDC_EDIT3, m_result);
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CE1605Dlg, CDialog)
//{{AFX_MSG_MAP(CE1605Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CE1605Dlg message handlersBOOL CE1605Dlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}void CE1605Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.void CE1605Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CE1605Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
UINT CalcThreadProc(LPVOID pParam)
{
CE1605Dlg * pDlg=(CE1605Dlg *)pParam;
int n1=pDlg->m_n1;
int n2=pDlg->m_n2;
LONG IResult=(n1+n2)*(n1-n2)/100;
::PostMessage(pDlg->GetSafeHwnd(),
WM_RESULT,
(WPARAM)IResult,
0);
return 0;
}
LONG CE1605Dlg::OnResult(WPARAM wParam,LPARAM lParam)
{
m_result=(long)wParam;
UpdateData(FALSE);
return 0;
}void CE1605Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
AfxBeginThread(CalcThreadProc,
this,
THREAD_PRIORITY_NORMAL,
0,
0,
NULL); //------error(B)
}------------------------------------
错误信息如下:
error(A):
error C2065: 'OnResult' : undeclared identifier
error C2440: 'type cast' : cannot convert from 'int *' to 'long (__thiscall CWnd::*)(unsigned int,long)'
There is no context in which this conversion is possible
error(B):
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'--------------------------------------------
请各位看一下,谢谢!
//#if !defined(AFX_E1605DLG_H__D2E69D95_9397_4BA5_80EB_F977CC5F6815__INCLUDED_)
#define AFX_E1605DLG_H__D2E69D95_9397_4BA5_80EB_F977CC5F6815__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000/////////////////////////////////////////////////////////////////////////////
// CE1605Dlg dialog
#define WM_RESULT (WM_USER+100)class CE1605Dlg : public CDialog
{
// Construction
public:
CE1605Dlg(CWnd* pParent = NULL); // standard constructor
UINT CalcThreadProc(LPVOID pParam);
// Dialog Data
//{{AFX_DATA(CE1605Dlg)
enum { IDD = IDD_E1605_DIALOG };
int m_n1;
int m_n2;
int m_result;
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CE1605Dlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
HICON m_hIcon; // Generated message map functions
//{{AFX_MSG(CE1605Dlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg LONG OnResult(WPARAM wParam,LPARAM lParam);
afx_msg void OnButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_E1605DLG_H__D2E69D95_9397_4BA5_80EB_F977CC5F6815__INCLUDED_)===================================================================================// E1605Dlg.cpp : implementation file
//#include "stdafx.h"
#include "E1605.h"
#include "E1605Dlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
{
public:
CAboutDlg();// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
ON_MESSAGE(WM_RESULT,OnResult) //------error(A)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CE1605Dlg dialogCE1605Dlg::CE1605Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CE1605Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CE1605Dlg)
m_n1 = 0;
m_n2 = 0;
m_result = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CE1605Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CE1605Dlg)
DDX_Text(pDX, IDC_EDIT1, m_n1);
DDX_Text(pDX, IDC_EDIT2, m_n2);
DDX_Text(pDX, IDC_EDIT3, m_result);
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CE1605Dlg, CDialog)
//{{AFX_MSG_MAP(CE1605Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CE1605Dlg message handlersBOOL CE1605Dlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}void CE1605Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.void CE1605Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CE1605Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
UINT CalcThreadProc(LPVOID pParam)
{
CE1605Dlg * pDlg=(CE1605Dlg *)pParam;
int n1=pDlg->m_n1;
int n2=pDlg->m_n2;
LONG IResult=(n1+n2)*(n1-n2)/100;
::PostMessage(pDlg->GetSafeHwnd(),
WM_RESULT,
(WPARAM)IResult,
0);
return 0;
}
LONG CE1605Dlg::OnResult(WPARAM wParam,LPARAM lParam)
{
m_result=(long)wParam;
UpdateData(FALSE);
return 0;
}void CE1605Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
AfxBeginThread(CalcThreadProc,
this,
THREAD_PRIORITY_NORMAL,
0,
0,
NULL); //------error(B)
}------------------------------------
错误信息如下:
error(A):
error C2065: 'OnResult' : undeclared identifier
error C2440: 'type cast' : cannot convert from 'int *' to 'long (__thiscall CWnd::*)(unsigned int,long)'
There is no context in which this conversion is possible
error(B):
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'--------------------------------------------
请各位看一下,谢谢!
解决方案 »
- 关于串口传输音频信号或声音文件的问题
- 菜鸟提问,请高手指点!
- 请教 对话框弹出后不能操作
- vc安装问题
- VC6+VisualAssistX+金山词霸2005
- 一个类中两个构造函数之间可以相互调用吗?如何做?谢谢。
- 需要开发人员:IC卡门禁消费、停车场管理、短信软件开发、管理软件开发(JAVA,JSP)。
- VC读取PPT后怎么样才能完全退出?(关闭进程)
- 线程的同步问题
- vc中字符串前面加_T与不加_T会有什么区别?我查msdn 知是说与unicode有关,没有说清楚!
- 写个客户端来测试内网中的服务器。如何保证客户端的最大性能
- LittleEndian::Read和write怎么使用?怎么我在MSDN查不到它们
最好把OnResult改成&CE1605Dlg::OnResult
AfxBeginThread(CalcThreadProc,
this); //就可以.
依然不行,为什么?
当为静态成员函数时,错误如下:
error LNK2001: unresolved external symbol "public: static unsigned int __cdecl CE1605Dlg::CalcThreadProc(void *)" (?CalcThreadProc@CE1605Dlg@@SAIPAX@Z)
Debug/E1605.exe : fatal error LNK1120: 1 unresolved externals
当为全局函数时,运行成功。
非常感谢你们的纠正,谢谢!