testDlg.cpp中:void CTestDlg::sign1(int number1)
{
char tmpstr[20];
sprintf(tmpstr, "%d", number1);
CWnd* pWnd = GetDlgItem(IDC_EDIT1);
pWnd->SetWindowText(tmpstr);
}void CTestDlg::OnButton3()
{
sign1(200) ;
}
sign1()调用正常;
在 MyThread.h 中:
#include "testDlg.h"
…………
// Attributes
public:
CTestDlg *mainDlg;
…………但是在int MyThread::Run()中用
mainDlg->sign1(100) ;一运行到此,就会出错:
Unhandled exception in test.exe(MFC42D.DLL)0xC0000005 Access Violation.本人刚用VC++,请问何故,如何解决?
{
char tmpstr[20];
sprintf(tmpstr, "%d", number1);
CWnd* pWnd = GetDlgItem(IDC_EDIT1);
pWnd->SetWindowText(tmpstr);
}void CTestDlg::OnButton3()
{
sign1(200) ;
}
sign1()调用正常;
在 MyThread.h 中:
#include "testDlg.h"
…………
// Attributes
public:
CTestDlg *mainDlg;
…………但是在int MyThread::Run()中用
mainDlg->sign1(100) ;一运行到此,就会出错:
Unhandled exception in test.exe(MFC42D.DLL)0xC0000005 Access Violation.本人刚用VC++,请问何故,如何解决?
解决方案 »
- 嗅探器 MFC程序崩溃?
- 用ODBC操作EXCEL出现的问题
- 请问 CFile能操作别人电脑上的文件吗 文件在共享文件夹里
- 请教一个图片填充的问题
- 文件读写共享问题
- Windows注册表编程:怎样在资源管理器里删除、添加鼠标右键快捷菜单的“新建”子菜单项啊?
- 有关多文档界面的菜单设置问题????
- 请问:想用VC进行windows网络编程,大家觉得入门书哪本比较好?
- 问题大讨论(来者有分):如何在vc中实现在对话框的特定位置使一字符串反复流动起来?
- ■■十万火急,紧急求教WIN2000-PROFESSOR的ADMINISTRATOR密码丢失,如何找回?找到,全部送分!!■■
- 消息处理的低级问题
- 谁知道怎样根据进程id判断这个进程在系统中是否存在?
you can sendmessage to the dialog!
另外,比如我想在窗体的Edit控件中显示数据,
又如何从线程发消息呀?
then in your thread function, you can use ::SendMessage send messge to your window.
in your window,you handle the message, do somthing!
CTestDlg *mainDlg;
mainDlg是NULL;如果你将CTestDlg *mainDlg;
申请为全局变量,并且在CTestDlg的OnInitDialog()中mainDlg=this;
并确保mythread在这以后才
mainDlg->sign1(100) ;