🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

GDI Objects build up using CreateCompatibleDC and CreateCompatibleBitmap

#12841
From: LarryJ
Date: Sun, 16 Nov 2003 10:40
34 lines
2246 bytes
I am using BCB6.0 and use CreateCompatibleDC and CreateCompatibleBitmap to
create a canvas for double buffering an image that is on a child form. These
bitmap objects can not be resized so each time the child form changes size I
have to delete this bitmap and create a new one using the new size. I am
using the code below to delete the bitmap and then create a new one. The
code works but each time this if statement is called the Windows Task
Manager shows the GDI Objects increases in number. When the GDI Objects get
to about 600 the bitmap goes blank and will no longer show an image. There
must be a delete or free function that I am missing to prevent the GDI
Objects from building up. Can anyone see the problem.
//====================
PCForm is the child form
TCanvas *BGCanvas is declared in the child form h file
HDC hDC1;
HBITMAP hBMP1;
//====================

if(mychart->PCForm->BGCanvas){
    DeleteObject(hBMP1);
    DeleteDC(hDC1);
    delete PCForm->BGCanvas;

    //----Create Back Ground Canvas----
    hDC1 = CreateCompatibleDC(PCForm->Canvas->Handle);
    hBMP1 = CreateCompatibleBitmap(PCForm->Canvas->Handle,
mychart->ClientWidth, mychart->ClientHeight);
    SelectObject(hDC1, hBMP1);
    PCForm->BGCanvas = new TCanvas;
    PCForm->BGCanvas->Handle = hDC1;
 }


Thank You For Helping
Larry Johnson.
Technical Details
Message-ID: <3fb7541b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,17187dcae4d9769f
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-16 03:09:15 PST
Reply-To: "LarryJ" <LarryJ33@ev1.net>
From: "LarryJ" <LarryJ33@ev1.net>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: GDI Objects build up using CreateCompatibleDC and CreateCompatibleBitmap
Date: Sun, 16 Nov 2003 04:40:17 -0600
Lines: 36
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: 216.40.234.237
Message-ID: <3fb7541b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1068979227 216.40.234.237 (16 Nov 2003 02:40:27 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail