chm Datei in Programm nutzen.
-
Also ich bin gerade dabei eine Hilfe für mein Programm zu erstellen die sich mit F1 öffnen soll.
Jetzt habe ich das Problem das ich das File zwar mit ShellExecute öffnen könnte jedoch ist das ja nicht der Sinn der Sache.
Wie schaffe ich es ein Hilfesystem zu entwerfen das ich mit F1 öffnen kann besser sogar je nachdem direkt sogar in bestimmte kapitel springend je nachdem wo ich mich in meinem programm befinde.Das ganze muss auf Win Vista funktionieren. Ich arbeite mit dem radstudio2007
ist da chm vieleicht das falsche Format ?
bzw wie mache ich es das sich dann so eine hilfe öffnet? helpsystem usw. hab mal etwas rumprobiert jedoch hat bisher nix geklappt.
Cool wäre auch ein kleines Beispiel falls jemand sowas hat.
Danke schonmal im Voraus.
-
Benutze die Suche.
-
Hab hier schon 2 Stunden gesucht jedoch ist nirgends etwas genaues beschrieben. oder ich finde nix.
Beispiele mit ShellExecute sind dabei.
aber nicht das was ich suche.
PS: Ich benutze immer die Suche vorher -- ganz Brav (erst Google - dann nochmal hier)
-
-
blue23 0 schrieb:
Hab hier schon 2 Stunden gesucht jedoch ist nirgends etwas genaues beschrieben. oder ich finde nix.
Auch mal nach "CHM"? Da hättest du das hier gefunden. Erst ein paar Wochen alt.
-
ja nach chm hatte ich gesucht und auch diesen thread gefunden aber wie ich schon schrieb hab ich mir das mit dem Thelper usw alles durchgelesen - auch versucht jedoch net hinbekommen.
Der Tip von Jansen war super. Damit klappts einwandfrei.
Danke also an beide für die Hilfe.
-
Das statische Einbinden der HHCTRL.OCX kann zu Problemen führen (Microsoft Windows bug KB935448). Deswegen lade ich immer dynamisch. Dazu habe ich mir ein Singleton gebastelt. Anbei mal der Code für den den es interessiert.
// Header #include <windows.h> #include <htmlhelp.h> #include <string> /// The class HtmlHelp is a utility class for showing HTML based help files. /// It loads the necessary HHCTRL.OCX as late as possible in order to avoid the Microsoft Windows bug KB935448 /// http://support.microsoft.com/kb/935448 /// Usage of class: /// @code /// HtmlHelper().displayHelp(HH_DISPLAY_TOC, "myhelpfile.chm"); // shows the table of contents /// HtmlHelper().displayHelp(HH_DISPLAY_TOPIC, "myhelpfile.chm", "mytopic"); // shows a topic /// @endcode class HtmlHelp { public: /// Typedef for winapi function typedef HWND (WINAPI *FPHH) (HWND, LPCSTR, UINT, DWORD); /// Destructor, unloads DLL. ~HtmlHelp() { unloadDll(); } /// Shows a help dialog based on the given parameters /// @param kind One of the display kinds defined in HtmlHelp.h /// HH_DISPLAY_INDEX opens the index /// HH_DISPLAY_TOC opens the table of contents /// HH_DISPLAY_SEARCH opens a search dialog /// HH_DISPLAY_TOPIC opens the topic given in (/a topic) /// @param helpfile Name of the helpfile (should be with path) /// @param topic A string with the help topic (used for HH_DISPLAY_TOPIC) /// @return Returns handle to created help window, or zero, if there was a problem with the help system. HWND displayHelp(unsigned short kind, const std::string& helpfile, const std::string& topic = "", HWND parent = 0) const; /// Allows direct call to help system with full control over all parameters. /// @return Returns handle to created help window, or zero, if there was a problem with the help system. HWND htmlHelp(HWND parent, LPCSTR topic, UINT command, DWORD q) const; private: /// Private constructor (ensures Singleton) HtmlHelp() : dllInstance(0), htmlHelpFunction(0) {} /// Private copy constructor (ensures Singleton) HtmlHelp(const HtmlHelp&) {} /// Public helper function to call help. /// @see HtmlHelp for usage examples. friend const HtmlHelp& HtmlHelper(); /// Initialization function, loads Dll, called from HtmlHelper() on first call. bool loadDll(); /// Removes DLL from memory. void unloadDll(); /// Internal pointer to dllInstance in memory, = 0 if DLL is not loaded. HWND dllInstance; /// Internal pointer to htmlHelpFunction in memory, = 0 if DLL is not loaded. FPHH htmlHelpFunction; };
// cpp-Datei bool HtmlHelp::loadDll() { unloadDll(); dllInstance = LoadLibrary( "HHCTRL.OCX" ); if (!dllInstance) return false; (FARPROC&) htmlHelpFunction = GetProcAddress( dllInstance, "HtmlHelpA" ); if (!htmlHelpFunction) return false; else return true; } void HtmlHelp::unloadDll() { if (dllInstance != 0) { FreeLibrary(dllInstance); dllInstance = 0; htmlHelpFunction = 0; } } HWND HtmlHelp::htmlHelp(HWND parent, LPCSTR topic, UINT command, DWORD q) const { // ensure that DLL was properly loaded before continuing if (!dllInstance) return 0; return htmlHelpFunction(parent, topic, command, q); } HWND HtmlHelp::displayHelp(unsigned short kind, const std::string& helpfile, const std::string& topic, HWND parent) const { // ensure that DLL was properly loaded before continuing if (!dllInstance) return 0; HH_FTS_QUERY q; q.cbStruct = sizeof(HH_FTS_QUERY); q.fUniCodeStrings = false; q.pszSearchQuery = ""; q.iProximity = HH_FTS_DEFAULT_PROXIMITY; q.fStemmedSearch = false; q.fTitleOnly = false; q.fExecute = false; q.pszWindow = NULL; HWND hwnd; switch(kind) { case HH_DISPLAY_INDEX: hwnd = htmlHelpFunction( parent, helpfile.c_str(), HH_DISPLAY_INDEX, NULL ); break; case HH_DISPLAY_TOC: hwnd = htmlHelpFunction( parent, helpfile.c_str(), HH_DISPLAY_TOC, ( DWORD )&q ); break; case HH_DISPLAY_SEARCH: hwnd = htmlHelpFunction( parent, helpfile.c_str(), HH_DISPLAY_SEARCH, ( DWORD )&q ); break; case HH_DISPLAY_TOPIC: { std::string top = helpfile + "::/" + topic + ".htm"; hwnd = htmlHelpFunction( parent, top.c_str(), HH_DISPLAY_TOPIC, NULL ); break; } // not implemented yet, this flag needs additional values // case HH_DISPLAY_TEXT_POPUP: hwnd = htmlHelpFunction( parent, helpfile.c_str(), HH_DISPLAY_TEXT_POPUP, NULL ); break; default: return 0; } return hwnd; } //--------------------------------------------------------------------------- const HtmlHelp& HtmlHelper() { static HtmlHelp h; if (h.dllInstance == 0) { h.loadDll(); } return h; }
-
Ich weiß wirklich nicht, was ihr gegen die Standard-VCL-Implementation habt
#pragma link "HTMLHelpViewer" ... Application->HelpFile = _T ("TheFile.chm"); ... Application->HelpShowTableOfContents ();
-
Ich habe was dagegen, wegen dem schon erwähnten KB935448 Bug. Wir hatten bei unserem Programm ein Haufen Anfragen von Nutzern, die diesen Patch eben nicht drauf hatten und uns den schwarzen Peter zuschoben. Damit es trotzdem funktioniert haben wir dann die oben erwähnte Lösung genommen.