Page 1 of 1

HelpController and path

Posted: Thu Oct 13, 2005 8:38 am
by wxuser
Hi all,

I wanted to add help file for my app and tried this:

Code: Select all

wxCHMHelpController *help = new wxCHMHelpController;
      help->Initialize( "myapp.chm");

Code: Select all

wxHelpController *Myhelp = new wxHelpController();
both work perfectly alright, except one thing.
Once i create the setup file and install the application, if i open the app through the start menu or the desktop shortcut, the help file wont showup.

I zeroed the problem to be of the path. If i directly go to program files and open the app, the help file will show up. Basically, it should check for the file in the folder where the app is installed.

I would like to know what others are doing for this. or am i missing anything?

Thanks in advance


Posted: Thu Oct 13, 2005 8:55 am
by benedicte
The path to the help file must be absolute.

If you don't specify the path completely, it will consider it as relative to the path from which the application is launched.

Code: Select all

wxString	app_path;
get_executable_path (app_path);
app_path = wxFileName(app_path).GetPath();
help->Initialize(app_path + "myapp.chm");
(assuming you set the chm file in the same folder as the application .exe file)

on windows, you can get the executable path using:

Code: Select all

void get_executable_path (wxString &app_path)
#ifdef __WXMSW__
        wchar buf[512];
        *buf = '\0';
        GetModuleFileName(NULL, buf, 511);
        app_path << buf;

Posted: Thu Oct 13, 2005 9:08 am
by upCASE
On Windows wxStandardPaths::GetDataDir() would do the job, too.
Another option would be to let the setup compiler create a link to the app in the start menu with the current working dir set to the app path.

Posted: Thu Oct 13, 2005 10:31 am
by wxuser
Thanks to both benedicte and upCASE. Its solved now.