Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #1117
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| References | (5 earlier) <4dca2018$0$1573$91cee783@newsreader04.highway.telekom.at> <4dcc4a3f$0$47020$c30e37c6@pit-reader.telstra.net> <4dccc7db$0$18690$91cee783@newsreader03.highway.telekom.at> <4dcdb621$0$47014$c30e37c6@pit-reader.telstra.net> <4dce2c3c$0$47014$c30e37c6@pit-reader.telstra.net> |
| Subject | Re: Highlighting Buttons on tab page freezes program - Solved! |
| Date | 2011-05-15 02:30 +1000 |
| Message-ID | <4dceae1f$0$47016$c30e37c6@pit-reader.telstra.net> (permalink) |
Aha - found the culprit!
The Expose() method calls GetDisplayTextWidth() to work out if the length of
each button's caption text to determine if it is multiline text or not.
GetDisplayTextWidth() creates ptrs for fonts during the calculations,
however these ptrs are never destroyed after use so just keep building up.
By deleting these ptrs after use solves the problem!
Thanks to all for your help, really appreciated.
Revised GetDisplayTextWidth() code below for those who want it.
FUNCTION getDisplayTextWidth( cText, xFont )
// returns the width of a text string in PIXELS
// needs to get a pointer to a font!
LOCAL dwSize AS DWORD
LOCAL winSize IS _winSize
LOCAL nWidth AS DWORD
LOCAL hOldFont AS PTR
LOCAL hFont AS PTR
LOCAL hDC AS PTR
hDC := CreateIC( String2Psz( "DISPLAY" ), NULL_PSZ, NULL_PSZ, NULL_PTR )
IF !(hDC == NULL_PTR)
IF IsPtr(xFont)
hFont := xFont
ELSEIF IsInstanceOfUsual(xFont,#font)
hFont := xFont:handle()
ELSE
(errorBox{,"Error: invalid font parameter in function getDisplayTextWidth(
cText, xFont )"}):show()
ENDIF
IF !(hFont == NULL_PTR)
hOldFont := SelectObject( hDC, hFont )
ENDIF
GetTextExtentPoint32( hDC, Cast2Psz( cText ), SLen( cText ), @winSize )
dwSize := DWORD(_CAST, MakeLong(WORD(_CAST, winSize.cx),
WORD(_CAST,winSize.cy)))
nWidth := LoWord( dwSize )
IF !(hOldFont == NULL_PTR)
SelectObject( hDC, hOldFont )
ENDIF
// CWD
DeleteDC(hDC)
DeleteDC(hOldFont)
DeleteDC(hFont)
ENDIF
// CWD
hDC := NULL_PTR
hOldFont := NULL_PTR
hFont := NULL_PTR
RETURN nWidth
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-10 07:39 +1000
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-09 21:51 -0500
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-10 14:09 +1000
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-10 05:52 -0500
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-11 01:53 +1000
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-10 11:57 -0500
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-10 11:57 -0500
Re: Highlighting Buttons on tab page freezes program "Bernhard Mayer" <Idonotexisthere@nowhere.com> - 2011-05-11 07:35 +0200
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-13 06:59 +1000
Re: Highlighting Buttons on tab page freezes program "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> - 2011-05-13 08:57 +1000
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-14 08:47 +1000
Re: Highlighting Buttons on tab page freezes program "Bernhard Mayer" <Idonotexisthere@nowhere.com> - 2011-05-13 07:55 +0200
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-14 08:52 +1000
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-14 17:16 +1000
Re: Highlighting Buttons on tab page freezes program - Solved! "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-15 02:30 +1000
Re: Highlighting Buttons on tab page freezes program - Solved! "Gerhard Bunzel" <g.bunzel@domonet.de> - 2011-05-16 00:08 +0200
Re: Highlighting Buttons on tab page freezes program - Solved! "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-17 21:55 +1000
Re: Highlighting Buttons on tab page freezes program - Solved! "Willie Moore" <williem@wmconsulting.com> - 2011-05-17 07:19 -0500
Re: Highlighting Buttons on tab page freezes program - Solved! "Paul D B" <polleke@NOMORESPAMhnt.be> - 2011-05-18 17:00 +0200
Re: Highlighting Buttons on tab page freezes program Sherlock <sherlock@sherlock.com.au> - 2011-05-10 05:01 -0700
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-11 01:58 +1000
Re: Highlighting Buttons on tab page freezes program "Paul D B" <polleke@NOMORESPAMhnt.be> - 2011-05-18 16:39 +0200
Re: Highlighting Buttons on tab page freezes program "Paul D B" <polleke@NOMORESPAMhnt.be> - 2011-05-18 16:42 +0200
csiph-web