Click here to Skip to main content
15,912,457 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Group box repaint problem in MDI Child Window Pin
David Crow7-Dec-04 9:21
David Crow7-Dec-04 9:21 
GeneralSolution in my own backyard ... : ) Pin
FreeSync7-Dec-04 10:41
sussFreeSync7-Dec-04 10:41 
GeneralCalling an EXE from a dialog app Pin
ravagga7-Dec-04 5:46
ravagga7-Dec-04 5:46 
GeneralRe: Calling an EXE from a dialog app Pin
BlackDice7-Dec-04 6:25
BlackDice7-Dec-04 6:25 
GeneralRe: Calling an EXE from a dialog app Pin
User 66587-Dec-04 6:43
User 66587-Dec-04 6:43 
GeneralRe: Calling an EXE from a dialog app Pin
David Crow7-Dec-04 7:37
David Crow7-Dec-04 7:37 
GeneralRe: Calling an EXE from a dialog app Pin
toxcct7-Dec-04 21:43
toxcct7-Dec-04 21:43 
GeneralStreams and MFC Pin
sweep1237-Dec-04 5:15
sweep1237-Dec-04 5:15 
This bit of code runs OK as a Win32 program:-

#include <iostream><br />
#include <fstream><br />
#include <string><br />
using namespace std;<br />
<br />
// Purpose:   Write to text file<br />
<br />
int main(int argc, char * argv[]) {<br />
    string OutFile;<br />
    fstream OutStream;<br />
<br />
    cout << "Please enter output file name: " ;<br />
    cin >> OutFile;<br />
<br />
    OutStream.open(OutFile.c_str(), ios::out | ios::trunc);<br />
<br />
// make sure file is successfully opened<br />
    if(!OutStream) {<br />
        cout << "Error open file " << OutFile << " for writing\n";<br />
        return 1;<br />
    }<br />
<br />
// Write the following two lines to file<br />
    OutStream<<"It is easier to resist at the beginning than at the end.\n";<br />
    OutStream <<"                 -- Leonardo da Vinci" << endl;<br />
<br />
    OutStream.close();                            // close output stream<br />
    cout << "Content written to " << OutFile <<".\n";<br />
    return 0;<br />
}


But if I try the code in an MFC dialog application I get the following errors:-
c:\C_Example\DiagnosticsDlg.cpp(177): error C2039: '_open' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'
with [ _Elem=char, _Traits=std::char_traits<char> ]
c:\C_Example\DiagnosticsDlg.cpp(177): error C2039: 'truc' : is not a member of 'std::basic_ios<_Elem,_Traits>' with [_Elem=char, _Traits=std::char_traits<char>]


Now if I use the statement to create/open the file

ofstream OutStream(OutFile); // Open an output stream

That seems to work, but as file not closed (as error with OutStream.close() so it is empty when viewed.
Is it a Namespace problem with the MFC classes!?!

GeneralRe: Streams and MFC Pin
Neville Franks7-Dec-04 9:04
Neville Franks7-Dec-04 9:04 
GeneralRe: Streams and MFC Pin
sweep1237-Dec-04 21:51
sweep1237-Dec-04 21:51 
GeneralRe: Streams and MFC Pin
Neville Franks7-Dec-04 23:52
Neville Franks7-Dec-04 23:52 
GeneralRe: Streams and MFC Pin
sweep1237-Dec-04 21:58
sweep1237-Dec-04 21:58 
GeneralVC++ Profiler Pin
Paper#7-Dec-04 5:05
Paper#7-Dec-04 5:05 
GeneralRe: VC++ Profiler Pin
Neville Franks7-Dec-04 9:08
Neville Franks7-Dec-04 9:08 
GeneralRe: VC++ Profiler Pin
John R. Shaw7-Dec-04 12:44
John R. Shaw7-Dec-04 12:44 
Generalwhy SCL not support Unicode filename Pin
sprewellkobe7-Dec-04 4:11
sprewellkobe7-Dec-04 4:11 
GeneralModifying a Bitmap Pin
nripun7-Dec-04 2:52
nripun7-Dec-04 2:52 
GeneralRe: Modifying a Bitmap Pin
John R. Shaw7-Dec-04 13:12
John R. Shaw7-Dec-04 13:12 
GeneralResizing Activex control Pin
Almenara7-Dec-04 2:16
Almenara7-Dec-04 2:16 
GeneralRe: Resizing Activex control Pin
Cedric Moonen7-Dec-04 2:21
Cedric Moonen7-Dec-04 2:21 
GeneralShell Notify ( icons disappeas on mouse over) Pin
Abhi Lahare7-Dec-04 2:13
Abhi Lahare7-Dec-04 2:13 
GeneralNo &quot;Press any key to continue&quot; Pin
Member 9504207-Dec-04 1:59
Member 9504207-Dec-04 1:59 
GeneralRe: No &quot;Press any key to continue&quot; Pin
David Crow7-Dec-04 3:33
David Crow7-Dec-04 3:33 
GeneralRe: No &quot;Press any key to continue&quot; Pin
Member 9504207-Dec-04 8:32
Member 9504207-Dec-04 8:32 
GeneralRe: No &quot;Press any key to continue&quot; Pin
David Crow7-Dec-04 9:15
David Crow7-Dec-04 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.