🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8610

Re: Registering Help Viewer

#8610
From: Remy Lebeau (TeamB)
Date: Thu, 07 Oct 2004 22:31
163 lines
5672 bytes
"3 Wishes" <3@wishes.com> wrote in message
news:4165b82e$2@newsgroups.borland.com...

> I tried to define a new type of help viewer (in fact tried to interface
> the HTMLHelp with C++ Builder).

> I have defined a class THtmlHelpViewer to deal with the problem...

You are going about it all wrong.

>   IHtmlHelpViewer =
> dynamic_cast<ICustomHelpViewer*>((ICustomHelpViewer*)HtmlHelpViewer);

You don't need the dynamic_cast since you are already hard-casting anyway
(which is wrong anyway because your class does not derive from
ICustomHelpViewer to begin with).

> I am lost because I do not know how to pass the second parameter
> for RegisterViewer.

You are not supposed to pass anything in.  RegisterViewer() uses the second
parameter to return an IHelpManager back to you.

>  [C++ Warning] UnitHTMLHelp.cpp(19): W8030 Temporary used
> for parameter 'Manager' in call to '_fastcall
> RegisterViewer(_di_ICustomHelpViewer,_di_IHelpManager &)'

That warning is correct.  You are passing a temporary parameter.

>  [C++ Error] systobj.h(256): E2193 Too few parameters in call to
> '_fastcall IHelpManager::Release(const int)'

As you can see, IHelpManager::Release() has an extra parameter that you are
not specifying when calling Release()

Try this code instead (untested):

    --- header ---

    #include <HelpIntfs.hpp>

    class THtmlHelpViewer : public TInterfacedObject, ICustomHelpViewer,
IHelpSelector
    {
    public:
        HRESULT __stdcall QueryInterface(const GUID& IID, void **Obj)
        ULONG __stdcall AddRef();
        ULONG __stdcall Release();

        AnsiString __fastcall GetViewerName();
        int __fastcall UnderstandsKeyword(const AnsiString HelpString);
        TStringList* __fastcall GetHelpStrings(const AnsiString HelpString);
        bool __fastcall CanShowTableOfContents();
        void __fastcall ShowTableOfContents();
        void __fastcall ShowHelp(const AnsiString HelpString);
        void __fastcall NotifyID(const int ViewerID);
        void __fastcall SoftShutDown();
        void __fastcall ShutDown();

        int __fastcall SelectKeyword(TStrings* Keywords);
        int __fastcall TableOfContents(TStrings* Contents);
    };


    --- source ---

    _di_ICustomHelpViewer HtmlHelpViewer;
    _di_IHelpManager HelpManager;

    HRESULT __stdcall THtmlHelpViewer::QueryInterface(const GUID& IID, void
**Obj)
    {
        return TInterfacedObject::QueryInterface(IID, (void *)Obj);
    }

    ULONG __stdcall THtmlHelpViewer::AddRef()
    {
        return TInterfacedObject::_AddRef();
    }

    ULONG __stdcall THtmlHelpViewer::Release()
    {
        return TInterfacedObject::_Release();
    }

    AnsiString __fastcall THtmlHelpViewer::GetViewerName()
    {
        // implement as needed...
        return "Your Viewer Name";
    }

    int __fastcall THtmlHelpViewer::UnderstandsKeyword(const AnsiString
HelpString)
    {
        // implement as needed...
        return NumberOfTopicsThatMatchTheHelpString;
    }

    TStringList* __fastcall THtmlHelpViewer::GetHelpStrings(const AnsiString
HelpString)
    {
        TStringList *HelpStrings = new TStringList;
        // fill in as needed...
        return HelpStrings;
    }

    bool __fastcall THtmlHelpViewer::CanShowTableOfContents()
    {
        // implement as needed...
        return WhetherCanShowOrNot;
    }

    void __fastcall THtmlHelpViewer::ShowTableOfContents()
    {
        // implement as needed...
    }

    void __fastcall THtmlHelpViewer::ShowHelp(const AnsiString HelpString)
    {
        // implement as needed...
    }

    void __fastcall THtmlHelpViewer::NotifyID(const int ViewerID)
    {
        // implement as needed...
    }

    void __fastcall THtmlHelpViewer::SoftShutDown()
    {
        // implement as needed...
    }

    void __fastcall THtmlHelpViewer::ShutDown()
    {
        // implement as needed...
    }

    int __fastcall THtmlHelpViewer::SelectKeyword(TStrings* Keywords)
    {
        // check the list of Keywords...
        // display a dialog if needed...
        return TheIndexOfTheSelectedKeywordInTheList;
    }

    int __fastcall THtmlHelpViewer::TableOfContents(TStrings* Contents)
    {
        // check the list of Viewer Names...
        return TheIndexOfTheChosenViewerInTheList;
    }

    void InitServices()
    {
        THtmlHelpViewer* Viewer = new THtmlHelpViewer;
        HtmlHelpViewer = (ICustomHelpViewer*)Viewer;
        Helpintfs::RegisterViewer(HtmlHelpViewer, HelpManager);
        Application->HelpSystem->AssignHelpSelector((IHelpSelector*)Viewer);
    }

    #pragma startup InitServices


Gambit
Technical Details
Message-ID: <4165c3bb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4165b82e$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fa848f661129ced4
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4165b82e$2@newsgroups.borland.com>
Subject: Re: Registering Help Viewer
Date: Thu, 7 Oct 2004 15:31:30 -0700
Lines: 165
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <4165c3bb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1097188283 68.69.17.41 (7 Oct 2004 15:31:23 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail