extra initialization in new window of a MFC/OpenCV project
I have a computer vision project using OpenCV and MFC for the GUI. I want to do the following: when i click Button1, i get a new window that displays a video then captures images by clicking on the buttons of that new window.
First, i had an MFC project with only the window that displays the video and it worked fine. Then i created a new project where i made that window comes after clicking on a button. Here is the code that i used to call that window.
void ClassTestDlg::OnBnClickedButton1()
{
CDialog ClassTestDlg(IDD_DIALOG_WindowDisplay);
ClassTestDlg.DoModal();
}
After clicking on button1, i can see the new window but the video doesn't display. The class of the new dialog doesn't contain an "OnInitDialog()" method and i don't know how to write extra initialization in this new class.
I am new to MFC so Help please. Thank you
You cannot instantiate a CDialog, only a class derived from CDialog.
Your button handler is in class ClassTestDlg, so why are you trying to create another ClassTestDlg? You need something like this:
void ClassFirstDlg::OnBnClickedButton1()
{
ClassSecondDlg dlg2;
dlg2.DoModal();
}
链接地址: http://www.djcxy.com/p/39238.html