🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: include TForm into ShellExtensionDLL

#11277
From: Remy Lebeau (TeamB)
Date: Mon, 16 Feb 2004 22:27
46 lines
2404 bytes
"nik" <neusser@okstate.edu> wrote in message
news:40310c11$1@newsgroups.borland.com...

> How do I have to free the memory after the use of the Form,
> i.e. after I don't need the form any more.

You simply 'delete' it when you are done with it.

> * does Form->Close(); do the job for me sufficiently?

Are you setting the Action parameter of the OnClose event to caFree?

> * do I have to use delete Form; ? If yes, where should I insert the code?

The easiest way to handle this is to simply instantiate the form when the
DLL's IContextMenu::InvokeCommand() is called, use the form's ShowModal()
method, and then 'delete' the form when ShowModal() returns, ie:

    HRESULT TIContextMenuImpl::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
    {
        //...
        TMyForm *form = new TMyForm(NULL);
        try {
            form->ShowModal();
        }
        __finally {
            delete form;
        }
        //...
    }

Alternatively, use an std::auto_ptr instead of a try...finally:

    #include <memory>

    HRESULT TIContextMenuImpl::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
    {
        //...
        std::auto_ptr<TMyForm> form(new TMyForm(NULL));
        form->ShowModal();
        //...
    }


Gambit
Technical Details
Message-ID: <40314206$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <402baeac$1@newsgroups.borland.com> <402bcd77$3@newsgroups.borland.com> <402ebc24$1@newsgroups.borland.com> <402ec23f$1@newsgroups.borland.com> <40310c11$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,12d8f10b74656960
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-16 14:39:03 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <402baeac$1@newsgroups.borland.com> <402bcd77$3@newsgroups.borland.com> <402ebc24$1@newsgroups.borland.com> <402ec23f$1@newsgroups.borland.com> <40310c11$1@newsgroups.borland.com>
Subject: Re: include TForm into ShellExtensionDLL
Date: Mon, 16 Feb 2004 14:27:38 -0800
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <40314206$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1076969990 67.22.138.253 (16 Feb 2004 14:19:50 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail