HelpController and path Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
wxuser
Knows some wx things
Knows some wx things
Posts: 29
Joined: Fri Feb 25, 2005 5:45 am
Location: India

HelpController and path

Post by wxuser » Thu Oct 13, 2005 8:38 am

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");
      help->LoadFile();
      help->DisplayContents();
or

Code: Select all

wxHelpController *Myhelp = new wxHelpController();
      Myhelp->Initialize("myapp.chm");
      Myhelp->DisplayContents();
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

Deepak

benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte » Thu Oct 13, 2005 8:55 am

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;
#endif
}

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Thu Oct 13, 2005 9:08 am

Hi!
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.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

wxuser
Knows some wx things
Knows some wx things
Posts: 29
Joined: Fri Feb 25, 2005 5:45 am
Location: India

Post by wxuser » Thu Oct 13, 2005 10:31 am

Thanks to both benedicte and upCASE. Its solved now.

Post Reply