Archived

This topic is now archived and is closed to further replies.

How bizzare....

This topic is 5884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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()...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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...

Share this post


Link to post
Share on other sites
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();
}

Share this post


Link to post
Share on other sites