Thread: CFileDialog Compile Error. thanks.

  1. #1
    Registered User
    Join Date
    Mar 2009

    Cool CFileDialog Compile Error. thanks.


    Good day.

    I plan to creat a small tool which for convert Ascii file to UTF-8 file.
    I already find the piece of convert code.(in C++)

    Now i plan to build the simple form.
    When i click the "Select Source File" button, I want to select the source(ASCII) file.

    I add the below button1_click function at Form1.h file, but it compiled fialed.

    	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    		   // Create an Open dialog; the default file name extension is ".my".
    		   CFileDialog fileDlg (TRUE, _T("my"), _T("*.my"),
    			  OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||"), this);
         		   // Display the file dialog. When user clicks OK, fileDlg.DoModal() 
    		   // returns IDOK.
    		   if( fileDlg.DoModal ()==IDOK )
        		           CString pathName = fileDlg.GetPathName();
    			  // Implement opening and reading file in here.
    			  //Change the window's title to the opened file's title.
    			  CString fileName = fileDlg.GetFileTitle ();
    Compiled Output

    ------ Build started: Project: AUConverter, Configuration: Debug Win32 ------
    WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
    d:\learning\win\auconverter\auconverter\auconverte r\Form1.h(96) : error C2664: 'CFileDialog::CFileDialog(BOOL,LPCTSTR,LPCTSTR,DWO RD,LPCTSTR,CWnd *,DWORD)' : cannot convert parameter 6 from 'AUConverter::Form1 ^const ' to 'CWnd *'
    No user-defined-conversion operator available, or
    Cannot convert a managed type to an unmanaged type
    Build log was saved at "file://d:\learning\win\AUConverter\AUConverter\AUConverte r\Debug\BuildLog.htm"
    AUConverter - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Would you please give me some suggestion.

    Thanks in advance.

    There is nothing more powerful than an idea.
    Except for an idea put into action.

  2. #2
    Join Date
    Oct 2007
    Inside my computer
    MFC and Windows Form do not work together.
    Switch to native C++ or use the file dialog of C++/CLI.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C and C++ compile speed
    By swgh in forum A Brief History of
    Replies: 3
    Last Post: 01-02-2007, 02:37 PM
  2. Compile as you type
    By Rocketmagnet in forum A Brief History of
    Replies: 33
    Last Post: 12-07-2006, 01:36 PM
  3. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 08:20 AM
  4. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM
  5. How can I compile C or C++ with Visual Studio .NET?
    By Dakkon in forum C Programming
    Replies: 8
    Last Post: 02-11-2003, 02:58 PM