CFileDialog implementation...
-
either open the File SAve as from ur dialog or make a member variable, and set it from the outside using a reference or a pointer to ur dialog Papa while (TRUE) Papa.WillLove ( Bebe ) ;
-
Hi, i made this "File save as.." dialog window but after this i don'really know how to insert or to connect the given name to my saving function which is in another dialog window? CString szlstfile = fileDlg.GetPathName(); //MainFrm.cpp SaveStream(szlstfile); //ContrDlg.cpp Thanks, Mark
What you have looks fine. Presumably SaveStream() will do something with the filename passed to it. What seems to be the problem?
-
What you have looks fine. Presumably SaveStream() will do something with the filename passed to it. What seems to be the problem?
-
Passing variables from one file to another is undefined. I assume you have a class defined in ControlDlg.cpp (e.g., CControlDlg) with at least one public method (e.g., SaveStream). In your CMainFrame class, you'll need an instance of the CControlDlg class, unless the method is static. Now it's just a matter of calling the CControlDlg's method, passing it the filename obtained from CFileDialog.
-
Hmm, sounds tricky.. I make a member variable(m_filename). Do u have a code snip for that? Thanks, Mark
in ur class: class urClass { private: CString m_fileName; /*(or array of char)*/ public: void SetFileName ( CString fileName ) ; }; and from another part of the world where this compile: urClass object; ... object.SetFileName ( "whateverPathToSet" ) ; Papa while (TRUE) Papa.WillLove ( Bebe ) ;
-
Passing variables from one file to another is undefined. I assume you have a class defined in ControlDlg.cpp (e.g., CControlDlg) with at least one public method (e.g., SaveStream). In your CMainFrame class, you'll need an instance of the CControlDlg class, unless the method is static. Now it's just a matter of calling the CControlDlg's method, passing it the filename obtained from CFileDialog.
-
Yes, thats right. I like to give the filename before data arrived.(it comes from the usb-port). The SaveStream() func is called during runtime when data arrives. How i can do that? I think the filename(variable is stored in RAM).. Thanks, Mark
Now you've really got me confused. In your OP, the filename was originally coming from CFileDialog::GetPathName(). You then wanted to pass that to the SaveStream() function. Perhaps you could explain in detail what you are after rather than just offer bits and pieces that just get construed along the way.
-
Now you've really got me confused. In your OP, the filename was originally coming from CFileDialog::GetPathName(). You then wanted to pass that to the SaveStream() function. Perhaps you could explain in detail what you are after rather than just offer bits and pieces that just get construed along the way.
I am sorry but thanks for your time. ---------------------------------------------------------------------------- //MainFrm.cpp void CMainFrame::OnDataSaveAs() { CFileDialog dlg(FALSE); CControlDlg cd; dlg.m_ofn.lpstrInitialDir = "F:"; dlg.DoModal(); if ( dlg.DoModal() == IDOK) { CString filename = dlg.GetPathName(); cd.SaveStream(filename); //doesn't work because no data at start } } ----------------------------------------------------------------------- //ControlDlg.cpp includes the main code for scanner void CControlDlg::OndataReady(LPUNKNOWN pDobj) { STGMEDIUM s; long hint = 0L; BOOL r = FALSE; COleDataObject foo; foo.Attach((LPDATAOBJECT)pDobj); r = ReadStream(pDobj, s, foo); if(r){ SaveStream(filename); //saving } } I like the user to choose a filename when my app starts, because this is a control programm for a 3d scanner over USB. When my app starts the scanner takes some scans every few seconds. So if the user select a filename at the start there is no data for the file at the begining. When the scanner sends the datafiles i like to save them incremently. For example: filename choosen is "File", then saved as: File_1 File_2 File_3 .... ..for this the prog has to know the last filename. This all i have to handle.
-
I am sorry but thanks for your time. ---------------------------------------------------------------------------- //MainFrm.cpp void CMainFrame::OnDataSaveAs() { CFileDialog dlg(FALSE); CControlDlg cd; dlg.m_ofn.lpstrInitialDir = "F:"; dlg.DoModal(); if ( dlg.DoModal() == IDOK) { CString filename = dlg.GetPathName(); cd.SaveStream(filename); //doesn't work because no data at start } } ----------------------------------------------------------------------- //ControlDlg.cpp includes the main code for scanner void CControlDlg::OndataReady(LPUNKNOWN pDobj) { STGMEDIUM s; long hint = 0L; BOOL r = FALSE; COleDataObject foo; foo.Attach((LPDATAOBJECT)pDobj); r = ReadStream(pDobj, s, foo); if(r){ SaveStream(filename); //saving } } I like the user to choose a filename when my app starts, because this is a control programm for a 3d scanner over USB. When my app starts the scanner takes some scans every few seconds. So if the user select a filename at the start there is no data for the file at the begining. When the scanner sends the datafiles i like to save them incremently. For example: filename choosen is "File", then saved as: File_1 File_2 File_3 .... ..for this the prog has to know the last filename. This all i have to handle.
I assume that OnDataSaveAs() is called when the "Save As" button is clicked, or when the "Save As" menu option is selected. Since this is a user-defined action, it may not have happened by the time your program needs the name of an output file (i.e., when calling SaveStream() from within CControlDlg::OndataReady(). It sounds like you need to check for the existance of an output filename before saving the data. Something like:
CControlDlg::OndataReady()
{
...
if (filename.IsEmpty() == TRUE)
{
CFileDialog dlg(FALSE);
dlg.DoModal();
filename = dlg.GetPathName();
}
...
SaveStream(filename); //saving
}You may need to remove like code from the CMainFrame::OnDataSaveAs() function.
-
I assume that OnDataSaveAs() is called when the "Save As" button is clicked, or when the "Save As" menu option is selected. Since this is a user-defined action, it may not have happened by the time your program needs the name of an output file (i.e., when calling SaveStream() from within CControlDlg::OndataReady(). It sounds like you need to check for the existance of an output filename before saving the data. Something like:
CControlDlg::OndataReady()
{
...
if (filename.IsEmpty() == TRUE)
{
CFileDialog dlg(FALSE);
dlg.DoModal();
filename = dlg.GetPathName();
}
...
SaveStream(filename); //saving
}You may need to remove like code from the CMainFrame::OnDataSaveAs() function.