fixed: the program didn't use a correct path to the config and help file
this was introduced by the update and open/save dialog on the pad window git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@225 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
4346383c57
commit
e7ec06ea9d
|
@ -1138,7 +1138,7 @@ SHELLEXECUTEINFO exec;
|
||||||
exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
|
exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
|
||||||
exec.hwnd = 0;
|
exec.hwnd = 0;
|
||||||
exec.lpVerb = "open";
|
exec.lpVerb = "open";
|
||||||
exec.lpFile = "ttcalc.chm";
|
exec.lpFile = GetPrgRes()->GetHelpFile().c_str();
|
||||||
exec.lpParameters = 0;
|
exec.lpParameters = 0;
|
||||||
exec.lpDirectory = "";
|
exec.lpDirectory = "";
|
||||||
exec.nShow = SW_SHOWNORMAL;
|
exec.nShow = SW_SHOWNORMAL;
|
||||||
|
|
|
@ -821,7 +821,7 @@ ATOM a = RegisterPadClass(ttcalc_pad_class_name);
|
||||||
DEFAULT_QUALITY, DEFAULT_PITCH, "Ms Shell Dlg");
|
DEFAULT_QUALITY, DEFAULT_PITCH, "Ms Shell Dlg");
|
||||||
|
|
||||||
|
|
||||||
HWND pad = CreateWindowEx(0, ttcalc_pad_class_name,
|
HWND pad = CreateWindowEx(WS_EX_CLIENTEDGE, ttcalc_pad_class_name,
|
||||||
"Pad",
|
"Pad",
|
||||||
WS_OVERLAPPEDWINDOW | WS_POPUPWINDOW ,
|
WS_OVERLAPPEDWINDOW | WS_POPUPWINDOW ,
|
||||||
GetPrgRes()->GetPadXPos(), GetPrgRes()->GetPadYPos(),
|
GetPrgRes()->GetPadXPos(), GetPrgRes()->GetPadYPos(),
|
||||||
|
|
|
@ -645,6 +645,12 @@ return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string & ProgramResources::GetHelpFile()
|
||||||
|
{
|
||||||
|
return help_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ProgramResources::ReadTextValueFromRegistry(HKEY main_key, const char * sub_key, const char * value, std::string & result)
|
bool ProgramResources::ReadTextValueFromRegistry(HKEY main_key, const char * sub_key, const char * value, std::string & result)
|
||||||
{
|
{
|
||||||
HKEY reg_key;
|
HKEY reg_key;
|
||||||
|
@ -672,20 +678,40 @@ return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
void ProgramResources::SetNameOfConfigurationFile()
|
setting names of:
|
||||||
|
- configuration file
|
||||||
|
- help file
|
||||||
|
*/
|
||||||
|
void ProgramResources::SetNameOfFiles()
|
||||||
{
|
{
|
||||||
static const char simple_file_name[] = "ttcalc.ini";
|
char buffer[_MAX_PATH];
|
||||||
|
static const char conf_name[] = "ttcalc.ini";
|
||||||
|
static const char help_name[] = "ttcalc.chm";
|
||||||
|
|
||||||
// if there'll be an error we assume that the current directory will be used
|
// if there'll be an error we assume that the current directory will be used
|
||||||
// (in the portable version the configuration file is in a current directory)
|
configuration_file = ".\\";
|
||||||
configuration_file = std::string(".\\") + simple_file_name;
|
configuration_file += conf_name;
|
||||||
|
help_file = ".\\";
|
||||||
|
help_file += help_name;
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
if( !GetCurrentDirectory(_MAX_PATH, buffer) )
|
||||||
|
return;
|
||||||
|
|
||||||
static const char simple_directory_name[] = "TTCalc";
|
help_file = buffer;
|
||||||
std::string application_data;
|
help_file += '\\';
|
||||||
|
help_file += help_name;
|
||||||
|
|
||||||
|
#ifdef TTCALC_PORTABLE
|
||||||
|
|
||||||
|
configuration_file = buffer;
|
||||||
|
configuration_file += '\\';
|
||||||
|
configuration_file += conf_name;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static const char dir_name[] = "TTCalc";
|
||||||
|
std::string app_data;
|
||||||
|
|
||||||
// we're trying to read the value "AppData" from registry
|
// we're trying to read the value "AppData" from registry
|
||||||
// which can be, for instance, as:
|
// which can be, for instance, as:
|
||||||
|
@ -695,38 +721,38 @@ std::string application_data;
|
||||||
HKEY_CURRENT_USER,
|
HKEY_CURRENT_USER,
|
||||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||||
"AppData",
|
"AppData",
|
||||||
application_data) )
|
app_data) )
|
||||||
{
|
{
|
||||||
std::string application_directory = application_data + '\\' + simple_directory_name;
|
std::string app_dir = app_data + '\\' + dir_name;
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
// we have to remember the currect directory
|
if( CreateDirIfNotExists(app_dir) )
|
||||||
// (because we're using it when we're opening the help)
|
configuration_file = app_dir + '\\' + conf_name;
|
||||||
char * buffer = new char[_MAX_PATH];
|
|
||||||
|
|
||||||
if( GetCurrentDirectory(_MAX_PATH, buffer) )
|
|
||||||
{
|
|
||||||
// we're testing whether we've got our directory or not
|
|
||||||
if( SetCurrentDirectory( application_directory.c_str() ) )
|
|
||||||
success = true;
|
|
||||||
else
|
|
||||||
// now we must create our directory inside it
|
|
||||||
if( CreateDirectory(application_directory.c_str(), 0) )
|
|
||||||
success = true;
|
|
||||||
|
|
||||||
if( success )
|
|
||||||
configuration_file = application_directory + '\\' + simple_file_name;
|
|
||||||
|
|
||||||
SetCurrentDirectory(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::CreateDirIfNotExists(const std::string & app_dir)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
if( SetCurrentDirectory( app_dir.c_str() ) )
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( CreateDirectory(app_dir.c_str(), 0) )
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ProgramResources::CheckCoordinates()
|
void ProgramResources::CheckCoordinates()
|
||||||
{
|
{
|
||||||
if( x_pos < -50 )
|
if( x_pos < -50 )
|
||||||
|
|
|
@ -317,8 +317,21 @@ public:
|
||||||
will be in a special directory for a particular user, for example:
|
will be in a special directory for a particular user, for example:
|
||||||
"C:\Documents and Settings\user\applitacion data"
|
"C:\Documents and Settings\user\applitacion data"
|
||||||
*/
|
*/
|
||||||
void SetNameOfConfigurationFile();
|
void SetNameOfFiles();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning the name of the help file
|
||||||
|
SetNameOfFiles() should be used first
|
||||||
|
*/
|
||||||
|
const std::string & GetHelpFile();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returning true if such a dir exists
|
||||||
|
if not the method is trying to create it and returns true if it is created
|
||||||
|
*/
|
||||||
|
bool CreateDirIfNotExists(const std::string & app_dir);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
reading and writing to a file
|
reading and writing to a file
|
||||||
|
@ -410,6 +423,7 @@ private:
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
std::string configuration_file;
|
std::string configuration_file;
|
||||||
|
std::string help_file;
|
||||||
|
|
||||||
int y_size_normal;
|
int y_size_normal;
|
||||||
int y_size_compact;
|
int y_size_compact;
|
||||||
|
|
|
@ -59,7 +59,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
GetPrgRes()->GetLanguages()->InitAll();
|
GetPrgRes()->GetLanguages()->InitAll();
|
||||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
||||||
//GetPrgRes()->GetConvert()->Init();
|
//GetPrgRes()->GetConvert()->Init();
|
||||||
GetPrgRes()->SetNameOfConfigurationFile();
|
GetPrgRes()->SetNameOfFiles();
|
||||||
GetPrgRes()->ReadFromFile();
|
GetPrgRes()->ReadFromFile();
|
||||||
|
|
||||||
INITCOMMONCONTROLSEX common_ctrl;
|
INITCOMMONCONTROLSEX common_ctrl;
|
||||||
|
|
Loading…
Reference in New Issue