VS2005 MFC 对话框 类外的普通函数 怎么调用类内的成员
//CMFC_VideoDlg.h文件classCMFC_VideoDlg:publicCDialog{//Constructionpublic:CMFC_VideoDl...
//CMFC_VideoDlg.h文件
class CMFC_VideoDlg : public CDialog
{
// Construction
public:
CMFC_VideoDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_MFC_VIDEO_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
//*********************************Added
HANDLE hThread;
DWORD ThreadID;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1Open();
public:
IplImage* m_ShowVideo;
public:
void DrawPicToHDC(IplImage* img, UINT ID);
public:
afx_msg void OnBnClickedButton1();
public:
afx_msg void OnBnClickedButton3Capture();
public:
IplImage* m_Show_Image;
public:
afx_msg void OnBnClickedButton2Close();
};
//*********************************Added
void Thread1videoFunc();
//函数的定义在.cpp文件中
void Thread1videoFunc()
{
capture=cvCreateCameraCapture(CV_CAP_ANY);
m_bVideo=TRUE;
while(m_bVideo)
{
m_ShowVideo=cvQueryFrame(capture);
DrawPicToHDC(m_ShowVideo,IDC_Picture_Video);
}
}
但是 编译出错 说是 m_ShowVideo DrawPicToHDC() 木有定义 可是 该怎么调用 展开
class CMFC_VideoDlg : public CDialog
{
// Construction
public:
CMFC_VideoDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_MFC_VIDEO_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
//*********************************Added
HANDLE hThread;
DWORD ThreadID;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1Open();
public:
IplImage* m_ShowVideo;
public:
void DrawPicToHDC(IplImage* img, UINT ID);
public:
afx_msg void OnBnClickedButton1();
public:
afx_msg void OnBnClickedButton3Capture();
public:
IplImage* m_Show_Image;
public:
afx_msg void OnBnClickedButton2Close();
};
//*********************************Added
void Thread1videoFunc();
//函数的定义在.cpp文件中
void Thread1videoFunc()
{
capture=cvCreateCameraCapture(CV_CAP_ANY);
m_bVideo=TRUE;
while(m_bVideo)
{
m_ShowVideo=cvQueryFrame(capture);
DrawPicToHDC(m_ShowVideo,IDC_Picture_Video);
}
}
但是 编译出错 说是 m_ShowVideo DrawPicToHDC() 木有定义 可是 该怎么调用 展开
3个回答
展开全部
在你的CMFC_VideoDlg类外定义一个全局变量
CMFC_VideoDlg *g_pDlg = NULL;
然后在OnInitDialog函数中加上这段代码: g_pDlg = this;
然后在你的Thread1videoFunc函数中这样使用
g_pDlg->m_ShowVideo = cvQueryFrame(capture);
g_pDlg->DrawPicToHDC(g_pDlg->m_ShowVideo, IDC_Pictrue_Video);
CMFC_VideoDlg *g_pDlg = NULL;
然后在OnInitDialog函数中加上这段代码: g_pDlg = this;
然后在你的Thread1videoFunc函数中这样使用
g_pDlg->m_ShowVideo = cvQueryFrame(capture);
g_pDlg->DrawPicToHDC(g_pDlg->m_ShowVideo, IDC_Pictrue_Video);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询