|
Use CFileDialog::GetPathName() to get the path of the file. Then open the file. Then read the data from the file.
|
|
|
|
|
ya i already used that.frm thre i can read only the 1st list.but iterating the list using Clist, it's not happening. can u tell me that? how to iterate in this file?
kamalesh
|
|
|
|
|
If you set the OFN_ALLOWMULTISELECT flag for the dialog, you use the following code to iterate through the list of path names:
CFileDialog dlg(...);
if (dlg.DoModal() == IDOK)<br />
{<br />
POSITION pos = dlg.GetStartPosition();<br />
while (NULL != pos)<br />
{<br />
CString newPath = dlg.GetNextPathName(pos);<br />
}
Is that what you are trying to do?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
-- modified at 15:29 Wednesday 21st June, 2006
|
|
|
|
|
kamalesh82 wrote: frm thre i can read only the 1st list
What list? Are you trying to read the contents of the selected file?
kamalesh82 wrote: ...but iterating the list using Clist...
How are you using CList ?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
and let me add...
|
|
|
|
|
if you want to read file and directory names with CListBox use DlgDirList
whitesky
|
|
|
|
|
I use function _gcvt() for convert the double value to string such as:
y = 0.01;
_gcvt(y,10,buffer);
MessageBox(buffer);
My problem is that the MessageBox will show "1.e-002".
How to do if want the string "0.01" after finish this function.
|
|
|
|
|
you could try doing a sprintf.
y = 0.01;
sprintf ( buffer, "%f", y );
|
|
|
|
|
Use
sprintf(buffer, "%f8.2", y); instead.
Best,
Jun
|
|
|
|
|
or see here
<br />
double y = 1230.01;<br />
CString strxx;<br />
strxx.Format("%lf", y );<br />
MessageBox(strxx);<br />
whitesky
|
|
|
|
|
Hi,
The below code for cfiledialog is have some problem. the problem is when i
press open many times the file dialog box opens ,but sometimes ( at any time ) when file dialog is open and if i press some starting character to select particular file ,the whole application closes automatically..
myclass::OnOpen() {
CFileDialog dlg(TRUE);
Sleep(50);
if (dlg.DoModal() == IDOK) {
l_strFileName = dlg.GetPathName();
MessageBox(l_strFileName);
filepath2 = (char *) (LPCTSTR) l_strFileName;
m_select.ShowWindow(SW_HIDE);
m_start.ShowWindow(SW_SHOW);
m_ed.SetWindowText(l_strFileName);
} }
Manjunath S
GESL
Bangalore
|
|
|
|
|
Manjunath S wrote: Sleep(50);
What's this for? A gratuitous Sleep() is usually an indication of something gone wrong.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi ,
If i remove sleep then also iam getting same error.
Manjunath S
GESL
Bangalore
|
|
|
|
|
Then you're giving the gratuity somewhere else.
|
|
|
|
|
can i get any sample code regarding ,to open fileopen dialog box
Manjunath S
GESL
Bangalore
|
|
|
|
|
Exactly what steps are you taking to reproduce the problem? Does it happen with every folder, or one in particular? What character are you typing? Is Enter/Return clicked? Does the same thing happen with GetOpenFileName() ?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
In every folder iam facing this problem,but not every time . once in while (frequency is 1 time for 20 times trying)my whole application closes....
Manjunath S
GESL
Bangalore
|
|
|
|
|
|
Manjunath S wrote: once in while (frequency is 1 time for 20 times trying)my whole application closes....
You've got problems elsewhere that are manifesting at the point in which you are using CFileDialog . This code should run 20+ times with no troubles:
CFileDialog dlg(TRUE);
if (dlg.DoModal() == IDOK)
AfxMessageBox(dlg.GetPathName());
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Just an FYI since I don't think these issues are causing this problem (at least not directly) ...
1) Manjunath S wrote: Sleep(50);
Chances are very high that if you are calling Sleep, something is wrong with your design. This is almost always the case when done in GUI code (as is the case here).
2) Manjunath S wrote: filepath2 = (char *) (LPCTSTR) l_strFileName;
LPCTSTR is defined as (const TCHAR*). Aside from the fact that the cast above won't work properly in a UNICODE build, it isn't want you want anyway. You aren't showing what you use filepath2 for, but I'm guessing you will either want it as a CString itself, a List/Array of CStrings, or don't need it at all.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
1.I deleted sleep
2.I need to pass filepath2 as a char* to a function in DLL.
Now the Modified code looks like this ...
void Upload::OnSelect()
{
CFileDialog upload(FALSE);
if(upload.DoModal() == IDOK) {
l_strFileName2 = upload.GetPathName();
MessageBox(l_strFileName2);
/* where filepath3 is a global char* variable */
filepath3 = (char *) (LPCTSTR) l_strFileName2;
m_start.ShowWindow(SW_SHOW);
m_select.ShowWindow(SW_HIDE);
m_edt.SetWindowText(l_strFileName2);
}
}
The above code problem is CfileDialog and whole application closes automatically (once in 18-20 times of Onselect is clicked) .The application closes when i try to select filename in filedialog using keyboard charater(i.e filename first character) )..
Thanking You
Manjunath S
GESL
Bangalore
|
|
|
|
|
Manjunath S wrote: 2.I need to pass filepath2 as a char* to a function in DLL.
Now the Modified code looks like this ...
And the DLL method doesn't take a const char*? If that is the case, what you are doing is still a problem. You are casting away the const on a CString object's private data (which you have no control over). Basically, if the CString object decides to clean up or allocate a bigger block, your pointer is out in the weeds. Try this:
char filepath3[_MAX_PATH] = {0};<br />
void Upload::OnSelect()<br />
{<br />
CFileDialog upload(FALSE);<br />
<br />
if(upload.DoModal() == IDOK) <br />
{<br />
l_strFileName2 = upload.GetPathName();<br />
MessageBox(l_strFileName2);<br />
<br />
strncpy(filepath3, l_strFileName2, _MAX_PATH);<br />
m_edt.SetWindowText(l_strFileName2);<br />
}<br />
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
why do you use Sleep?
whitesky
|
|
|
|
|
Are there any functions available to set the language used for menus/dialogs once a MUI is installed?
The user would manually configure this via: control panel -> regional & language options -> languages tab
Microsoft calls this the UI language and documents functions (GetSystemDefaultUILanguage, GetUserDefaultUILanguage) to get the value, but nothing to set it:
www.microsoft.com/globaldev/reference/localetable.mspx
Thanks for any help
|
|
|
|
|
Hi,
I have created MFC SDI application. I see the title as "Untitled App" after execution. How to change it to the desired one?
I don't see any caption in the form's properties. I have changed the caption
in AboutDialog, but that doesn't help to change to caption of the application.
Thank you.
Harsha
|
|
|
|