2 Replies - 1377 Views - Last Post: 31 October 2010 - 01:37 PM Rate Topic: -----

#1 iry  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 17-September 07

How to solve Error C2039: 'CFileDialog' : is not a member of &

Posted 30 October 2010 - 06:34 PM

i wanted to have an event handler where on button click, i can open an image.

but i'm having problem about using CFileDialog (Error C2039: 'CFileDialog' : is not a member of 'CWnd')

here is my code:
void MyAlbum::OnBnClickedBnbrowse()
{
GetDlgItem( IDC_BnBrowse ) -> 
  // TODO: Add your control notification handler code here
  	//Error 2039--------------------------					
  	CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, 	_T("image files (*.bmp; *.jpg) |*.bmp; *.jpg; *.jpeg | All Files (*.*) |*.*||"), NULL);
	dlg.m_ofn.lpstrTitle = _T("Open Image");	
	if( dlg.DoModal() != IDOK )					
		return;
	
	CString mPath = dlg.GetPathName();			

	IplImage* ipl = cvLoadImage( mPath, 1 );	
	if( !ipl )									
		return;
	if( TheImage )								
		cvZero( TheImage );
		
	ResizeImage( ipl );	
	ShowImage( TheImage, IDC_Iquery );	
	cvReleaseImage( &ipl );
}



is that because i missing some header file or something?

I tried to search on google and also forum, but i failed to find any solutions.
*I'm using VS2008 and OpenCv 2.8.11

Is This A Good Question/Topic? 0
  • +

Replies To: How to solve Error C2039: 'CFileDialog' : is not a member of &

#2 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 3875
  • View blog
  • Posts: 11,415
  • Joined: 18-April 07

Re: How to solve Error C2039: 'CFileDialog' : is not a member of &

Posted 30 October 2010 - 09:24 PM

That is because you have the line GetDlgItem( IDC_BnBrowse ) -> which is saying get the dialog window with the ID of IDC_BnBrowse and then look to call a method of that window returned. See the "->" part? So what the compiler is seeing is actually this...

GetDlgItem( IDC_BnBrowse ) -> CFileDialog dlg...



It then thinks you are trying to access a variable or method called "CFileDialog" from the window returned by GetDlgItem(). So you need to finish that line prior to calling the CFileDialog line or delete it since it is not doing anything at the moment anyways. Remember a semicolon ends a line.

Hope that helps you out. :)
Was This Post Helpful? 1
  • +
  • -

#3 iry  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 17-September 07

Re: How to solve Error C2039: 'CFileDialog' : is not a member of &

Posted 31 October 2010 - 01:37 PM

View PostMartyr2, on 30 October 2010 - 08:24 PM, said:

That is because you have the line GetDlgItem( IDC_BnBrowse ) -> which is saying get the dialog window with the ID of IDC_BnBrowse and then look to call a method of that window returned. See the "->" part? So what the compiler is seeing is actually this...

GetDlgItem( IDC_BnBrowse ) -> CFileDialog dlg...



It then thinks you are trying to access a variable or method called "CFileDialog" from the window returned by GetDlgItem(). So you need to finish that line prior to calling the CFileDialog line or delete it since it is not doing anything at the moment anyways. Remember a semicolon ends a line.

Hope that helps you out. :)


omg! :blush: :blush:
i think it should works now.. =X
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1