netying
netying

Reputation: 1

About TBitmap->Canvas->Handle and HandleAllocated() in C++ Builder

I writed the followed code:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    for(int i=0;i<100;i++)
    {
        Graphics::TBitmap *bitmap=new  Graphics::TBitmap();
        bitmap->PixelFormat=pf24bit;
        bitmap->Width=256;
        bitmap->Height=256;
        HDC h=bitmap->Canvas->Handle;

        Memo1->Lines->Add(""); //if no this code,OK; otherwise,HandleAllocated error。why?

        if(bitmap->Canvas->HandleAllocated())
        {
            ShowMessage("OK");
        }
        else
        {
            ShowMessage("HandleAllocated error");
        }
        delete bitmap;
    }
}

I use C++ builder 6.0.

Memo1->Lines->Add(""); //if no this code,OK; otherwise,HandleAllocated error。why?

I have searched many search engines and forums for this question, but have not received a clear answer.

Upvotes: 0

Views: 28

Answers (0)

Related Questions