Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #9328

Re: GDI Objects creeping up

From Martin <Martin@spam.spam>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: GDI Objects creeping up
Date 2016-05-05 09:37 +0100
Organization A noiseless patient Spider
Message-ID <ngf0gr$l44$1@dont-email.me> (permalink)
References <nga8uu$n54$2@dont-email.me> <nqejibh2atflb7j8klqdmgc5sdfecsjh6j@4ax.com> <ngchkd$h49$1@dont-email.me> <d25kib951f5n3vmffkpsivovkgl5km3p55@4ax.com>

Show all headers | View raw


I modded the code to do the font once and subclassed it into a debug version

All created
All destroyed

Need to look at other things now

I have a few classes for cells on bbrowsers, are there any potentials 
leaks in this draw code?

This is a class added to a bcompoundvalue, real name is not xxxxx

CLASS xxxxx
	// bar chart
	PROTECT nCol			AS DWORD

	// methods
	DECLARE METHOD 	Draw
METHOD Init(nCol) CLASS xxxxx
	// initialize
	SELF:nCol := nCol
	RETURN SELF
METHOD Draw(hDC AS PTR, srcArea AS _winRect) AS LOGIC PASCAL CLASS xxxxx
LOCAL iBarWidth		AS INT, ;
       iBarHeight	AS INT, ;
       oBrush		AS Brush, ;
       iLeft			AS INT, ;
       iRight		AS INT, ;
       iTop			AS INT, ;
       iBot			AS INT

// determine max. height
iBarHeight	:= srcArea.Bottom-srcArea.Top-2

// determine width of a bar
iBarWidth	:= srcArea.Right-srcArea.Left-2

iLeft		:= srcArea.Left-1
iRight		:= iLeft+iBarWidth
iTop		:= srcArea.Bottom-1-iBarHeight
iBot		:= srcArea.Bottom-1

SelectObject(hDC, GetStockObject(NULL_PEN))
DO CASE
	CASE Empty(SELF:nCol) .OR. SELF:nCol = 0
		oBrush := Brush{Color{COLORBLUE}}

	CASE SELF:nCol = 1
		oBrush := Brush{Color{COLORGREEN}}

	CASE SELF:nCol = 2
		oBrush := Brush{Color{COLORRED}}

	CASE SELF:nCol = 3
		oBrush := Brush{Color{COLORYELLOW}}

ENDCASE

//		draw bar
SelectObject(hDC, oBrush:Handle())
Rectangle(hDC, iLeft, iTop, iRight, iBot)

RestoreDC(hDC, -1)

RETURN TRUE










On 04/05/2016 16:29, Benito Fern�ndez Meneses wrote:
> Martin,
>
> In my methods I always use local variables declared as DIM, at some
> post I read that using a Font, Brush, Color, etc. use a declare
> statement  as
>
> LOCAL DIM aFonts[3] AS Font
>
> It get released as the method goes out of scope.
>
> HTH
> Benito
>
>
> On Wed, 4 May 2016 11:10:52 +0100, Martin <Martin@spam.spam> wrote:
>
>> Some good food for thought there Karl
>>
>> Well on one screen I have code like below
>>
>> This is in a bbrowser cell
>>
>> oFont	:= Font{,8,"MS Shell Dlg"}
>>
>> bcVal:AddValue(bCompoundValue{cDriver,;
>>     Point{ 0,48},;
>>     Dimension{67,16},,,,oFont})
>>
>> bcVal:AddValue(bCompoundValue{cLorry,;
>>     Point{68,48},;
>>     Dimension{61,16},BALIGN_RIGHT,,,oFont})
>>
>> Not sure if this is good or not.
>>
>> Thanks
>>
>> Martin
>>
>> On 04/05/2016 10:21, Karl Faller wrote:
>>> Martin,
>>> just some ideas;
>>> look at
>>> https://support.microsoft.com/de-de/kb/2719248
>>> possibly related?
>>>
>>> Then i read in the help:
>>> ...
>>> Notes
>>> Deselecting a Font:        In Windows, the current font should be
>>> deselected before destroying the window.  To do this, use Window:Font
>>> to assign the previous font, for example.  However, this is only
>>> necessary if there is a font other than the default one currently
>>> selected.
>>> ...
>>> It won't say, "why" you have to deselect - maybe because the font
>>> won't get released automatically?
>>>
>>> And you are sure, you destroy explicitely things like brushes etc.?
>>>
>>> KArl
>>>
>>>> Hello
>>>>
>>>> I use the following to monitor GDI Objects
>>>>
>>>> GetGuiResources(GetCurrentProcess(),GR_GDIOBJECTS)
>>>>
>>>> And now we are finding that is it creeping up a lot.
>>>>
>>>> Any ideas what to check, I know there must be a leak, but where do I look?
>>>>
>>>> Thanks
>>>>
>>>> Martin
>>> Regards
>>>
>>> Karl
>>>

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

GDI Objects creeping up Martin <Martin@spam.spam> - 2016-05-03 14:30 +0100
  Re: GDI Objects creeping up "Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it> - 2016-05-04 08:58 +0200
    Re: GDI Objects creeping up Martin <Martin@spam.spam> - 2016-05-04 09:07 +0100
    Re: GDI Objects creeping up Martin <Martin@spam.spam> - 2016-05-04 11:05 +0100
  Re: GDI Objects creeping up Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2016-05-04 11:21 +0200
    Re: GDI Objects creeping up Martin <Martin@spam.spam> - 2016-05-04 11:10 +0100
      Re: GDI Objects creeping up Benito Fernández Meneses <bfernandez@bfmconsultores.com.mx> - 2016-05-04 10:29 -0500
        Re: GDI Objects creeping up "Jamal Assaf" <someone@example.com> - 2016-05-04 21:34 -0400
          Re: GDI Objects creeping up Camille Kater <katercam@pt.lu> - 2016-05-05 09:52 +0200
          Re: GDI Objects creeping up Otto Christiaanse <ofchristiaanse@gmail.com> - 2016-05-05 03:47 -0700
            Re: GDI Objects creeping up "Jamal Assaf" <someone@example.com> - 2016-05-07 13:09 -0400
              Re: GDI Objects creeping up "Jamal Assaf" <someone@example.com> - 2016-05-08 00:50 -0400
                Re: GDI Objects creeping up Otto Christiaanse <ofchristiaanse@gmail.com> - 2016-05-17 02:33 -0700
        Re: GDI Objects creeping up Martin <Martin@spam.spam> - 2016-05-05 09:37 +0100
  Re: GDI Objects creeping up "Jamal Assaf" <someone@example.com> - 2016-05-07 13:12 -0400

csiph-web