WinHelp.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include <Tools.h>
  6. #include <TextsWin.h>
  7. #include <CoreMain.h>
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. //---------------------------------------------------------------------------
  11. class TWebHelpSystem : public TInterfacedObject, public ICustomHelpViewer
  12. {
  13. public:
  14. __fastcall TWebHelpSystem(const AnsiString & Version);
  15. virtual int __fastcall UnderstandsKeyword(const AnsiString HelpString);
  16. virtual TStringList * __fastcall GetHelpStrings(const AnsiString HelpString);
  17. virtual void __fastcall NotifyID(const int ViewerID);
  18. virtual void __fastcall SoftShutDown();
  19. virtual void __fastcall ShutDown();
  20. virtual AnsiString __fastcall GetViewerName();
  21. virtual bool __fastcall CanShowTableOfContents();
  22. virtual void __fastcall ShowTableOfContents();
  23. virtual void __fastcall ShowHelp(const AnsiString HelpString);
  24. IUNKNOWN
  25. private:
  26. AnsiString FVersion;
  27. };
  28. //---------------------------------------------------------------------------
  29. void __fastcall SearchHelp(const AnsiString & Message)
  30. {
  31. OpenBrowser(FMTLOAD(DOCUMENTATION_SEARCH_URL,
  32. (EncodeUrlString(UTF8Encode(Message)), Configuration->ProductVersion)));
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall InitializeWinHelp()
  36. {
  37. InitializeCustomHelp(new TWebHelpSystem(Configuration->ProductVersion));
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall FinalizeWinHelp()
  41. {
  42. FinalizeCustomHelp();
  43. }
  44. //---------------------------------------------------------------------------
  45. __fastcall TWebHelpSystem::TWebHelpSystem(const AnsiString & Version) :
  46. FVersion(Version)
  47. {
  48. }
  49. //---------------------------------------------------------------------------
  50. int __fastcall TWebHelpSystem::UnderstandsKeyword(const AnsiString HelpString)
  51. {
  52. // pretend that we know everything
  53. return 1;
  54. }
  55. //---------------------------------------------------------------------------
  56. TStringList * __fastcall TWebHelpSystem::GetHelpStrings(const AnsiString HelpString)
  57. {
  58. TStringList * Result = new TStringList();
  59. Result->Add(GetViewerName() + " : " + HelpString);
  60. return Result;
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TWebHelpSystem::NotifyID(const int /*ViewerID*/)
  64. {
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TWebHelpSystem::SoftShutDown()
  68. {
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TWebHelpSystem::ShutDown()
  72. {
  73. }
  74. //---------------------------------------------------------------------------
  75. AnsiString __fastcall TWebHelpSystem::GetViewerName()
  76. {
  77. return "Web";
  78. }
  79. //---------------------------------------------------------------------------
  80. bool __fastcall TWebHelpSystem::CanShowTableOfContents()
  81. {
  82. return true;
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TWebHelpSystem::ShowTableOfContents()
  86. {
  87. OpenBrowser(FMTLOAD(DOCUMENTATION_URL, (FVersion)));
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TWebHelpSystem::ShowHelp(const AnsiString HelpString)
  91. {
  92. OpenBrowser(FMTLOAD(DOCUMENTATION_KEYWORD_URL, (HelpString, FVersion)));
  93. }