sujan.dasmahapa 0 Light Poster

I am creating a view in the dialog.
when i am instantiating the dialog like this
CMyDialog dlg(NULL, L"filename.txt");
dlg.DoModal();

CMyDialog constructor I overloaded so that it takes a file name.

Now in the OnInitDialog() function I an intializing the view pointer m_pView and creating the view, toolbar , everything.

Can I use this m_pView in the constructor of the CMyDialog so that I want to call one function from the CMyView class which takes the filename (filename.txt) as the argument.

check the code of the CMyDialog constructor and OnInitDialog

CMyDialog::CMyDialog(CWnd* pParent /*=NULL*/, CString filename)
	: CDialog(CDlgsViewDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	if(!filename.IsEmpty()) {
	m_pView->loadProfile(filename);
}


BOOL CMyDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_pView = new CMyView();
	ShowWindow(SW_SHOWMAXIMIZED);
	CRect clientRect;
	GetClientRect(&clientRect);
	clientRect.DeflateRect(10, 30);
	if(! m_pView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD, clientRect,
							this, WM_USER))
	{
		MessageBox(L"Failed to create view");
	}

}

Is this code correct, m_pView will initialized before the constructor called right ? Can access m_pView in the constructor and call the function loadprofile() function which takes the file name.

I am calling this dialog in an extern C fucntion for dll

extern "C" BOOL __declspec(dllexport)runAppli(CString fileName)
{
        CDlgsViewDlg dlg(NULL, fileName);
	dlg.DoModal();
	return true;
}

I am getting error please help me whats going wrong in this ...Thanks a lot for any help.