🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Controls Class BC5 vs BC6

#7826
From: Remy Lebeau (TeamB)
Date: Wed, 22 Dec 2004 17:41
69 lines
2702 bytes
"Elias Berelian" <eliasb@voyager.snetnsa.com> wrote in message
news:41c9af28@newsgroups.borland.com...

> I guess I was subclassing the main form. I copied the idea from
> the following. Except in this case they are subclassing a Memo.

That is a significant difference.

> What should I do to be able to accept files anywhere on the form?

I already told you what to do - override the WndProc() method instead of
using the WindowProc property.


    --- header ---

    protected:
        void __fastcall CreateWnd();
        void __fastcall DestroyWnd();
        void __fastcall WndProc(TMessage &Msg);


    --- source ---

    void __fastcall TForm1::CreateWnd()
    {
        TForm::CreateWnd();
        if( HandleAllocated() )
            DragAcceptFiles(Handle, TRUE);
    }

    void __fastcall TForm1::DestroyWnd()
    {
        if( HandleAllocated() )
            DragAcceptFiles(Handle, FALSE);
        TForm::DestroyWnd();
    }

    void __fastcall TForm1::WndProc(TMessage &Msg)
    {
        if( Msg.Msg == WM_DROPFILES )
        {
            int num_files = DragQueryFile((HDROP)Msg.WParam, 0xFFFFFFFF,
NULL, NULL);
            if( num_files == 1 )
            {
                int NameLength = DragQueryFile((HDROP)Msg.WParam, 0, NULL,
NULL);

                char *FileName = new char[NameLength];
                DragQueryFile((HDROP)Msg.WParam, 0, FileName, NameLength);

                Memo1->Lines->LoadFromFile(FileName);
                delete[] FileName;
            }
            else
                ShowMessage("too many files!");

            DragFinish((HDROP)Msg.WParam);
            Msg.Result = 0;
            return;
        }

        TForm::WndProc(Msg);
    }


Gambit
Technical Details
Message-ID: <41c9b179$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41c31afb$1@newsgroups.borland.com> <41c35862$1@newsgroups.borland.com> <41c36850$1@newsgroups.borland.com> <41c9af28@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a08d779203a41a49
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: <41c31afb$1@newsgroups.borland.com> <41c35862$1@newsgroups.borland.com> <41c36850$1@newsgroups.borland.com> <41c9af28@newsgroups.borland.com>
Subject: Re: Controls Class BC5 vs BC6
Date: Wed, 22 Dec 2004 09:41:05 -0800
Lines: 71
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: <41c9b179$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1103737209 68.69.17.41 (22 Dec 2004 09:40:09 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail