![]() |
| | #1 |
| Registered User Join Date: Mar 2009
Posts: 48
| 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. Code:
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 ();
//SetWindowText(fileName);
}
}
------ Build started: Project: AUConverter, Configuration: Debug Win32 ------ Compiling... AUConverter.cpp 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. BR! Pingz
__________________ -------------------------------------------------------- Newbie C/C#/C++ swimming/cycling/running There is nothing more powerful than an idea. Except for an idea put into action. -------------------------------------------------------- |
| userpingz is offline | |
| | #2 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,099
| MFC and Windows Form do not work together. Switch to native C++ or use the file dialog of C++/CLI.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C and C++ compile speed | swgh | General Discussions | 3 | 01-02-2007 02:37 PM |
| Compile as you type | Rocketmagnet | General Discussions | 33 | 12-07-2006 01:36 PM |
| How to compile mfc libs from platform sdk | tjcbs | Windows Programming | 6 | 11-19-2006 08:20 AM |
| Compile crashes certain windows | Loduwijk | C++ Programming | 5 | 03-26-2006 09:05 PM |
| How can I compile C or C++ with Visual Studio .NET? | Dakkon | C Programming | 8 | 02-11-2003 02:58 PM |