How bizzare....

Started by
4 comments, last by DanTheRocker 22 years, 5 months ago
I''m getting a strange side effect when I use the open file name dialog. After I select a file, some of my code stops working. Here is exactly where i am having the problem: Log( "Everything before this shows up\n" ); GetOpenFileName( ( LPOPENFILENAME ) &ofn ); Log( "THIS NEVER SHOWS UP....why???\n" ); The function Log() is one that I have made, it just copies the message to a log file. After I call GetOpenFileName, the log stops working for the rest of the duration of the program. Does GetOpenFileName do anything funky that I should be aware of?
-Dan
Advertisement
I think it depends on how you''ve implemented this Log() function (c++ streams, c functions??). Then you can also check why the log function doesn''t log the string to a file. But I really have no idea why this can conflict with GetOpenFileName()...
I''ve never used it and don''t know the syntax, but are you sure the function isn''t a callback?

Trying is the first step towards failure.
Trying is the first step towards failure.
if i recall correctly, GetOpenFileName() leaves the current directory of the program set to whichever directory you browse to in the open file dialog. so, if the Log() function opens the log file each time, the log file will be created in the directory that the open file dialog was last in...


no idea if that''s your problem, but it might be an idea to look around for fragments of your log file in strange places...
Here is the Log() function that I use. I''ve used it forever and never had a problem.

//-----------------------------------------------------------------------------
// Name: Log()
// Desc: Adds to the logfile
//-----------------------------------------------------------------------------
void Log( char *str )
{
static bool first_time = true;
ofstream fp;

if( first_time == true )
{
fp.open("log.txt");

fp << "//-----------------------------------------------------------------------------\n";
fp << "// File: log.txt\n";
fp << "//\n";
fp << "// Desc: Log File of the application''s activity\n";
fp << "//\n";
fp << "// Copyright (c) 2001 Dan\n";
fp << "//-----------------------------------------------------------------------------\n";
fp << "\n";

first_time = false;

fp.close();
}

fp.open("log.txt", ios::app);

fp << str;

fp.close();
}
-Dan
Oh geez, right when I post this it hit me. Mr Anonymous Poster is correct. It does change the directory. Thanks you!
-Dan

This topic is closed to new replies.

Advertisement