问题描述
- 调试没错,运行就有错了。。Unhandled exception at 0x10002c64
- 调试没错,运行就有错了。。Unhandled exception at 0x10002c64 in DIPAX.exe: 0xC0000005: Access violation writing location 0x00000000.
头文件:#pragma once
// CMixDlg dialog
class CMixDlg : public CDialogEx
{
DECLARE_DYNAMIC(CMixDlg)public:
CMixDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CMixDlg();/*void SetWindowSize(int m_nxsize int m_nysize);*/
// Dialog Data
enum { IDD = IDD_MIX_DIALOG };protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV supportDECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
//定义主窗口指针
CWnd *m_pParent;
//定义图像指针
//BYTE *m_pImage_in;
// BYTE *m_pImage_out;
//定义图像大小
int m_nxsize1;
int m_nysize1;int m_nxsize2;int m_nysize2;BYTE *m_pImage_in1_r;BYTE *m_pImage_in1_g; BYTE *m_pImage_in1_b;BYTE *m_pImage_in2_r;BYTE *m_pImage_in2_g; BYTE *m_pImage_in2_b;BYTE *m_pImage_out_r;BYTE *m_pImage_out_g; BYTE *m_pImage_out_b;BYTE *m_pImage_key;int m_nModel;int m_nHardkey;int m_nSoftkey;int m_nTh;int Thmin;int Thmax;int m_nHardmix;afx_msg void OnBnClickedUppic();afx_msg void OnBnClickedBackpic();afx_msg void OnBnClickedUppicRadio();afx_msg void OnBnClickedBackpicRadio();afx_msg void OnBnClickedHardkey();afx_msg void OnBnClickedSoftkey();afx_msg void OnBnClickedHardRadio();afx_msg void OnBnClickedCancel();
};
cpp文件
// MixDlg.cpp : implementation file
//#include ""stdafx.h""
#include ""DIPAX.h""
#include ""MixDlg.h""
#include ""afxdialogex.h""
#include ""Global.h""
#include ""BaseList.h""
#include ""DIPAXDoc.h""
#include ""DIPAXView.h""// CMixDlg dialog
IMPLEMENT_DYNAMIC(CMixDlg CDialogEx)
CMixDlg::CMixDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CMixDlg::IDD pParent)
m_nModel(0)
m_nHardkey(0)
m_nSoftkey(0)
m_nTh(10)
Thmin(10)
Thmax(200)
m_nHardmix(0)
{
// 保存主窗口句柄
m_pParent=pParent;// 初始化图像指针/*m_pImage_in=NULL;m_pImage_out=NULL;*/m_pImage_in1_r=NULL;m_pImage_in1_g=NULL; m_pImage_in1_b=NULL;m_pImage_in2_r=NULL;m_pImage_in2_g=NULL;m_pImage_in2_b=NULL;m_pImage_out_r=NULL;m_pImage_out_g=NULL; m_pImage_out_b=NULL;m_pImage_key=NULL;
}
CMixDlg::~CMixDlg()
{
}void CMixDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Radio(pDX IDC_UPPIC_RADIO m_nModel);
DDX_Radio(pDX IDC_HARDKEY m_nHardkey);
DDX_Radio(pDX IDC_SOFTKEY m_nSoftkey);
DDX_Text(pDX IDC_THARD_EDIT m_nTh);
DDX_Text(pDX IDC_TSOFT_MIN Thmin);
DDX_Text(pDX IDC_TSOFT_MAX Thmax);
DDX_Radio(pDX IDC_HARD_RADIO m_nHardmix);
}BEGIN_MESSAGE_MAP(CMixDlg CDialogEx)
ON_BN_CLICKED(IDC_UPPIC &CMixDlg::OnBnClickedUppic)ON_BN_CLICKED(IDC_BACKPIC &CMixDlg::OnBnClickedBackpic)ON_BN_CLICKED(IDC_UPPIC_RADIO &CMixDlg::OnBnClickedUppicRadio)ON_BN_CLICKED(IDC_BACKPIC_RADIO &CMixDlg::OnBnClickedBackpicRadio)ON_BN_CLICKED(IDC_HARDKEY &CMixDlg::OnBnClickedHardkey)ON_BN_CLICKED(IDC_SOFTKEY &CMixDlg::OnBnClickedSoftkey)ON_BN_CLICKED(IDC_HARD_RADIO &CMixDlg::OnBnClickedHardRadio)ON_BN_CLICKED(IDCANCEL &CMixDlg::OnBnClickedCancel)
END_MESSAGE_MAP()
// CMixDlg message handlers
BOOL CMixDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();// TODO: Add extra initialization here// 获得图像大小m_nxsize1=::GetXSize();m_nysize1=::GetYSize();m_nxsize2=::GetXSize();m_nysize2=::GetYSize();//图像时退出if(::GetImageType()==8) return FALSE;//分配内存m_pImage_in1_r=new BYTE[m_nxsize1*m_nysize1];m_pImage_in1_g=new BYTE[m_nxsize1*m_nysize1];m_pImage_in1_b=new BYTE[m_nxsize1*m_nysize1];m_pImage_in2_r=new BYTE[m_nxsize2*m_nysize2];m_pImage_in2_g=new BYTE[m_nxsize2*m_nysize2];m_pImage_in2_b=new BYTE[m_nxsize2*m_nysize2];m_pImage_out_r=new BYTE[m_nxsize2*m_nysize2];m_pImage_out_g=new BYTE[m_nxsize2*m_nysize2];m_pImage_out_b=new BYTE[m_nxsize2*m_nysize2];m_pImage_key=new BYTE[m_nxsize1*m_nysize1];//读入图像数据::ReadImageDataRGB(m_pImage_in1_rm_pImage_in1_gm_pImage_in1_b);::ReadImageDataRGB(m_pImage_in2_rm_pImage_in2_gm_pImage_in2_b);return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE
}
void CMixDlg::OnBnClickedUppic()
{
// TODO: Add your control notification handler code here//读入位图文件int rnt;rnt = ::Load_imagefile_bmp();if(rnt == 0) return;m_nxsize1 = ::GetXSize();m_nysize1 = ::GetYSize();//设定图像窗口大小((CDIPAXView*)m_pParent) -> SetWindowSize(m_nxsize1 m_nysize1);//更新画面/*Invalidate();*///判断图像格式if( ::GetImageType() == 24){ //消除老图像数据 if(m_pImage_in1_r != NULL) { delete[] m_pImage_in1_r; m_pImage_in1_r = NULL; } if(m_pImage_in1_g != NULL) { delete[] m_pImage_in1_g; m_pImage_in1_g = NULL; } if(m_pImage_in1_b != NULL) { delete[] m_pImage_in1_b; m_pImage_in1_b = NULL; } //读入新图像数据 ::ReadImageDataRGB(m_pImage_in1_rm_pImage_in1_g m_pImage_in1_b);}//更新画面m_pParent->Invalidate();
}
void CMixDlg::OnBnClickedBackpic()
{
// TODO: Add your control notification handler code here//读入位图文件int rnt;rnt = ::Load_imagefile_bmp();if(rnt == 0) return;m_nxsize2 = ::GetXSize();m_nysize2 = ::GetYSize();//设定图像窗口大小((CDIPAXView*)m_pParent) ->SetWindowSize(m_nxsize2 m_nysize2);//更新画面/*Invalidate();*///判断图像格式if( ::GetImageType() == 24){ //消除老图像数据 if(m_pImage_in2_r != NULL) { delete[] m_pImage_in2_r; m_pImage_in2_r = NULL; } if(m_pImage_in2_g != NULL) { delete[] m_pImage_in2_g; m_pImage_in2_g = NULL; } if(m_pImage_in2_b != NULL) { delete[] m_pImage_in2_b; m_pImage_in2_b = NULL; } //读入新图像数据 ::ReadImageDataRGB(m_pImage_in2_rm_pImage_in2_g m_pImage_in2_b);}//更新画面m_pParent->Invalidate();
}
void CMixDlg::OnBnClickedUppicRadio()
{
// TODO: Add your control notification handler code here
//表示处理后图像
::Disp_imageRGB(m_pImage_in1_r m_pImage_in1_g m_pImage_in1_b);//更新图像画面m_pParent->Invalidate();
}
void CMixDlg::OnBnClickedBackpicRadio()
{
// TODO: Add your control notification handler code here
//表示处理后图像
::Disp_imageRGB(m_pImage_in2_r m_pImage_in2_g m_pImage_in2_b);//更新图像画面m_pParent->Invalidate();
}
void CMixDlg::OnBnClickedHardkey()
{
// TODO: Add your control notification handler code here
// 获得窗口数据
UpdateData(TRUE);//处理Hard_key(m_pImage_in1_r m_pImage_in1_g m_pImage_in1_bm_pImage_key m_nxsize1m_nysize1 m_nTh);//表示处理结果::Disp_image(m_pImage_key);//更新图像画面m_pParent->Invalidate();
}
void CMixDlg::OnBnClickedSoftkey()
{
// TODO: Add your control notification handler code here
// 获得窗口数据
UpdateData(TRUE);//处理Soft_key(m_pImage_in1_r m_pImage_in1_g m_pImage_in1_bm_pImage_key m_nxsize1m_nysize1ThmaxThmin);//表示处理结果::Disp_image(m_pImage_key);//更新图像画面m_pParent->Invalidate();
}
void CMixDlg::OnBnClickedHardRadio()
{
// TODO: Add your control notification handler code here
// 获得窗口数据
UpdateData(TRUE);//处理if (m_nHardmix==0){ Synth(m_pImage_in1_r m_pImage_in1_g m_pImage_in1_bm_pImage_in2_r m_pImage_in2_g m_pImage_in2_b m_pImage_out_r m_pImage_out_g m_pImage_out_bm_pImage_keym_nxsize1m_nysize1);}else{ S_synth(m_pImage_in1_r m_pImage_in1_g m_pImage_in1_bm_pImage_in2_r m_pImage_in2_g m_pImage_in2_b m_pImage_out_r m_pImage_out_g m_pImage_out_bm_pImage_keym_nxsize1m_nysize1);}//表示处理结果::Disp_imageRGB(m_pImage_out_r m_pImage_out_g m_pImage_out_b);//更新图像画面m_pParent->Invalidate();
}
void CMixDlg::OnBnClickedCancel()
{
// TODO: Add your control notification handler code heredelete[] m_pImage_in1_r;delete[] m_pImage_in1_g;delete[] m_pImage_in1_b;delete[] m_pImage_in2_r;delete[] m_pImage_in2_g;delete[] m_pImage_in2_b;delete[] m_pImage_out_r;delete[] m_pImage_out_g;delete[] m_pImage_out_b;delete[] m_pImage_key;CDialogEx::OnCancel();
}
解决方案
CFileDialog 的unhandled exception at
Eclipse运行报错,提示Unhandled event loop exception No more handles
错误 1 error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value
解决方案二:
1.弹出错误提示框后,点击重试
2.按Alt+7 调出CallStack对话框
3.找到错误位置,处理错误