HI
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);
}
}
Compiled Output
------ 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