Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #1076 > unrolled thread
| Started by | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| First post | 2011-05-10 07:39 +1000 |
| Last post | 2011-05-18 16:42 +0200 |
| Articles | 20 on this page of 23 — 7 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
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
Page 1 of 2 [1] 2 Next page →
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-10 07:39 +1000 |
| Subject | Highlighting Buttons on tab page freezes program |
| Message-ID | <4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net> |
Hi all, I have a strange problem. I have a POS system that has a window with tabs on them. On those tabs are a number of buttons that fill the entire tab page. It was designed for touch screens and day-in, day-out, it works quite well - however for those customers that do not have one and only use a mouse to click the buttons, they are reporting a problem. If they only use the mouse, after around 40-50 transactions, the system locks up and freezes (note that touch screens are no problem). At first, I could not reproduce it, however if I got the mouse pointer and moved it rapidly around in circles over the buttons (they would highlight / dehighlight / highlight again atc), after about 30-35 seconds or so bingo! It froze and the screen went all spastic with buttons disappearing and then reappearing in different positions, etc. Anyone had this happen to them or have any clues as to what would be causing this strange behaviour? Thanks in advance, Craig.
[toc] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-05-09 21:51 -0500 |
| Message-ID | <iqa97b$1eh$1@speranza.aioe.org> |
| In reply to | #1076 |
Craig, That is pretty strange. I would look at your mouse code. Are you doing any handlers to track the mouse position? If you are using mousemove or mousedrag you can eat up memory if you are not careful. Is their any error message in any log? It will be a hard one to debug but the best way would be with debout32() and pass debug strings so you can see what the program is doing without being intrusive with the debugger. While you do that you can also monitor your GDI objects. See if they are rising. Regards, Willie "Craig Dawson" wrote in message news:4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net... Hi all, I have a strange problem. I have a POS system that has a window with tabs on them. On those tabs are a number of buttons that fill the entire tab page. It was designed for touch screens and day-in, day-out, it works quite well - however for those customers that do not have one and only use a mouse to click the buttons, they are reporting a problem. If they only use the mouse, after around 40-50 transactions, the system locks up and freezes (note that touch screens are no problem). At first, I could not reproduce it, however if I got the mouse pointer and moved it rapidly around in circles over the buttons (they would highlight / dehighlight / highlight again atc), after about 30-35 seconds or so bingo! It froze and the screen went all spastic with buttons disappearing and then reappearing in different positions, etc. Anyone had this happen to them or have any clues as to what would be causing this strange behaviour? Thanks in advance, Craig.
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-10 14:09 +1000 |
| Message-ID | <4dc8ba70$0$47013$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1078 |
Thanks Willie but no mousemove or mousedrag code whatsoever. No errors in any logs are created either. Strange that I have not yet been able to recreate it in XP - just Vista & Win7 (all are up to date with service packs). ----- Regards, Craig. "Willie Moore" <williem@wmconsulting.com> wrote in message news:iqa97b$1eh$1@speranza.aioe.org... > Craig, > > That is pretty strange. I would look at your mouse code. Are you doing any > handlers to track the mouse position? If you are using mousemove or > mousedrag you can eat up memory if you are not careful. Is their any error > message in any log? It will be a hard one to debug but the best way would > be with debout32() and pass debug strings so you can see what the program > is doing without being intrusive with the debugger. While you do that you > can also monitor your GDI objects. See if they are rising. > > Regards, > Willie > > "Craig Dawson" wrote in message > news:4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net... > > Hi all, I have a strange problem. > > I have a POS system that has a window with tabs on them. On those tabs are > a > number of buttons that fill the entire tab page. > It was designed for touch screens and day-in, day-out, it works quite > well - > however for those customers that do not have one and only use a mouse to > click the buttons, they are reporting a problem. > > If they only use the mouse, after around 40-50 transactions, the system > locks up and freezes (note that touch screens are no problem). > At first, I could not reproduce it, however if I got the mouse pointer and > moved it rapidly around in circles over the buttons (they would highlight > / > dehighlight / highlight again atc), after about 30-35 seconds or so bingo! > It froze and the screen went all spastic with buttons disappearing and > then > reappearing in different positions, etc. > > Anyone had this happen to them or have any clues as to what would be > causing > this strange behaviour? > > Thanks in advance, Craig. >
[toc] | [prev] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-05-10 05:52 -0500 |
| Message-ID | <iqb5ch$dn0$1@speranza.aioe.org> |
| In reply to | #1080 |
Craig, How about the buttons, are they standard buttons or are the a subclassed button? I have seen button subclasses over the years that used images incorrectly. They would leak resources. Here is a trick that you may or may not know. Open up taskmanager on the machine you are testing. Go to the processes view and click on view and the columns. With GDI objects up, you can run your program and see what happens when you wave the mouse around. The other place to look for problems would be if you are doing things with gradients on the datawindows. You have to make sure that those objects are being cleared properly. It is a nasty think to hunt because it can come from many places. Are you using windows themes in your program ( rounded buttons, etc)? If so, make a backup of and then delete the manafest file. If the problem goes away then you would be closer to figuring out where the issue is. Lastly, don’t make too many changes in a row before you retest. If you do you wont really know which one fixed the issue. It takes longer to test this way but gives better results in the end. Regards, Willie "Craig Dawson" wrote in message news:4dc8ba70$0$47013$c30e37c6@pit-reader.telstra.net... Thanks Willie but no mousemove or mousedrag code whatsoever. No errors in any logs are created either. Strange that I have not yet been able to recreate it in XP - just Vista & Win7 (all are up to date with service packs). ----- Regards, Craig. "Willie Moore" <williem@wmconsulting.com> wrote in message news:iqa97b$1eh$1@speranza.aioe.org... > Craig, > > That is pretty strange. I would look at your mouse code. Are you doing any > handlers to track the mouse position? If you are using mousemove or > mousedrag you can eat up memory if you are not careful. Is their any error > message in any log? It will be a hard one to debug but the best way would > be with debout32() and pass debug strings so you can see what the program > is doing without being intrusive with the debugger. While you do that you > can also monitor your GDI objects. See if they are rising. > > Regards, > Willie > > "Craig Dawson" wrote in message > news:4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net... > > Hi all, I have a strange problem. > > I have a POS system that has a window with tabs on them. On those tabs are > a > number of buttons that fill the entire tab page. > It was designed for touch screens and day-in, day-out, it works quite > well - > however for those customers that do not have one and only use a mouse to > click the buttons, they are reporting a problem. > > If they only use the mouse, after around 40-50 transactions, the system > locks up and freezes (note that touch screens are no problem). > At first, I could not reproduce it, however if I got the mouse pointer and > moved it rapidly around in circles over the buttons (they would highlight > / > dehighlight / highlight again atc), after about 30-35 seconds or so bingo! > It froze and the screen went all spastic with buttons disappearing and > then > reappearing in different positions, etc. > > Anyone had this happen to them or have any clues as to what would be > causing > this strange behaviour? > > Thanks in advance, Craig. >
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-11 01:53 +1000 |
| Message-ID | <4dc95f7f$0$47016$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1082 |
Willie, Yes you were right, thanks for the tip - the GDI objects go through the roof and finally the app fails. The buttons are actually inherited from the IconPushButton class originally from Harald Kogler and modified by Paul DB on 31st October 2005. Whilst I don't have any icons on them, I do have text and they are coloured. Perhaps someone has a newer version of the IconPushButton class? I searched but could not find anything. There were a lot of people who also implemented it in their code (according to Google) around the same time I did in November of 2005 and perhaps have already discovered and/or solved the problem. Clutching at straws I guess as many have moved on from VO, but you never know :) Does anyone have a newer version? Regards, Craig. "Willie Moore" <williem@wmconsulting.com> wrote in message news:iqb5ch$dn0$1@speranza.aioe.org... > Craig, > > How about the buttons, are they standard buttons or are the a subclassed > button? I have seen button subclasses over the years that used images > incorrectly. They would leak resources. Here is a trick that you may or > may not know. Open up taskmanager on the machine you are testing. Go to > the processes view and click on view and the columns. With GDI objects up, > you can run your program and see what happens when you wave the mouse > around. The other place to look for problems would be if you are doing > things with gradients on the datawindows. You have to make sure that those > objects are being cleared properly. It is a nasty think to hunt because it > can come from many places. Are you using windows themes in your program > ( rounded buttons, etc)? If so, make a backup of and then delete the > manafest file. If the problem goes away then you would be closer to > figuring out where the issue is. Lastly, don't make too many changes in a > row before you retest. If you do you wont really know which one fixed the > issue. It takes longer to test this way but gives better results in the > end. > > Regards, > Willie > > "Craig Dawson" wrote in message > news:4dc8ba70$0$47013$c30e37c6@pit-reader.telstra.net... > > Thanks Willie but no mousemove or mousedrag code whatsoever. > No errors in any logs are created either. > Strange that I have not yet been able to recreate it in XP - just Vista & > Win7 (all are up to date with service packs). > ----- > Regards, Craig. > > "Willie Moore" <williem@wmconsulting.com> wrote in message > news:iqa97b$1eh$1@speranza.aioe.org... >> Craig, >> >> That is pretty strange. I would look at your mouse code. Are you doing >> any handlers to track the mouse position? If you are using mousemove or >> mousedrag you can eat up memory if you are not careful. Is their any >> error message in any log? It will be a hard one to debug but the best way >> would be with debout32() and pass debug strings so you can see what the >> program is doing without being intrusive with the debugger. While you do >> that you can also monitor your GDI objects. See if they are rising. >> >> Regards, >> Willie >> >> "Craig Dawson" wrote in message >> news:4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net... >> >> Hi all, I have a strange problem. >> >> I have a POS system that has a window with tabs on them. On those tabs >> are a >> number of buttons that fill the entire tab page. >> It was designed for touch screens and day-in, day-out, it works quite >> well - >> however for those customers that do not have one and only use a mouse to >> click the buttons, they are reporting a problem. >> >> If they only use the mouse, after around 40-50 transactions, the system >> locks up and freezes (note that touch screens are no problem). >> At first, I could not reproduce it, however if I got the mouse pointer >> and >> moved it rapidly around in circles over the buttons (they would highlight >> / >> dehighlight / highlight again atc), after about 30-35 seconds or so >> bingo! >> It froze and the screen went all spastic with buttons disappearing and >> then >> reappearing in different positions, etc. >> >> Anyone had this happen to them or have any clues as to what would be >> causing >> this strange behaviour? >> >> Thanks in advance, Craig. >> >
[toc] | [prev] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-05-10 11:57 -0500 |
| Message-ID | <iqbqoo$dld$1@speranza.aioe.org> |
| In reply to | #1088 |
Craig,
Here is a subclass. It isnt exact but it works and uses the image in the 2.8
pushbutton class instead of using an ownerdrawn.
Regards,
Willie
CLASS _ButtonImageList INHERIT ImageList
HIDDEN _oImage AS VObject
METHOD INIT(oImage) CLASS _ButtonImageList
//PP-030915
_oImage := oImage
//Ueberbacher 101209: use Add() to add an icon or AddMask() to add a
bitmap
SUPER:INIT(1, oImage:Size, , _OR(ILC_COLOR32, ILC_MASK))
RETURN SELF
ACCESS Image CLASS _ButtonImageList
RETURN _oImage
METHOD __SetImage(oNewImage) CLASS _PushButton
LOCAL oImageList AS _ButtonImageList
IF IsThemeEnabled()
IF IsInstanceOfUsual(oNewImage, #ICON) .OR.
IsInstanceOfUsual(oNewImage, #Bitmap)
oImageList := _ButtonImageList{oNewImage}
IF IsInstanceOfUsual(oNewImage, #ICON)
oImageList:Add(oNewImage)
ELSE
// Ueberbacher-101209: this is the only way to show a bitmap
transparently on a Button WITH XP-Style
oImageList:AddMask(oNewImage, oMaskColor)
ENDIF
SELF:ImageList := oImageList
RETURN TRUE
ENDIF
ENDIF
RETURN FALSE
ASSIGN Image(oNewImage) CLASS _PushButton
LOCAL dwType AS DWORD
LOCAL lStyle AS LONG
LOCAL lSetStyle AS LONG
LOCAL hImage AS PTR
LOCAL oIcon AS Icon
LOCAL oBitMap AS bitmap
lStyle := GetWindowLong(SELF:Handle(), GWL_STYLE)
lStyle := _AND(lStyle, _NOT(_OR(BS_ICON,BS_BITMAP)))
// Ueberbacher-101209: set the Button style (BS_ICON or BS_BITMAP) only
IF there IS no caption.
// This is the right way (MSDN) to show text and image on a Button.
IF Empty(cCaption)
lStyle := _OR(lStyle, lSetStyle)
ENDIF
SetWindowLong(SELF:Handle(), GWL_STYLE, lStyle)
IF !SELF:__SetImage(oNewImage)
IF IsInstanceOfUsual(oNewImage, #ICON) .OR.
IsInstanceOfUsual(oNewImage, #Bitmap)
oImage := oNewImage
IF IsInstanceOf(oImage, #ICON)
dwType := IMAGE_ICON
lSetStyle := BS_ICON
oIcon := oNewImage
hImage := oIcon:Handle()
ELSE
dwType := IMAGE_BITMAP
lSetStyle := BS_BITMAP
oBitMap := oNewImage
hImage := oBitMap:Handle()
ENDIF
SendMessage(SELF:Handle(), BM_SETIMAGE, dwType, LONG(_CAST,
hImage))
ENDIF
ENDIF
RETURN oImage
CLASS _PushButton INHERIT PushButton
PROTECT oMaskColor AS Color
ASSIGN ImageList(oImageList) CLASS _PushButton
LOCAL sBImageList IS _winButton_ImageList
LOCAL oImgList AS ImageList
IF IsInstanceOfUsual(oImageList, #ImageList)
oImgList := oImageList
IF IsThemeEnabled()
sBImageList.himl := oImgList:Handle()
// Ueberbacher-101209: if there is a caption, align the Button
on the left
IF Empty(cCaption)
sBImageList.uAlign := Button_IMAGELIST_ALIGN_CENTER
ELSE
sBImageList.uAlign := BUTTON_IMAGELIST_ALIGN_LEFT
ENDIF
SendMessage(hWnd, BCM_SETIMAGELIST, 0, LONG(_CAST,@sBImageList))
ENDIF
ENDIF
RETURN (oImage := oImgList)
ASSIGN MaskColor(oColor) CLASS _PushButton
oMaskColor := oColor
RETURN NIL
METHOD INIT( oOwner, xID, oPoint, oDimension, cText, kStyle, lDataAware)
CLASS _PushButton
IF IsInstanceOfUsual(xID,#ResourceID)
SUPER:INIT(oOwner, xID, oPoint, oDimension, , kStyle,lDataAware)
ELSE
SUPER:INIT(oOwner, xID, oPoint, oDimension, "Button",
kStyle,lDataAware)
IF !IsNil(cText)
SELF:caption := cText
ENDIF
ENDIF
// Ueberbacher-101209: a mask color is needed to draw bitmaps
transparently on a button WITH xp-style
oMaskColor := Color{192, 192, 192}
RETURN SELF
"Craig Dawson" wrote in message
news:4dc95f7f$0$47016$c30e37c6@pit-reader.telstra.net...
Willie,
Yes you were right, thanks for the tip - the GDI objects go through the roof
and finally the app fails.
The buttons are actually inherited from the IconPushButton class originally
from Harald Kogler and modified by Paul DB on 31st October 2005. Whilst I
don't have any icons on them, I do have text and they are coloured.
Perhaps someone has a newer version of the IconPushButton class? I searched
but could not find anything. There were a lot of people who also implemented
it in their code (according to Google) around the same time I did in
November of 2005 and perhaps have already discovered and/or solved the
problem.
Clutching at straws I guess as many have moved on from VO, but you never
know :) Does anyone have a newer version?
Regards, Craig.
"Willie Moore" <williem@wmconsulting.com> wrote in message
news:iqb5ch$dn0$1@speranza.aioe.org...
> Craig,
>
> How about the buttons, are they standard buttons or are the a subclassed
> button? I have seen button subclasses over the years that used images
> incorrectly. They would leak resources. Here is a trick that you may or
> may not know. Open up taskmanager on the machine you are testing. Go to
> the processes view and click on view and the columns. With GDI objects up,
> you can run your program and see what happens when you wave the mouse
> around. The other place to look for problems would be if you are doing
> things with gradients on the datawindows. You have to make sure that those
> objects are being cleared properly. It is a nasty think to hunt because it
> can come from many places. Are you using windows themes in your program
> ( rounded buttons, etc)? If so, make a backup of and then delete the
> manafest file. If the problem goes away then you would be closer to
> figuring out where the issue is. Lastly, don't make too many changes in a
> row before you retest. If you do you wont really know which one fixed the
> issue. It takes longer to test this way but gives better results in the
> end.
>
> Regards,
> Willie
>
> "Craig Dawson" wrote in message
> news:4dc8ba70$0$47013$c30e37c6@pit-reader.telstra.net...
>
> Thanks Willie but no mousemove or mousedrag code whatsoever.
> No errors in any logs are created either.
> Strange that I have not yet been able to recreate it in XP - just Vista &
> Win7 (all are up to date with service packs).
> -----
> Regards, Craig.
>
> "Willie Moore" <williem@wmconsulting.com> wrote in message
> news:iqa97b$1eh$1@speranza.aioe.org...
>> Craig,
>>
>> That is pretty strange. I would look at your mouse code. Are you doing
>> any handlers to track the mouse position? If you are using mousemove or
>> mousedrag you can eat up memory if you are not careful. Is their any
>> error message in any log? It will be a hard one to debug but the best way
>> would be with debout32() and pass debug strings so you can see what the
>> program is doing without being intrusive with the debugger. While you do
>> that you can also monitor your GDI objects. See if they are rising.
>>
>> Regards,
>> Willie
>>
>> "Craig Dawson" wrote in message
>> news:4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net...
>>
>> Hi all, I have a strange problem.
>>
>> I have a POS system that has a window with tabs on them. On those tabs
>> are a
>> number of buttons that fill the entire tab page.
>> It was designed for touch screens and day-in, day-out, it works quite
>> well -
>> however for those customers that do not have one and only use a mouse to
>> click the buttons, they are reporting a problem.
>>
>> If they only use the mouse, after around 40-50 transactions, the system
>> locks up and freezes (note that touch screens are no problem).
>> At first, I could not reproduce it, however if I got the mouse pointer
>> and
>> moved it rapidly around in circles over the buttons (they would highlight
>> /
>> dehighlight / highlight again atc), after about 30-35 seconds or so
>> bingo!
>> It froze and the screen went all spastic with buttons disappearing and
>> then
>> reappearing in different positions, etc.
>>
>> Anyone had this happen to them or have any clues as to what would be
>> causing
>> this strange behaviour?
>>
>> Thanks in advance, Craig.
>>
>
[toc] | [prev] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-05-10 11:57 -0500 |
| Message-ID | <iqbqqj$do4$1@speranza.aioe.org> |
| In reply to | #1088 |
Craig, I do have the source for iconpushbutton but I havent used it in a long time. If I have time while I am at the DevShare conference, I will fire up VO and have a look at it. Regards, Willie "Craig Dawson" wrote in message news:4dc95f7f$0$47016$c30e37c6@pit-reader.telstra.net... Willie, Yes you were right, thanks for the tip - the GDI objects go through the roof and finally the app fails. The buttons are actually inherited from the IconPushButton class originally from Harald Kogler and modified by Paul DB on 31st October 2005. Whilst I don't have any icons on them, I do have text and they are coloured. Perhaps someone has a newer version of the IconPushButton class? I searched but could not find anything. There were a lot of people who also implemented it in their code (according to Google) around the same time I did in November of 2005 and perhaps have already discovered and/or solved the problem. Clutching at straws I guess as many have moved on from VO, but you never know :) Does anyone have a newer version? Regards, Craig. "Willie Moore" <williem@wmconsulting.com> wrote in message news:iqb5ch$dn0$1@speranza.aioe.org... > Craig, > > How about the buttons, are they standard buttons or are the a subclassed > button? I have seen button subclasses over the years that used images > incorrectly. They would leak resources. Here is a trick that you may or > may not know. Open up taskmanager on the machine you are testing. Go to > the processes view and click on view and the columns. With GDI objects up, > you can run your program and see what happens when you wave the mouse > around. The other place to look for problems would be if you are doing > things with gradients on the datawindows. You have to make sure that those > objects are being cleared properly. It is a nasty think to hunt because it > can come from many places. Are you using windows themes in your program > ( rounded buttons, etc)? If so, make a backup of and then delete the > manafest file. If the problem goes away then you would be closer to > figuring out where the issue is. Lastly, don't make too many changes in a > row before you retest. If you do you wont really know which one fixed the > issue. It takes longer to test this way but gives better results in the > end. > > Regards, > Willie > > "Craig Dawson" wrote in message > news:4dc8ba70$0$47013$c30e37c6@pit-reader.telstra.net... > > Thanks Willie but no mousemove or mousedrag code whatsoever. > No errors in any logs are created either. > Strange that I have not yet been able to recreate it in XP - just Vista & > Win7 (all are up to date with service packs). > ----- > Regards, Craig. > > "Willie Moore" <williem@wmconsulting.com> wrote in message > news:iqa97b$1eh$1@speranza.aioe.org... >> Craig, >> >> That is pretty strange. I would look at your mouse code. Are you doing >> any handlers to track the mouse position? If you are using mousemove or >> mousedrag you can eat up memory if you are not careful. Is their any >> error message in any log? It will be a hard one to debug but the best way >> would be with debout32() and pass debug strings so you can see what the >> program is doing without being intrusive with the debugger. While you do >> that you can also monitor your GDI objects. See if they are rising. >> >> Regards, >> Willie >> >> "Craig Dawson" wrote in message >> news:4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net... >> >> Hi all, I have a strange problem. >> >> I have a POS system that has a window with tabs on them. On those tabs >> are a >> number of buttons that fill the entire tab page. >> It was designed for touch screens and day-in, day-out, it works quite >> well - >> however for those customers that do not have one and only use a mouse to >> click the buttons, they are reporting a problem. >> >> If they only use the mouse, after around 40-50 transactions, the system >> locks up and freezes (note that touch screens are no problem). >> At first, I could not reproduce it, however if I got the mouse pointer >> and >> moved it rapidly around in circles over the buttons (they would highlight >> / >> dehighlight / highlight again atc), after about 30-35 seconds or so >> bingo! >> It froze and the screen went all spastic with buttons disappearing and >> then >> reappearing in different positions, etc. >> >> Anyone had this happen to them or have any clues as to what would be >> causing >> this strange behaviour? >> >> Thanks in advance, Craig. >> >
[toc] | [prev] | [next] | [standalone]
| From | "Bernhard Mayer" <Idonotexisthere@nowhere.com> |
|---|---|
| Date | 2011-05-11 07:35 +0200 |
| Message-ID | <4dca2018$0$1573$91cee783@newsreader04.highway.telekom.at> |
| In reply to | #1088 |
Hi Craig!
Enclosed find some of our code (Which was mostly done by Harald Kogler btw -
he sits right next to me <g>); maybe it won't compile as I just copied it
from our PushButton class, but it might give you something to start with.
BR,
Bernhard
CLASS pshStandard INHERIT PushButton
METHOD Destroy() CLASS pshStandard
IF SELF:oBitmap != NULL_OBJECT
DeleteObject(SELF:oBitmap:handle())
SELF:oBitmap:destroy()
SELF:oBitmap := NULL_OBJECT
ENDIF
IF SELF:dwImgType = IMAGE_ICON .AND. SELF:hImage != NULL_PTR
DestroyIcon(SELF:hImage)
SELF:hImage := NULL_PTR
ENDIF
IF SELF:oBackGround != NULL_OBJECT
DeleteObject(SELF:oBackGround:handle())
SELF:oBackGround:Destroy()
SELF:oBackGround := NULL_OBJECT
ENDIF
IF SELF:oContextMenu != NULL_OBJECT
SELF:oContextMenu:Destroy()
SELF:oContextMenu := NULL_OBJECT
ENDIF
IF SELF:oImageSize != NULL_OBJECT
SELF:oImageSize:= NULL_OBJECT
ENDIF
IF SELF:oHiLightBitmap != NULL_OBJECT
SELF:oHiLightBitmap:Destroy()
SELF:oHiLightBitmap:= NULL_OBJECT
ENDIF
IF SELF:oDisabledBitmap != NULL_OBJECT
SELF:oDisabledBitmap:Destroy()
SELF:oDisabledBitmap:= NULL_OBJECT
ENDIF
IF SELF:oImage != NULL_OBJECT
SELF:oImage:Destroy()
SELF:oImage := NULL_OBJECT
ENDIF
RETURN SUPER:Destroy()
METHOD UseRibbon(cResource, hInst, nImage, oSize, oSizeNew, oStartPoint)
CLASS pshStandard
Default(@oSizeNew, oSize)
Default(@oStartPoint, Point{0,0})
SELF:lUseImage := TRUE
SELF:dwImgType := IMAGE_BITMAP
SELF:oBitmap := BitmapfromRibbon{cResource, hInst, nImage, oSize, oSizeNew,
oStartPoint, #NORMAL}
SELF:oHiLightBitmap := BitmapfromRibbon{cResource, hInst, nImage, oSize,
oSizeNew, oStartPoint, #HILIGHT}
SELF:oDisabledBitmap := BitmapfromRibbon{cResource, hInst, nImage, oSize,
oSizeNew, oStartPoint, #DISABLED}
SELF:oImageSize := SELF:oBitmap:Size
RETURN NIL// TRUE
METHOD UseBitmap(oBmp AS Bitmap, oBitmapHL AS Bitmap, oBitmapDisabled AS
Bitmap) AS LOGIC PASCAL CLASS pshStandard
IF oBmp == NULL_OBJECT
SELF:lUseImage := FALSE
IF SELF:oBitmap != NULL_OBJECT
SELF:oBitmap:Destroy()
ENDIF
IF SELF:oHiLightBitmap != NULL_OBJECT
SELF:oHiLightBitmap:Destroy()
ENDIF
IF SELF:oDisabledBitmap != NULL_OBJECT
SELF:oDisabledBitmap:Destroy()
ENDIF
SELF:oBitmap := NULL_OBJECT
SELF:oHiLightBitmap := NULL_OBJECT
SELF:oDisabledBitmap := NULL_OBJECT
SELF:oImageSize := Dimension{0, 0}
ELSE
SELF:lUseImage := TRUE
SELF:dwImgType := IMAGE_BITMAP
SELF:oBitmap := oBmp
IF oBitmapHL != NULL_OBJECT
SELF:oHiLightBitmap := oBitmapHL
ELSE
SELF:oHiLightBitmap := oBmp
ENDIF
IF oBitmapDisabled != NULL_OBJECT
SELF:oDisabledBitmap := oBitmapDisabled
ELSE
SELF:oDisabledBitmap := oBmp
ENDIF
SELF:oImageSize := oBmp:Size
ENDIF
RETURN SELF:lUseImage
ASSIGN UseColor(oBrush AS Brush) AS VOID PASCAL CLASS pshStandard
IF oBrush == NULL_OBJECT
SELF:lUseColor := FALSE
IF SELF:oBackGround != NULL_OBJECT
DeleteObject(SELF:oBackground:handle())
SELF:oBackGround:destroy()
SELF:oBackGround := NULL_OBJECT
ENDIF
ELSE
SELF:lUseColor := TRUE
IF SELF:oBackground != oBrush .AND. SELF:oBackground != NULL_OBJECT
DeleteObject(SELF:oBackground:handle())
SELF:oBackground:destroy()
ENDIF
SELF:oBackGround := oBrush
ENDIF
InvalidateRect(SELF:handle(), NULL_PTR, TRUE)
RETURN // SELF:lUseColor
ASSIGN UseIcon(hIcon AS PTR) AS VOID PASCAL CLASS pshStandard
IF hIcon == NULL_PTR
SELF:lUseImage := FALSE
SELF:hImage := NULL_PTR
SELF:oImageSize := Dimension{0, 0}
ELSE
SELF:lUseImage := TRUE
SELF:dwImgType := IMAGE_ICON
SELF:hImage := hIcon
SELF:oImageSize := Dimension{16, 16}
ENDIF
RETURN // SELF:lUseImage
"Craig Dawson" <craig@control.nospam.net.au> schrieb im Newsbeitrag
news:4dc95f7f$0$47016$c30e37c6@pit-reader.telstra.net...
> Willie,
>
> Yes you were right, thanks for the tip - the GDI objects go through the
> roof and finally the app fails.
>
> The buttons are actually inherited from the IconPushButton class
> originally from Harald Kogler and modified by Paul DB on 31st October
> 2005. Whilst I don't have any icons on them, I do have text and they are
> coloured.
>
> Perhaps someone has a newer version of the IconPushButton class? I
> searched but could not find anything. There were a lot of people who also
> implemented it in their code (according to Google) around the same time I
> did in November of 2005 and perhaps have already discovered and/or solved
> the problem.
>
> Clutching at straws I guess as many have moved on from VO, but you never
> know :) Does anyone have a newer version?
>
> Regards, Craig.
>
>
> "Willie Moore" <williem@wmconsulting.com> wrote in message
> news:iqb5ch$dn0$1@speranza.aioe.org...
>> Craig,
>>
>> How about the buttons, are they standard buttons or are the a subclassed
>> button? I have seen button subclasses over the years that used images
>> incorrectly. They would leak resources. Here is a trick that you may or
>> may not know. Open up taskmanager on the machine you are testing. Go to
>> the processes view and click on view and the columns. With GDI objects
>> up, you can run your program and see what happens when you wave the mouse
>> around. The other place to look for problems would be if you are doing
>> things with gradients on the datawindows. You have to make sure that
>> those objects are being cleared properly. It is a nasty think to hunt
>> because it can come from many places. Are you using windows themes in
>> your program ( rounded buttons, etc)? If so, make a backup of and then
>> delete the manafest file. If the problem goes away then you would be
>> closer to figuring out where the issue is. Lastly, don't make too many
>> changes in a row before you retest. If you do you wont really know which
>> one fixed the issue. It takes longer to test this way but gives better
>> results in the end.
>>
>> Regards,
>> Willie
>>
>> "Craig Dawson" wrote in message
>> news:4dc8ba70$0$47013$c30e37c6@pit-reader.telstra.net...
>>
>> Thanks Willie but no mousemove or mousedrag code whatsoever.
>> No errors in any logs are created either.
>> Strange that I have not yet been able to recreate it in XP - just Vista &
>> Win7 (all are up to date with service packs).
>> -----
>> Regards, Craig.
>>
>> "Willie Moore" <williem@wmconsulting.com> wrote in message
>> news:iqa97b$1eh$1@speranza.aioe.org...
>>> Craig,
>>>
>>> That is pretty strange. I would look at your mouse code. Are you doing
>>> any handlers to track the mouse position? If you are using mousemove or
>>> mousedrag you can eat up memory if you are not careful. Is their any
>>> error message in any log? It will be a hard one to debug but the best
>>> way would be with debout32() and pass debug strings so you can see what
>>> the program is doing without being intrusive with the debugger. While
>>> you do that you can also monitor your GDI objects. See if they are
>>> rising.
>>>
>>> Regards,
>>> Willie
>>>
>>> "Craig Dawson" wrote in message
>>> news:4dc85f07$0$47019$c30e37c6@pit-reader.telstra.net...
>>>
>>> Hi all, I have a strange problem.
>>>
>>> I have a POS system that has a window with tabs on them. On those tabs
>>> are a
>>> number of buttons that fill the entire tab page.
>>> It was designed for touch screens and day-in, day-out, it works quite
>>> well -
>>> however for those customers that do not have one and only use a mouse to
>>> click the buttons, they are reporting a problem.
>>>
>>> If they only use the mouse, after around 40-50 transactions, the system
>>> locks up and freezes (note that touch screens are no problem).
>>> At first, I could not reproduce it, however if I got the mouse pointer
>>> and
>>> moved it rapidly around in circles over the buttons (they would
>>> highlight /
>>> dehighlight / highlight again atc), after about 30-35 seconds or so
>>> bingo!
>>> It froze and the screen went all spastic with buttons disappearing and
>>> then
>>> reappearing in different positions, etc.
>>>
>>> Anyone had this happen to them or have any clues as to what would be
>>> causing
>>> this strange behaviour?
>>>
>>> Thanks in advance, Craig.
>>>
>>
>
>
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-13 06:59 +1000 |
| Message-ID | <4dcc4a3f$0$47020$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1094 |
Thanks Bernhard,
Here is the code to the IconPushButton class I currently have.
Can anyone see anything obvious in it that would cause the GDIs to keep
increasing? It's driving me crazy.
Regards, Craig.
METHOD Enable() CLASS IconPushbutton
// added by PDB 24/2/2003 to be able to show a "disabled" icon
IF SELF:_lDisabled==TRUE // currently disabled
SELF:_lDisabled:=FALSE
ENDIF
IF SELF:_oIconEnabled <> NULL_OBJECT
SELF:UseIcon:=SELF:_oIconEnabled:Handle()
ENDIF
InvalidateRect(SELF:handle(),NULL_PTR, TRUE) // to fix repainting problem
caused by VO2.6 if button used on tabpage
?
SUPER:Enable()
METHOD Disable() CLASS IconPushbutton
// added by PDB 24/2/2003 to be able to show a "disabled" icon
IF SELF:_lDisabled==FALSE
SELF:_lDisabled:=TRUE
ENDIF
IF SELF:_oIconDisabled <> NULL_OBJECT
SELF:UseIcon:= SELF:_oIconDisabled:Handle()
ELSE
// don't change icon but continue to use the "Upicon"
ENDIF
InvalidateRect(SELF:handle(),NULL_PTR, TRUE) // to fix repainting problem
caused by VO2.6 if button used on tabpage
?
?
SUPER:Disable()
CLASS IconPushbutton INHERIT PUSHBUTTON
/*
Class from Harald Kogler: kog@kns.at feb 2003
I played with the Visual Themes some time ago... this works fine for me
This is a Class, which can Display an Icon or a Bitmap next to the
Button-Text or a Button-Backgroundcolor.
Should work on any Kind of Theme you've set...
*/
?
PROTECT lIsTabWindow AS LOGIC
PROTECT lHilight AS LOGIC
PROTECT lUseImage AS LOGIC
PROTECT lUseColor AS LOGIC
PROTECT dwImgType AS DWORD
PROTECT hImage AS PTR
PROTECT _lFocus AS LOGIC
PROTECT _lPressed AS LOGIC
PROTECT _lDisabled AS LOGIC
PROTECT oBackGround AS Brush
PROTECT oBitmap AS Bitmap
PROTECT pXPTheme AS PTR
PROTECT pXPOpenThemeFunc AS PTR
PROTECT pXPCloseThemeFunc AS PTR
PROTECT pXPDrawFrameFunc AS PTR
PROTECT pXPDrawEdgeFunc AS PTR
PROTECT lXP AS LOGIC
?
PROTECT _oIconEnabled AS icon // PDB
PROTECT _oIconDisabled AS icon // pdb
DECLARE METHOD UseBitmap
DECLARE ASSIGN UseIcon
DECLARE ASSIGN UseColor
?
METHOD AxitXP() CLASS IconPushbutton
IF SELF:lXP
PCALL(SELF:pXPCloseThemeFunc, SELF:pXPTheme)
ENDIF
?
METHOD Expose(oEvent) CLASS IconPushbutton
?
LOCAL hDC, hHandle AS PTR
LOCAL sRect IS _winRECT
LOCAL sPs IS _winPAINTSTRUCT
LOCAL hPenBlack, hFont, hBrushBack, hBackGround AS PTR
LOCAL dwBtnStyle AS DWORD
LOCAL lKillFont AS LOGIC
LOCAL hDCSrc AS PTR
LOCAL oSize AS Dimension
LOCAL nOffset AS INT
LOCAL nIconheight AS DWORD // PDB, so we can resize the icon according to
the height of the button
LOCAL nREctWidth AS DWORD
LOCAL lMultiline AS LOGIC
?
LOCAL dwXPBtnStyle AS DWORD
hHandle := SELF:handle()
hDC := BeginPaint(hHandle, @sPs)
SetBkMode(hdc, TRANSPARENT)
hPenBlack := CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNTEXT))
hBrushBack := CreateSolidBrush(GetSysColor(COLOR_3DFACE))
IF SELF:lUseColor
hBackGround := SELF:oBackGround:handle()
SelectObject (hDC, hBackGround)
ENDIF
?
?
sRect.top := 0
sRect.left := 0
sRect.bottom := SELF:size:height - 1
sRect.right := SELF:size:width - 1
dwBtnStyle := DFCS_BUTTONPUSH
dwXPBtnStyle := 1
IF (!SELF:_lPressed .AND. SELF:_lFocus) .OR. SELF:_lPressed
IF !SELF:lXP
SelectObject(hDC, hPenBlack)
MoveToEx(hDC, sRect.left, sRect.top, NULL_PTR)
LineTo(hDC, sRect.right, sRect.top)
LineTo(hDC, sRect.right, sRect.bottom)
LineTo(hDC, sRect.left, sRect.bottom)
LineTo(hDC, sRect.left, sRect.top)
ENDIF
sRect.left += 1
sRect.top += 1
dwXPBtnStyle := 5
IF SELF:_lPressed
dwBtnStyle := DFCS_BUTTONPUSH+DFCS_PUSHED
dwXPBtnStyle := 3
ENDIF
ELSEIF !SELF:_lPressed .AND. !SELF:_lFocus
sRect.bottom += 1
sRect.right += 1
ENDIF
IF SELF:lHilight .AND. !SELF:_lPressed
dwXPBtnStyle := 2
ENDIF
IF SELF:_lDisabled
dwXPBtnStyle := 4
ENDIF
IF SELF:lXP
PCALL(SELF:pXPDrawFrameFunc, SELF:pXPTheme, hDC, 1, dwXPBtnStyle,
@sRect,NULL_PTR)
ELSE
DrawFrameControl(hDC, @sRect, DFC_BUTTON, dwBtnStyle)
ENDIF
?
IF SELF:lUseColor
SelectObject(hDC, GetStockObject(NULL_PEN))
DO CASE
CASE SELF:_lPressed
Rectangle(hDC, sRect.left+3, sRect.top+3, sRect.right-1, sRect.Bottom-1)
CASE SELF:lXP
Rectangle(hDC, sRect.left+3, sRect.top+3, sRect.right-2, sRect.Bottom-2)
OTHERWISE
Rectangle(hDC, sRect.left+2, sRect.top+2, sRect.right-2, sRect.Bottom-2)
ENDCASE
SelectObject(hDC, hPenBlack)
ENDIF
?
?
// Draw the icon:
IF SELF:lUseImage
IF SELF:dwImgType == IMAGE_ICON
nIconHeight := SELF:size:Height-4
** nOffset := 4 // PDB
nOffset := 2 // make icon border only 2 pixels
IF SELF:_lPressed
nOffset += 1
ENDIF
** DrawIconEx(hDC, nOffset, nOffset, SELF:hImage, 16, 16, 0, NULL_PTR,
DI_NORMAL) //PDB
DrawIconEx(hDC, nOffset, nOffset, SELF:hImage, nIconHeight, nIconHeight, 0,
NULL_PTR, DI_NORMAL) //PDB for support 32x32 icon
ELSEIF SELF:dwImgType == IMAGE_BITMAP
nOffset := 2
IF SELF:_lPressed
nOffset += 1
ENDIF
oSize := SELF:oBitmap:size
IF (SELF:Size:width - 4) < oSize:width
oSize:width := SELF:Size:width - 4
ENDIF
IF (SELF:Size:Height - 4) < oSize:height
oSize:Height := SELF:Size:Height - 4
ENDIF
hDCSrc := CreateCompatibleDC(hDC)
SelectObject(hDCSrc, SELF:oBitmap:handle())
BitBlt(hDC, nOffset, nOffset, oSize:width, oSize:height, hDCSrc, 0, 0,
SRCCOPY)
DeleteDC(hDCSrc)
ENDIF
ENDIF
?
// Draw the caption:
IF SLen(SELF:Caption) > 0
IF SELF:oFont == NULL_OBJECT
lKillFont := TRUE
hFont := GetStockObject(DEFAULT_GUI_FONT)
IF hFont == NULL_PTR
hFont := GetStockObject(SYSTEM_FONT)
ENDIF
ELSE
hFont := SELF:oFont:handle()
ENDIF
SelectObject(hDC, hFont)
// define rectangle for the caption
sRect.top +=2
sRect.bottom -= 3
** sRect.left += 20
//PDB: place the caption text as much aside as the icon is big:
IF nIconHeight <> 0
sRect.left := nIconheight
ELSE
sRect.left += 2 // no icon
ENDIF
sRect.right -= 4
?
// PDB: first check if the width of the button can accomadate the caption.
If not, switch to multiline button
nREctWidth := sRect.right - sRect.left // available space
// how long is the text
IF getDisplayTextWidth(SELF:Caption,hFont) > nREctWidth
lMultiline := TRUE
ENDI
?
?
IF !SELF:_lDisabled
SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT))
IF SELF:_lPressed
sRect.top += 1
sRect.left += 1
sRect.bottom += 1
sRect.right += 1
ENDIF
IF !lMultiline
DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
@sRect,DT_SINGLELINE+DT_CENTER+DT_VCENTER)
ELSE
DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
@sRect,DT_CENTER+DT_WORDBREAK)
ENDIF
ELSE
sRect.top += 1
sRect.left += 1
sRect.bottom += 1
sRect.right += 1
SetTextColor(hDC, GetSysColor(COLOR_3DHILIGHT))
IF !lMultiline
DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
@sRect,DT_SINGLELINE+DT_CENTER+DT_VCENTER)
ELSE
DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
@sRect,DT_CENTER+DT_WORDBREAK)
ENDIF
// draw shadow
sRect.top -= 1
sRect.left -= 1
sRect.bottom -= 1
sRect.right -= 1
SetTextColor(hDC, GetSysColor(COLOR_3DSHADOW))
IF !lMultiline
DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
@sRect,DT_SINGLELINE+DT_CENTER+DT_VCENTER)
ELSE
DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
@sRect,DT_CENTER+DT_WORDBREAK)
ENDIF
ENDIF
IF SELF:_lFocus
SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT))
DrawFocusRect(hDC, @sRect)
ENDIF
ENDIF
EndPaint(hHandle, @sPs)
IF lKillFont
DeleteObject(hFont)
ENDIF
DeleteObject(hPenBlack)
DeleteObject(hBrushBack)
ReleaseDC(hHandle, hDC)
DeleteDC(hDC)
?
?
?
METHOD MouseButtonUp(oEvent) CLASS IconPushbutton
IF SELF:lUseImage
IF oEvent:IsLeftButton
_lPressed := FALSE
SELF:owner:RepaintBoundingBox(BoundingBox{SELF:origin, SELF:size})
ENDIF
ENDIF
SUPER:MouseButtonUp(oEvent)
ASSIGN IconDisabled(oIco) CLASS IconPushbutton
// Set the icon for disabled state
// you can set this assign in the INIT() of an inherited icon class (bv
CopyPushbutton)
SELF:_oIconDisabled:=oIco
RETURN _oIconDisabled
METHOD InitXP() CLASS IconPushbutton
** A few fixes made by Paul De Bie 25/2/2003 because of 5333 crash
LOCAL pszControl AS PTR
LOCAL pszUCString AS PTR
LOCAL iRet AS INT
LOCAL iUCStrLen AS INT
IF !SELF:lXP
SELF:pXPOpenThemeFunc :=
GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),String2Psz("OpenThemeData"))
SELF:pXPCloseThemeFunc :=
GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),
String2Psz("CloseThemeData"))
SELF:pXPDrawFrameFunc :=
GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),
String2Psz("DrawThemeBackground"))
SELF:pXPDrawEdgeFunc :=
GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),String2Psz("DrawThemeEdge"))
IF SELF:pXPOpenThemeFunc != NULL_PTR .AND. SELF:pXPCloseThemeFunc !=
NULL_PTR .AND. SELF:pXPDrawFrameFunc != NULL_PTR .AND. SELF:pXPDrawEdgeFunc
!= NULL_PTR
SELF:lXP := TRUE
ENDIF
ENDIF
// IF SELF:lXP
// pszControl := String2Psz("BUTTON")
// nStrLen := MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszControl, -1,
NULL_PTR, 0)
//
// IF nStrLen != 0
// pszUCString := MemAlloc(nStrLen)
// *** EXE CRASHES ON NEXT STATEMENT!!!
// iRet := MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
pszControl, -1,pszUCString, nStrLen)
// //
// SELF:pXPTheme := PCALL(pXPOpenThemeFunc, NULL, PSZUCString)
// IF SELF:pXPTheme == NULL_PTR
// SELF:lXP := FALSE
// ENDIF
// MemFree(pszUCString)
// ENDIF
// ENDIF
// PDB:
IF SELF:lXP
// allocate a buffer large enough for equivalent Unicode string
// at most twice as big; +1 for trailing terminator
iUCStrLen := 2 * (SLen("BUTTON") +1)
pszUCString := MemAlloc(iUCStrLen)
pszControl := String2Psz("BUTTON")
IF pszUCString != NULL_PTR
// write the number of "wide" characters to pszUCString
iRet := MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
pszControl, -1,pszUCString, iUCStrLen)
IF iRet !=0 // succes? open XP Theme
SELF:pXPTheme := PCALL(pXPOpenThemeFunc, NULL, pszUCString)
IF SELF:pXPTheme == NULL_PTR
SELF:lXP := FALSE
ENDIF
ELSE
SELF:lXP := FALSE
ENDIF
MemFree(pszUCString)
ENDIF
ENDIF
?
METHOD UseBitmap(oBmp AS Bitmap, hBitmap AS PTR) AS LOGIC PASCAL CLASS
IconPushbutton
IF hBitmap == NULL_PTR
SELF:lUseImage := FALSE
SELF:hImage := NULL_PTR
SELF:AxitXP()
ELSE
SELF:lUseImage := TRUE
SELF:dwImgType := IMAGE_BITMAP
* SELF:oBitmap := BitMap{ResourceID{NULL_STRING, _GetInst()}}
SELF:oBitmap := oBmp
* SELF:oBitmap:hBitMapPtr := hBitmap
SELF:hImage := hBitmap
SELF:InitXP()
ENDIF
RETURN SELF:lUseImage
ASSIGN UseColor(oBrush AS Brush) AS LOGIC PASCAL CLASS IconPushbutton
// attention: has NO EFFECT when there is an icon assigned to the button!
IF oBrush == NULL_OBJECT
SELF:lUseColor := FALSE
IF SELF:oBackGround != NULL_OBJECT
DeleteObject(SELF:oBackground:handle())
SELF:oBackGround:destroy()
SELF:oBackGround := NULL_OBJECT
ENDIF
SELF:AxitXP()
ELSE
SELF:lUseColor := TRUE
IF SELF:oBackground != oBrush .AND. SELF:oBackground != NULL_OBJECT
DeleteObject(SELF:oBackground:handle())
SELF:oBackground:destroy()
ENDIF
SELF:oBackGround := oBrush
SELF:InitXP()
ENDIF
InvalidateRect(SELF:handle(), NULL_PTR, TRUE)
RETURN SELF:lUseColor
ASSIGN UseIcon(hIcon AS PTR) AS LOGIC PASCAL CLASS IconPushbutton
IF hIcon == NULL_PTR
SELF:lUseImage := FALSE
SELF:hImage := NULL_PTR
SELF:AxitXP()
ELSE
SELF:lUseImage := TRUE
SELF:lXP := FALSE // to force the InitXp to check if XP Themes are active
SELF:dwImgType := IMAGE_ICON
SELF:hImage := hIcon
SELF:InitXP()
ENDIF
RETURN SELF:lUseImage
?
?
ASSIGN IconEnabled(oIco) CLASS IconPushbutton
// Set the icon for enabled state
// you can set this assign in the INIT() of an inherited icon class (bv
CopyPushbutton)
SELF:_oIconEnabled:=oIco
RETURN _oIconEnabled
METHOD FocusChange(oEvent) CLASS IconPushbutton
// Callback, called if object recieves or loose focus
// PDB: this makes that the button, when you tab to them (with tab key),
have a "focused" look (blue border)
SUPER:focusChange (oEvent)
IF oEvent:gotFocus
// give the button a look such as the "default" one
PostMessage (SELF:handle(), BM_SETSTYLE, BS_DEFPUSHBUTTON, 1)
SELF:_lFocus := TRUE
ELSE
PostMessage (SELF:handle(), BM_SETSTYLE, BS_PUSHBUTTON, 1)
SELF:_lFocus := FALSE
ENDIF
IF SELF:lUseImage // if image, redraw the button
InvalidateRect(SELF:handle(), NULL_PTR, TRUE)
ENDIF
RETURN
METHOD Destroy() CLASS IconPushbutton
IF SELF:oBitmap != NULL_OBJECT
DeleteObject(SELF:oBitmap:handle())
SELF:oBitmap:destroy()
SELF:oBitmap := NULL_OBJECT
SELF:hImage := NULL_PTR
ENDIF
IF SELF:oBackGround != NULL_OBJECT
DeleteObject(SELF:oBackGround:handle())
SELF:oBackGround:Destroy()
SELF:oBackGround := NULL_OBJECT
ENDIF
SELF:AxitXP()
SUPER:Destroy()
?
METHOD SetStyle(kStil, lAktivieren) CLASS IconPushbutton
IF IsNil(lAktivieren)
lAktivieren := TRUE
ENDIF
IF kStil == WS_DISABLED
SELF:_lDisabled := lAktivieren
ENDIF
IF kStil == BS_DEFPUSHBUTTON .AND. lAktivieren == FALSE
PostMessage (SELF:handle(), BM_SETSTYLE, BS_PUSHBUTTON, 1)
ELSE
SUPER:SetStyle(kStil, lAktivieren)
ENDIF
?
METHOD Init(oOwner, nID, oPoint, oDim, cText, kStyle) CLASS IconPushbutton
SUPER:init(oOwner, nID, oPoint, oDim, cText, kStyle)
// Stelle fest, ob es sich beim Owner um ein Tabfenster
// der Klasse Dialogwindow handelt
IF IsInstanceOf(oOwner, #DIALOGWINDOW)
* SELF:lIsTabWindow := !(_And (GetWindowLong (oOwner:handle (), GWL_Style),
WS_POPUP) != 0 )
ENDIF
METHOD MouseButtonDown(oEvent) CLASS IconPushbutton
IF SELF:lUseImage
IF oEvent:IsLeftButton
_lPressed := TRUE
SELF:owner:RepaintBoundingBox(BoundingBox{SELF:origin, SELF:size})
ENDIF
ENDIF
SUPER:MouseButtonDown(oEvent)
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
?
ENDIF
RETURN nWidth
?
TEXTBLOCK readme
/*
Class from Harald Kogler: kog@kns.at feb 2003
I played with the Visual Themes some time ago... this works fine for me
This is a Class, which can Display an Icon or a Bitmap next to the
Button-Text or a Button-Backgroundcolor.
Should work on any Kind of Theme you've set...
REMARKS FROM PAUL DE BIE:
- To set a background color:
Assign UseColor --> Brush e.g. SELF:occPbtest:Usecolor :=
Brush{Color{COLORYELLOW},HATCHSOLID}
- To set an icon:
Assign IconEnabled --> icon object e.g. SELF:oCCpbTest:IconEnabled :=
{PrinterUp}
or e.g. SELF:oCCpbTest:IconEnabled := { ResourceId{"PrinterUp",
_GetInst()} }
Assign IconDisabled --> icon object (if not set, then uses the same Icon as
IconEnabled)
?
Changed by PDB 02/2003:
======================
- icons are now always 32*32 instead of 16*16 (but if your button is smaller
than 32 pixels, the icons will be automatically reduced in size)
- added possibility to enable/disable the button.
- can now be used just as the former Iconpushbutton class; by making icon
resources first for enabled/disabled states
- Use now the assign IconEnabled or IconDisabled (ICO object type) to set
the Up/Enabled icons (normally they must be set
in the INIT of the subclassed pushbutton, but you can change them afterwards
too.)
-> a SELF:Enable() must be done once to set the icon for the first time; you
can also do this from within the Init() of
your subclassed buttons
- Fixed a 5333 crash in INITXP() method
- Tested to see if XP Theme can be changed while Appli is running: OK this
gives no problems, it works!
Changed PDB 23/6/2003:
=====================
- In ExposeEX and ExposeCol; I now check to see if the caption (text) fits
on the pushbutton; if not the pushbutton style is
changed to multiline instead of single line
Changed PDB 31/10/2005:
======================
- Merged the two Expose methods (ExposeEX and ExposeCol) which makes it now
possible to use both an Icon AND a background color
?
REMARK: don't use the Bitmap anymore - didn't test it to see it supports my
changes!
?
HOW TO USE THIS CLASS
=====================
?
- In order to compile, you will have to put all of the icons in a folder
called:
C:\Cavo_Bitmaps_and_Icons\General_use
If you want them in another folder, then search/replace the foldername in
all resource entities. Attention: do NOT use
foldernames that contain spaces or it won't compile.
?
?
- If you don't need icons, but just a colored background:
inherit your pushbutton from Iconpushbutton class
Assign the color SELF:occPbtest:Usecolor :=
Brush{Color{COLORYELLOW},HATCHSOLID}
?
- If you want to show Icons with two states (enabled/disabled):
?
You need two icons for each pushbutton, one normal and one "greyed out". You
can easily do this
with an Icon editor. Or with a graphics program: open the colored icon,
convert it to greyscale, then save with another name.
I have for each type of pushbutton a different class; I have them all in a
library that I link into my application when needed.
So all I have to do when I need, say, a pushbutton with a printer, is to put
a standard PB (via the WED) on my form
and have it inherit from the appropriate class, e.g. printerPushButton.
Below an example for one such pushbutton class.
In this example I use two icons: PrinterDisabled.ico and PrinterUp.ico in a
folder c:\temp\
?
?
CLASS PrinterPushButton INHERIT IconPushbutton
METHOD INIT(oOwner,nId,oPoint,oDimension,cText) CLASS PrinterPushButton
SUPER:INIT(oOwner,nId,oPoint,oDimension,cText)
SELF:IconEnabled := PrinterUP{}
SELF:iconDisabled := PrinterDisabled{}
SELF:Enable()
CLASS PRINTERDISABLED INHERIT Icon
RESOURCE PRINTERDISABLED Icon c:\temp\PrinterDisabled.ico
METHOD Init() CLASS PRINTERDISABLED
SUPER:init(ResourceID{"PRINTERDISABLED", _GetInst()})
CLASS PRINTERUP INHERIT Icon
RESOURCE PRINTERUP Icon c:\temp\PrinterUp.ico
METHOD Init() CLASS PRINTERUP
SUPER:init(ResourceID{"PRINTERUP", _GetInst()})
?
?
NB: you'll have some more work setting up all the classes for each
pushbutton;
but afterwards in your application it's a piece of cake and no code needed
at all, just "inherit from" and voilà.
?
?
?
?
?
*/
METHOD Dispatch(oEvent) CLASS IconPushbutton
IF oEvent:Message == BM_SETSTATE
// Button Status geändert ?
IF ! SELF:_lPressed .AND. oEvent:wParam == 1
SELF:_lPressed := TRUE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ELSEIF SELF:_lPressed .AND. oEvent:wParam == 0
SELF:_lPressed := FALSE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ENDIF
ENDIF
** IF oEvent:uMsg == WM_PAINT
** SELF:Expose(oEvent)
** SELF:EventReturnValue := 0L
** RETURN 0L
** ENDIF
IF oEvent:message == WM_MOUSEMOVE .AND. !SELF:lHilight
SELF:lHilight := TRUE
ENDIF
IF oEvent:message == 0x2A3 .AND. SELF:lHilight//WM_MOUSELEAVE
SELF:lHilight := FALSE
ENDIF
IF oEvent:message == 0x128 //WM_UPDATEUISTATE
SELF:Expose(oEvent)
SELF:EventReturnValue := 1L
RETURN 1L
ENDIF
IF oEvent:message == 0x031A //WM_THEMECHANGED
SELF:AxitXP()
SELF:lXP := FALSE
SELF:InitXP()
ENDIF
IF oEvent:message == WM_GETDLGCODE
IF oEvent:wParam = VK_RETURN
// Drückt zwar den Button, ruft aber nicht die Methode auf
*PostMessage (SELF:handle(), WM_KEYDOWN, VK_SPACE, 0)
// Rufe die Methode zum Button auf (Falls diese existiert)
IF SELF:lIsTabWindow // Nur bei Tabwindows
IF IsMethod (SELF:owner, SELF:NameSym)
Send (SELF:owner, SELF:NameSym)
ENDIF
** SELF:EventReturnValue := 1L
** RETURN 1L
ENDIF
ENDIF
ENDIF
RETURN SUPER:Dispatch(oEvent)
CLASS cdPosItemButton INHERIT ICONPUSHBUTTONEXPORT aItemInfo AS ARRAY
EXPORT cItemNo AS STRING
METHOD Dispatch(oEvent) CLASS cdPosItemButton
// CASE InList(oE:Message, WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_LBUTTONUP)
IF oEvent:message == WM_RBUTTONDOWN //MOVE .AND. !SELF:lHilight
IF SELF:NameSym != #pbPosButton .AND. SELF:NameSym != #pbPosButtonNew //
Just so we don't process again if button is clicked in the setup button
window
IF IsMethod (SELF:owner:owner, #cdSetupButton)
SELF:owner:owner:cdSetupButton(SELF)
ENDIF
ENDIF
ENDIF
RETURN SUPER:Dispatch(oEvent)
?
?
[toc] | [prev] | [next] | [standalone]
| From | "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> |
|---|---|
| Date | 2011-05-13 08:57 +1000 |
| Message-ID | <QEZyp.4093$aH5.2847@viwinnwfe02.internal.bigpond.com> |
| In reply to | #1110 |
Craig > InvalidateRect(SELF:handle(),NULL_PTR, TRUE) // to fix repainting problem > caused by VO2.6 if button used on tabpage Maybe the repaint bug has been fixed in VO2.8 and the above is no longer required. CYA Steve
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-14 08:47 +1000 |
| Message-ID | <4dcdb50e$0$47013$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1111 |
Thanks Steve, tried it - but no difference :( "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> wrote in message news:QEZyp.4093$aH5.2847@viwinnwfe02.internal.bigpond.com... > Craig > >> InvalidateRect(SELF:handle(),NULL_PTR, TRUE) // to fix repainting problem >> caused by VO2.6 if button used on tabpage > > Maybe the repaint bug has been fixed in VO2.8 and the above is no longer > required. > > CYA > Steve >
[toc] | [prev] | [next] | [standalone]
| From | "Bernhard Mayer" <Idonotexisthere@nowhere.com> |
|---|---|
| Date | 2011-05-13 07:55 +0200 |
| Message-ID | <4dccc7db$0$18690$91cee783@newsreader03.highway.telekom.at> |
| In reply to | #1110 |
Hi Craig!
What about destroying the additional icons?
PROTECT _oIconEnabled AS icon // PDB
PROTECT _oIconDisabled AS icon // pdb
--> add in your IconPushbutton:Destroy()
IF SELF:_oIconEnabled != NULL_OBJECT
SELF:_oIconEnabled:Destroy()
SELF:_oIconEnabled := NULL_OBJECT
ENDIF
IF SELF:_oIconDisabled != NULL_OBJECT
SELF:_oIconDisabled:Destroy()
SELF:_oIconDisabled := NULL_OBJECT
ENDIF
IF SELF:hImage != NULL_PTR
DestroyIcon(SELF:hImage)
SELF:hImage := NULL_PTR
ENDIF
And I would destroy the existing bitmap before adding a new one.
METHOD UseBitmap(oBmp AS Bitmap, hBitmap AS PTR) AS LOGIC PASCAL CLASS
IconPushbutton
IF hBitmap == NULL_PTR
SELF:lUseImage := FALSE
SELF:hImage := NULL_PTR
SELF:AxitXP()
ELSE
IF SELF:oBitmap != NULL_OBJECT
SELF:oBitmap:Destroy()
SELF:oBitmap := NULL_OBJECT
ENDIF
SELF:lUseImage := TRUE
SELF:dwImgType := IMAGE_BITMAP
SELF:oBitmap := oBmp
SELF:hImage := hBitmap
SELF:InitXP()
ENDIF
RETURN SELF:lUseImage
HTH,
Bernhard
"Craig Dawson" <craig@control.nospam.net.au> schrieb im Newsbeitrag
news:4dcc4a3f$0$47020$c30e37c6@pit-reader.telstra.net...
> Thanks Bernhard,
>
> Here is the code to the IconPushButton class I currently have.
> Can anyone see anything obvious in it that would cause the GDIs to keep
> increasing? It's driving me crazy.
> Regards, Craig.
>
> METHOD Enable() CLASS IconPushbutton
>
> // added by PDB 24/2/2003 to be able to show a "disabled" icon
>
> IF SELF:_lDisabled==TRUE // currently disabled
>
> SELF:_lDisabled:=FALSE
>
> ENDIF
>
> IF SELF:_oIconEnabled <> NULL_OBJECT
>
> SELF:UseIcon:=SELF:_oIconEnabled:Handle()
>
> ENDIF
>
> InvalidateRect(SELF:handle(),NULL_PTR, TRUE) // to fix repainting problem
> caused by VO2.6 if button used on tabpage
>
> ?
>
> SUPER:Enable()
>
> METHOD Disable() CLASS IconPushbutton
>
> // added by PDB 24/2/2003 to be able to show a "disabled" icon
>
> IF SELF:_lDisabled==FALSE
>
> SELF:_lDisabled:=TRUE
>
> ENDIF
>
> IF SELF:_oIconDisabled <> NULL_OBJECT
>
> SELF:UseIcon:= SELF:_oIconDisabled:Handle()
>
> ELSE
>
> // don't change icon but continue to use the "Upicon"
>
> ENDIF
>
> InvalidateRect(SELF:handle(),NULL_PTR, TRUE) // to fix repainting problem
> caused by VO2.6 if button used on tabpage
>
> ?
>
> ?
>
> SUPER:Disable()
>
> CLASS IconPushbutton INHERIT PUSHBUTTON
>
> /*
>
> Class from Harald Kogler: kog@kns.at feb 2003
>
> I played with the Visual Themes some time ago... this works fine for me
>
> This is a Class, which can Display an Icon or a Bitmap next to the
>
> Button-Text or a Button-Backgroundcolor.
>
> Should work on any Kind of Theme you've set...
>
> */
>
> ?
>
> PROTECT lIsTabWindow AS LOGIC
>
> PROTECT lHilight AS LOGIC
>
> PROTECT lUseImage AS LOGIC
>
> PROTECT lUseColor AS LOGIC
>
> PROTECT dwImgType AS DWORD
>
> PROTECT hImage AS PTR
>
> PROTECT _lFocus AS LOGIC
>
> PROTECT _lPressed AS LOGIC
>
> PROTECT _lDisabled AS LOGIC
>
> PROTECT oBackGround AS Brush
>
> PROTECT oBitmap AS Bitmap
>
> PROTECT pXPTheme AS PTR
>
> PROTECT pXPOpenThemeFunc AS PTR
>
> PROTECT pXPCloseThemeFunc AS PTR
>
> PROTECT pXPDrawFrameFunc AS PTR
>
> PROTECT pXPDrawEdgeFunc AS PTR
>
> PROTECT lXP AS LOGIC
>
> ?
>
> PROTECT _oIconEnabled AS icon // PDB
>
> PROTECT _oIconDisabled AS icon // pdb
>
> DECLARE METHOD UseBitmap
>
> DECLARE ASSIGN UseIcon
>
> DECLARE ASSIGN UseColor
>
> ?
>
> METHOD AxitXP() CLASS IconPushbutton
>
> IF SELF:lXP
>
> PCALL(SELF:pXPCloseThemeFunc, SELF:pXPTheme)
>
> ENDIF
>
> ?
>
> METHOD Expose(oEvent) CLASS IconPushbutton
>
> ?
>
> LOCAL hDC, hHandle AS PTR
>
> LOCAL sRect IS _winRECT
>
> LOCAL sPs IS _winPAINTSTRUCT
>
> LOCAL hPenBlack, hFont, hBrushBack, hBackGround AS PTR
>
> LOCAL dwBtnStyle AS DWORD
>
> LOCAL lKillFont AS LOGIC
>
> LOCAL hDCSrc AS PTR
>
> LOCAL oSize AS Dimension
>
> LOCAL nOffset AS INT
>
> LOCAL nIconheight AS DWORD // PDB, so we can resize the icon according to
> the height of the button
>
> LOCAL nREctWidth AS DWORD
>
> LOCAL lMultiline AS LOGIC
>
> ?
>
> LOCAL dwXPBtnStyle AS DWORD
>
> hHandle := SELF:handle()
>
> hDC := BeginPaint(hHandle, @sPs)
>
> SetBkMode(hdc, TRANSPARENT)
>
> hPenBlack := CreatePen(PS_SOLID, 0, GetSysColor(COLOR_BTNTEXT))
>
> hBrushBack := CreateSolidBrush(GetSysColor(COLOR_3DFACE))
>
> IF SELF:lUseColor
>
> hBackGround := SELF:oBackGround:handle()
>
> SelectObject (hDC, hBackGround)
>
> ENDIF
>
> ?
>
> ?
>
> sRect.top := 0
>
> sRect.left := 0
>
> sRect.bottom := SELF:size:height - 1
>
> sRect.right := SELF:size:width - 1
>
> dwBtnStyle := DFCS_BUTTONPUSH
>
> dwXPBtnStyle := 1
>
> IF (!SELF:_lPressed .AND. SELF:_lFocus) .OR. SELF:_lPressed
>
> IF !SELF:lXP
>
> SelectObject(hDC, hPenBlack)
>
> MoveToEx(hDC, sRect.left, sRect.top, NULL_PTR)
>
> LineTo(hDC, sRect.right, sRect.top)
>
> LineTo(hDC, sRect.right, sRect.bottom)
>
> LineTo(hDC, sRect.left, sRect.bottom)
>
> LineTo(hDC, sRect.left, sRect.top)
>
> ENDIF
>
> sRect.left += 1
>
> sRect.top += 1
>
> dwXPBtnStyle := 5
>
> IF SELF:_lPressed
>
> dwBtnStyle := DFCS_BUTTONPUSH+DFCS_PUSHED
>
> dwXPBtnStyle := 3
>
> ENDIF
>
> ELSEIF !SELF:_lPressed .AND. !SELF:_lFocus
>
> sRect.bottom += 1
>
> sRect.right += 1
>
> ENDIF
>
> IF SELF:lHilight .AND. !SELF:_lPressed
>
> dwXPBtnStyle := 2
>
> ENDIF
>
> IF SELF:_lDisabled
>
> dwXPBtnStyle := 4
>
> ENDIF
>
> IF SELF:lXP
>
> PCALL(SELF:pXPDrawFrameFunc, SELF:pXPTheme, hDC, 1, dwXPBtnStyle,
> @sRect,NULL_PTR)
>
> ELSE
>
> DrawFrameControl(hDC, @sRect, DFC_BUTTON, dwBtnStyle)
>
> ENDIF
>
> ?
>
> IF SELF:lUseColor
>
> SelectObject(hDC, GetStockObject(NULL_PEN))
>
> DO CASE
>
> CASE SELF:_lPressed
>
> Rectangle(hDC, sRect.left+3, sRect.top+3, sRect.right-1, sRect.Bottom-1)
>
> CASE SELF:lXP
>
> Rectangle(hDC, sRect.left+3, sRect.top+3, sRect.right-2, sRect.Bottom-2)
>
> OTHERWISE
>
> Rectangle(hDC, sRect.left+2, sRect.top+2, sRect.right-2, sRect.Bottom-2)
>
> ENDCASE
>
> SelectObject(hDC, hPenBlack)
>
> ENDIF
>
> ?
>
> ?
>
> // Draw the icon:
>
> IF SELF:lUseImage
>
> IF SELF:dwImgType == IMAGE_ICON
>
> nIconHeight := SELF:size:Height-4
>
> ** nOffset := 4 // PDB
>
> nOffset := 2 // make icon border only 2 pixels
>
> IF SELF:_lPressed
>
> nOffset += 1
>
> ENDIF
>
> ** DrawIconEx(hDC, nOffset, nOffset, SELF:hImage, 16, 16, 0, NULL_PTR,
> DI_NORMAL) //PDB
>
> DrawIconEx(hDC, nOffset, nOffset, SELF:hImage, nIconHeight, nIconHeight,
> 0, NULL_PTR, DI_NORMAL) //PDB for support 32x32 icon
>
> ELSEIF SELF:dwImgType == IMAGE_BITMAP
>
> nOffset := 2
>
> IF SELF:_lPressed
>
> nOffset += 1
>
> ENDIF
>
> oSize := SELF:oBitmap:size
>
> IF (SELF:Size:width - 4) < oSize:width
>
> oSize:width := SELF:Size:width - 4
>
> ENDIF
>
> IF (SELF:Size:Height - 4) < oSize:height
>
> oSize:Height := SELF:Size:Height - 4
>
> ENDIF
>
> hDCSrc := CreateCompatibleDC(hDC)
>
> SelectObject(hDCSrc, SELF:oBitmap:handle())
>
> BitBlt(hDC, nOffset, nOffset, oSize:width, oSize:height, hDCSrc, 0, 0,
> SRCCOPY)
>
> DeleteDC(hDCSrc)
>
> ENDIF
>
> ENDIF
>
> ?
>
> // Draw the caption:
>
> IF SLen(SELF:Caption) > 0
>
> IF SELF:oFont == NULL_OBJECT
>
> lKillFont := TRUE
>
> hFont := GetStockObject(DEFAULT_GUI_FONT)
>
> IF hFont == NULL_PTR
>
> hFont := GetStockObject(SYSTEM_FONT)
>
> ENDIF
>
> ELSE
>
> hFont := SELF:oFont:handle()
>
> ENDIF
>
> SelectObject(hDC, hFont)
>
> // define rectangle for the caption
>
> sRect.top +=2
>
> sRect.bottom -= 3
>
> ** sRect.left += 20
>
> //PDB: place the caption text as much aside as the icon is big:
>
> IF nIconHeight <> 0
>
> sRect.left := nIconheight
>
> ELSE
>
> sRect.left += 2 // no icon
>
> ENDIF
>
> sRect.right -= 4
>
> ?
>
> // PDB: first check if the width of the button can accomadate the caption.
> If not, switch to multiline button
>
> nREctWidth := sRect.right - sRect.left // available space
>
> // how long is the text
>
> IF getDisplayTextWidth(SELF:Caption,hFont) > nREctWidth
>
> lMultiline := TRUE
>
> ENDI
>
> ?
>
> ?
>
> IF !SELF:_lDisabled
>
> SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT))
>
> IF SELF:_lPressed
>
> sRect.top += 1
>
> sRect.left += 1
>
> sRect.bottom += 1
>
> sRect.right += 1
>
> ENDIF
>
> IF !lMultiline
>
> DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
> @sRect,DT_SINGLELINE+DT_CENTER+DT_VCENTER)
>
> ELSE
>
> DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
> @sRect,DT_CENTER+DT_WORDBREAK)
>
> ENDIF
>
> ELSE
>
> sRect.top += 1
>
> sRect.left += 1
>
> sRect.bottom += 1
>
> sRect.right += 1
>
> SetTextColor(hDC, GetSysColor(COLOR_3DHILIGHT))
>
> IF !lMultiline
>
> DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
> @sRect,DT_SINGLELINE+DT_CENTER+DT_VCENTER)
>
> ELSE
>
> DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
> @sRect,DT_CENTER+DT_WORDBREAK)
>
> ENDIF
>
> // draw shadow
>
> sRect.top -= 1
>
> sRect.left -= 1
>
> sRect.bottom -= 1
>
> sRect.right -= 1
>
> SetTextColor(hDC, GetSysColor(COLOR_3DSHADOW))
>
> IF !lMultiline
>
> DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
> @sRect,DT_SINGLELINE+DT_CENTER+DT_VCENTER)
>
> ELSE
>
> DrawText(hDC, SELF:Caption, SLen(SELF:Caption),
> @sRect,DT_CENTER+DT_WORDBREAK)
>
> ENDIF
>
> ENDIF
>
> IF SELF:_lFocus
>
> SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT))
>
> DrawFocusRect(hDC, @sRect)
>
> ENDIF
>
> ENDIF
>
> EndPaint(hHandle, @sPs)
>
> IF lKillFont
>
> DeleteObject(hFont)
>
> ENDIF
>
> DeleteObject(hPenBlack)
>
> DeleteObject(hBrushBack)
>
> ReleaseDC(hHandle, hDC)
>
> DeleteDC(hDC)
>
> ?
>
> ?
>
> ?
>
> METHOD MouseButtonUp(oEvent) CLASS IconPushbutton
>
> IF SELF:lUseImage
>
> IF oEvent:IsLeftButton
>
> _lPressed := FALSE
>
> SELF:owner:RepaintBoundingBox(BoundingBox{SELF:origin, SELF:size})
>
> ENDIF
>
> ENDIF
>
> SUPER:MouseButtonUp(oEvent)
>
> ASSIGN IconDisabled(oIco) CLASS IconPushbutton
>
> // Set the icon for disabled state
>
> // you can set this assign in the INIT() of an inherited icon class (bv
> CopyPushbutton)
>
> SELF:_oIconDisabled:=oIco
>
> RETURN _oIconDisabled
>
> METHOD InitXP() CLASS IconPushbutton
>
> ** A few fixes made by Paul De Bie 25/2/2003 because of 5333 crash
>
> LOCAL pszControl AS PTR
>
> LOCAL pszUCString AS PTR
>
> LOCAL iRet AS INT
>
> LOCAL iUCStrLen AS INT
>
> IF !SELF:lXP
>
> SELF:pXPOpenThemeFunc :=
> GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),String2Psz("OpenThemeData"))
>
> SELF:pXPCloseThemeFunc :=
> GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),
> String2Psz("CloseThemeData"))
>
> SELF:pXPDrawFrameFunc :=
> GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),
> String2Psz("DrawThemeBackground"))
>
> SELF:pXPDrawEdgeFunc :=
> GetProcAddress(GetModuleHandle(String2Psz("UXTHEME")),String2Psz("DrawThemeEdge"))
>
> IF SELF:pXPOpenThemeFunc != NULL_PTR .AND. SELF:pXPCloseThemeFunc !=
> NULL_PTR .AND. SELF:pXPDrawFrameFunc != NULL_PTR .AND.
> SELF:pXPDrawEdgeFunc != NULL_PTR
>
> SELF:lXP := TRUE
>
> ENDIF
>
> ENDIF
>
> // IF SELF:lXP
>
> // pszControl := String2Psz("BUTTON")
>
> // nStrLen := MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszControl, -1,
> NULL_PTR, 0)
>
> //
>
> // IF nStrLen != 0
>
> // pszUCString := MemAlloc(nStrLen)
>
> // *** EXE CRASHES ON NEXT STATEMENT!!!
>
> // iRet := MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
> pszControl, -1,pszUCString, nStrLen)
>
> // //
>
> // SELF:pXPTheme := PCALL(pXPOpenThemeFunc, NULL, PSZUCString)
>
> // IF SELF:pXPTheme == NULL_PTR
>
> // SELF:lXP := FALSE
>
> // ENDIF
>
> // MemFree(pszUCString)
>
> // ENDIF
>
> // ENDIF
>
> // PDB:
>
> IF SELF:lXP
>
> // allocate a buffer large enough for equivalent Unicode string
>
> // at most twice as big; +1 for trailing terminator
>
> iUCStrLen := 2 * (SLen("BUTTON") +1)
>
> pszUCString := MemAlloc(iUCStrLen)
>
> pszControl := String2Psz("BUTTON")
>
> IF pszUCString != NULL_PTR
>
> // write the number of "wide" characters to pszUCString
>
> iRet := MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
> pszControl, -1,pszUCString, iUCStrLen)
>
> IF iRet !=0 // succes? open XP Theme
>
> SELF:pXPTheme := PCALL(pXPOpenThemeFunc, NULL, pszUCString)
>
> IF SELF:pXPTheme == NULL_PTR
>
> SELF:lXP := FALSE
>
> ENDIF
>
> ELSE
>
> SELF:lXP := FALSE
>
> ENDIF
>
> MemFree(pszUCString)
>
> ENDIF
>
> ENDIF
>
> ?
>
> METHOD UseBitmap(oBmp AS Bitmap, hBitmap AS PTR) AS LOGIC PASCAL CLASS
> IconPushbutton
>
> IF hBitmap == NULL_PTR
>
> SELF:lUseImage := FALSE
>
> SELF:hImage := NULL_PTR
>
> SELF:AxitXP()
>
> ELSE
>
> SELF:lUseImage := TRUE
>
> SELF:dwImgType := IMAGE_BITMAP
>
> * SELF:oBitmap := BitMap{ResourceID{NULL_STRING, _GetInst()}}
>
> SELF:oBitmap := oBmp
>
> * SELF:oBitmap:hBitMapPtr := hBitmap
>
> SELF:hImage := hBitmap
>
> SELF:InitXP()
>
> ENDIF
>
> RETURN SELF:lUseImage
>
> ASSIGN UseColor(oBrush AS Brush) AS LOGIC PASCAL CLASS IconPushbutton
>
> // attention: has NO EFFECT when there is an icon assigned to the button!
>
> IF oBrush == NULL_OBJECT
>
> SELF:lUseColor := FALSE
>
> IF SELF:oBackGround != NULL_OBJECT
>
> DeleteObject(SELF:oBackground:handle())
>
> SELF:oBackGround:destroy()
>
> SELF:oBackGround := NULL_OBJECT
>
> ENDIF
>
> SELF:AxitXP()
>
> ELSE
>
> SELF:lUseColor := TRUE
>
> IF SELF:oBackground != oBrush .AND. SELF:oBackground != NULL_OBJECT
>
> DeleteObject(SELF:oBackground:handle())
>
> SELF:oBackground:destroy()
>
> ENDIF
>
> SELF:oBackGround := oBrush
>
> SELF:InitXP()
>
> ENDIF
>
> InvalidateRect(SELF:handle(), NULL_PTR, TRUE)
>
> RETURN SELF:lUseColor
>
> ASSIGN UseIcon(hIcon AS PTR) AS LOGIC PASCAL CLASS IconPushbutton
>
> IF hIcon == NULL_PTR
>
> SELF:lUseImage := FALSE
>
> SELF:hImage := NULL_PTR
>
> SELF:AxitXP()
>
> ELSE
>
> SELF:lUseImage := TRUE
>
> SELF:lXP := FALSE // to force the InitXp to check if XP Themes are active
>
> SELF:dwImgType := IMAGE_ICON
>
> SELF:hImage := hIcon
>
> SELF:InitXP()
>
> ENDIF
>
> RETURN SELF:lUseImage
>
> ?
>
> ?
>
> ASSIGN IconEnabled(oIco) CLASS IconPushbutton
>
> // Set the icon for enabled state
>
> // you can set this assign in the INIT() of an inherited icon class (bv
> CopyPushbutton)
>
> SELF:_oIconEnabled:=oIco
>
> RETURN _oIconEnabled
>
> METHOD FocusChange(oEvent) CLASS IconPushbutton
>
> // Callback, called if object recieves or loose focus
>
> // PDB: this makes that the button, when you tab to them (with tab key),
> have a "focused" look (blue border)
>
> SUPER:focusChange (oEvent)
>
> IF oEvent:gotFocus
>
> // give the button a look such as the "default" one
>
> PostMessage (SELF:handle(), BM_SETSTYLE, BS_DEFPUSHBUTTON, 1)
>
> SELF:_lFocus := TRUE
>
> ELSE
>
> PostMessage (SELF:handle(), BM_SETSTYLE, BS_PUSHBUTTON, 1)
>
> SELF:_lFocus := FALSE
>
> ENDIF
>
> IF SELF:lUseImage // if image, redraw the button
>
> InvalidateRect(SELF:handle(), NULL_PTR, TRUE)
>
> ENDIF
>
> RETURN
>
> METHOD Destroy() CLASS IconPushbutton
>
> IF SELF:oBitmap != NULL_OBJECT
>
> DeleteObject(SELF:oBitmap:handle())
>
> SELF:oBitmap:destroy()
>
> SELF:oBitmap := NULL_OBJECT
>
> SELF:hImage := NULL_PTR
>
> ENDIF
>
> IF SELF:oBackGround != NULL_OBJECT
>
> DeleteObject(SELF:oBackGround:handle())
>
> SELF:oBackGround:Destroy()
>
> SELF:oBackGround := NULL_OBJECT
>
> ENDIF
>
> SELF:AxitXP()
>
> SUPER:Destroy()
>
> ?
>
> METHOD SetStyle(kStil, lAktivieren) CLASS IconPushbutton
>
> IF IsNil(lAktivieren)
>
> lAktivieren := TRUE
>
> ENDIF
>
> IF kStil == WS_DISABLED
>
> SELF:_lDisabled := lAktivieren
>
> ENDIF
>
> IF kStil == BS_DEFPUSHBUTTON .AND. lAktivieren == FALSE
>
> PostMessage (SELF:handle(), BM_SETSTYLE, BS_PUSHBUTTON, 1)
>
> ELSE
>
> SUPER:SetStyle(kStil, lAktivieren)
>
> ENDIF
>
> ?
>
> METHOD Init(oOwner, nID, oPoint, oDim, cText, kStyle) CLASS IconPushbutton
>
> SUPER:init(oOwner, nID, oPoint, oDim, cText, kStyle)
>
> // Stelle fest, ob es sich beim Owner um ein Tabfenster
>
> // der Klasse Dialogwindow handelt
>
> IF IsInstanceOf(oOwner, #DIALOGWINDOW)
>
> * SELF:lIsTabWindow := !(_And (GetWindowLong (oOwner:handle (),
> GWL_Style), WS_POPUP) != 0 )
>
> ENDIF
>
> METHOD MouseButtonDown(oEvent) CLASS IconPushbutton
>
> IF SELF:lUseImage
>
> IF oEvent:IsLeftButton
>
> _lPressed := TRUE
>
> SELF:owner:RepaintBoundingBox(BoundingBox{SELF:origin, SELF:size})
>
> ENDIF
>
> ENDIF
>
> SUPER:MouseButtonDown(oEvent)
>
> 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
>
> ?
>
> ENDIF
>
> RETURN nWidth
>
> ?
>
> TEXTBLOCK readme
>
> /*
>
> Class from Harald Kogler: kog@kns.at feb 2003
>
> I played with the Visual Themes some time ago... this works fine for me
>
> This is a Class, which can Display an Icon or a Bitmap next to the
>
> Button-Text or a Button-Backgroundcolor.
>
> Should work on any Kind of Theme you've set...
>
> REMARKS FROM PAUL DE BIE:
>
> - To set a background color:
>
> Assign UseColor --> Brush e.g. SELF:occPbtest:Usecolor :=
> Brush{Color{COLORYELLOW},HATCHSOLID}
>
> - To set an icon:
>
> Assign IconEnabled --> icon object e.g. SELF:oCCpbTest:IconEnabled :=
> {PrinterUp}
>
> or e.g. SELF:oCCpbTest:IconEnabled := { ResourceId{"PrinterUp",
> _GetInst()} }
>
> Assign IconDisabled --> icon object (if not set, then uses the same Icon
> as IconEnabled)
>
> ?
>
> Changed by PDB 02/2003:
>
> ======================
>
> - icons are now always 32*32 instead of 16*16 (but if your button is
> smaller than 32 pixels, the icons will be automatically reduced in size)
>
> - added possibility to enable/disable the button.
>
> - can now be used just as the former Iconpushbutton class; by making icon
> resources first for enabled/disabled states
>
> - Use now the assign IconEnabled or IconDisabled (ICO object type) to set
> the Up/Enabled icons (normally they must be set
>
> in the INIT of the subclassed pushbutton, but you can change them
> afterwards too.)
>
> -> a SELF:Enable() must be done once to set the icon for the first time;
> you can also do this from within the Init() of
>
> your subclassed buttons
>
> - Fixed a 5333 crash in INITXP() method
>
> - Tested to see if XP Theme can be changed while Appli is running: OK this
> gives no problems, it works!
>
> Changed PDB 23/6/2003:
>
> =====================
>
> - In ExposeEX and ExposeCol; I now check to see if the caption (text) fits
> on the pushbutton; if not the pushbutton style is
>
> changed to multiline instead of single line
>
> Changed PDB 31/10/2005:
>
> ======================
>
> - Merged the two Expose methods (ExposeEX and ExposeCol) which makes it
> now possible to use both an Icon AND a background color
>
> ?
>
> REMARK: don't use the Bitmap anymore - didn't test it to see it supports
> my changes!
>
> ?
>
> HOW TO USE THIS CLASS
>
> =====================
>
> ?
>
> - In order to compile, you will have to put all of the icons in a folder
> called:
>
> C:\Cavo_Bitmaps_and_Icons\General_use
>
> If you want them in another folder, then search/replace the foldername in
> all resource entities. Attention: do NOT use
>
> foldernames that contain spaces or it won't compile.
>
> ?
>
> ?
>
> - If you don't need icons, but just a colored background:
>
> inherit your pushbutton from Iconpushbutton class
>
> Assign the color SELF:occPbtest:Usecolor :=
> Brush{Color{COLORYELLOW},HATCHSOLID}
>
> ?
>
> - If you want to show Icons with two states (enabled/disabled):
>
> ?
>
> You need two icons for each pushbutton, one normal and one "greyed out".
> You can easily do this
>
> with an Icon editor. Or with a graphics program: open the colored icon,
> convert it to greyscale, then save with another name.
>
> I have for each type of pushbutton a different class; I have them all in a
> library that I link into my application when needed.
>
> So all I have to do when I need, say, a pushbutton with a printer, is to
> put a standard PB (via the WED) on my form
>
> and have it inherit from the appropriate class, e.g. printerPushButton.
>
> Below an example for one such pushbutton class.
>
> In this example I use two icons: PrinterDisabled.ico and PrinterUp.ico in
> a folder c:\temp\
>
> ?
>
> ?
>
> CLASS PrinterPushButton INHERIT IconPushbutton
>
> METHOD INIT(oOwner,nId,oPoint,oDimension,cText) CLASS PrinterPushButton
>
> SUPER:INIT(oOwner,nId,oPoint,oDimension,cText)
>
> SELF:IconEnabled := PrinterUP{}
>
> SELF:iconDisabled := PrinterDisabled{}
>
> SELF:Enable()
>
> CLASS PRINTERDISABLED INHERIT Icon
>
> RESOURCE PRINTERDISABLED Icon c:\temp\PrinterDisabled.ico
>
> METHOD Init() CLASS PRINTERDISABLED
>
> SUPER:init(ResourceID{"PRINTERDISABLED", _GetInst()})
>
> CLASS PRINTERUP INHERIT Icon
>
> RESOURCE PRINTERUP Icon c:\temp\PrinterUp.ico
>
> METHOD Init() CLASS PRINTERUP
>
> SUPER:init(ResourceID{"PRINTERUP", _GetInst()})
>
> ?
>
> ?
>
> NB: you'll have some more work setting up all the classes for each
> pushbutton;
>
> but afterwards in your application it's a piece of cake and no code needed
> at all, just "inherit from" and voilà.
>
> ?
>
> ?
>
> ?
>
> ?
>
> ?
>
> */
>
> METHOD Dispatch(oEvent) CLASS IconPushbutton
>
> IF oEvent:Message == BM_SETSTATE
>
> // Button Status geändert ?
>
> IF ! SELF:_lPressed .AND. oEvent:wParam == 1
>
> SELF:_lPressed := TRUE
>
> SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
>
> ELSEIF SELF:_lPressed .AND. oEvent:wParam == 0
>
> SELF:_lPressed := FALSE
>
> SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
>
> ENDIF
>
> ENDIF
>
> ** IF oEvent:uMsg == WM_PAINT
>
> ** SELF:Expose(oEvent)
>
> ** SELF:EventReturnValue := 0L
>
> ** RETURN 0L
>
> ** ENDIF
>
> IF oEvent:message == WM_MOUSEMOVE .AND. !SELF:lHilight
>
> SELF:lHilight := TRUE
>
> ENDIF
>
> IF oEvent:message == 0x2A3 .AND. SELF:lHilight//WM_MOUSELEAVE
>
> SELF:lHilight := FALSE
>
> ENDIF
>
> IF oEvent:message == 0x128 //WM_UPDATEUISTATE
>
> SELF:Expose(oEvent)
>
> SELF:EventReturnValue := 1L
>
> RETURN 1L
>
> ENDIF
>
> IF oEvent:message == 0x031A //WM_THEMECHANGED
>
> SELF:AxitXP()
>
> SELF:lXP := FALSE
>
> SELF:InitXP()
>
> ENDIF
>
> IF oEvent:message == WM_GETDLGCODE
>
> IF oEvent:wParam = VK_RETURN
>
> // Drückt zwar den Button, ruft aber nicht die Methode auf
>
> *PostMessage (SELF:handle(), WM_KEYDOWN, VK_SPACE, 0)
>
> // Rufe die Methode zum Button auf (Falls diese existiert)
>
> IF SELF:lIsTabWindow // Nur bei Tabwindows
>
> IF IsMethod (SELF:owner, SELF:NameSym)
>
> Send (SELF:owner, SELF:NameSym)
>
> ENDIF
>
> ** SELF:EventReturnValue := 1L
>
> ** RETURN 1L
>
> ENDIF
>
> ENDIF
>
> ENDIF
>
> RETURN SUPER:Dispatch(oEvent)
>
> CLASS cdPosItemButton INHERIT ICONPUSHBUTTONEXPORT aItemInfo AS ARRAY
>
> EXPORT cItemNo AS STRING
>
> METHOD Dispatch(oEvent) CLASS cdPosItemButton
>
> // CASE InList(oE:Message, WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_LBUTTONUP)
>
> IF oEvent:message == WM_RBUTTONDOWN //MOVE .AND. !SELF:lHilight
>
>
> IF SELF:NameSym != #pbPosButton .AND. SELF:NameSym != #pbPosButtonNew //
> Just so we don't process again if button is clicked in the setup button
> window
>
> IF IsMethod (SELF:owner:owner, #cdSetupButton)
>
> SELF:owner:owner:cdSetupButton(SELF)
>
> ENDIF
>
> ENDIF
>
> ENDIF
>
> RETURN SUPER:Dispatch(oEvent)
>
> ?
>
> ?
>
>
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-14 08:52 +1000 |
| Message-ID | <4dcdb621$0$47014$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1112 |
Thanks Bernhard, but no difference. The GDI objects increase as I move the mouse over the buttons (but not all) - interesting to note that GDI's increase ONLY on those buttons that have a caption on them. Buttons without captions are fine. Regards, Craig. "Bernhard Mayer" <Idonotexisthere@nowhere.com> wrote in message news:4dccc7db$0$18690$91cee783@newsreader03.highway.telekom.at... > Hi Craig! > > What about destroying the additional icons? > > PROTECT _oIconEnabled AS icon // PDB > PROTECT _oIconDisabled AS icon // pdb > > --> add in your IconPushbutton:Destroy() > > IF SELF:_oIconEnabled != NULL_OBJECT > SELF:_oIconEnabled:Destroy() > SELF:_oIconEnabled := NULL_OBJECT > ENDIF > > IF SELF:_oIconDisabled != NULL_OBJECT > SELF:_oIconDisabled:Destroy() > SELF:_oIconDisabled := NULL_OBJECT > ENDIF > > IF SELF:hImage != NULL_PTR > DestroyIcon(SELF:hImage) > SELF:hImage := NULL_PTR > ENDIF > > And I would destroy the existing bitmap before adding a new one. > > METHOD UseBitmap(oBmp AS Bitmap, hBitmap AS PTR) AS LOGIC PASCAL CLASS > IconPushbutton > > IF hBitmap == NULL_PTR > SELF:lUseImage := FALSE > SELF:hImage := NULL_PTR > SELF:AxitXP() > ELSE > IF SELF:oBitmap != NULL_OBJECT > SELF:oBitmap:Destroy() > SELF:oBitmap := NULL_OBJECT > ENDIF > SELF:lUseImage := TRUE > SELF:dwImgType := IMAGE_BITMAP > SELF:oBitmap := oBmp > SELF:hImage := hBitmap > SELF:InitXP() > ENDIF > > RETURN SELF:lUseImage > > > HTH, > Bernhard >
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-14 17:16 +1000 |
| Message-ID | <4dce2c3c$0$47014$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1115 |
OK - narrowed it to the Expose method... Lets see what can be discovered...
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-15 02:30 +1000 |
| Subject | Re: Highlighting Buttons on tab page freezes program - Solved! |
| Message-ID | <4dceae1f$0$47016$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1116 |
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
[toc] | [prev] | [next] | [standalone]
| From | "Gerhard Bunzel" <g.bunzel@domonet.de> |
|---|---|
| Date | 2011-05-16 00:08 +0200 |
| Subject | Re: Highlighting Buttons on tab page freezes program - Solved! |
| Message-ID | <iqpis8$qgv$1@news.m-online.net> |
| In reply to | #1117 |
Craig,
...
dwSize := DWORD(_CAST, MakeLong(WORD(_CAST, winSize.cx),
WORD(_CAST,winSize.cy)))
nWidth := LoWord( dwSize )
....
...why call a MAKELONG(...) to use the LoWord(..)? You can simply use
winSize.cx.
Have a look at this function, to get the Textsize:
FUNCTION GetTextExtentWidth ( hWnd AS PTR, sText AS STRING ) AS LONG PASCAL
LOCAL oSize AS _winSIZE
LOCAL iWidth AS LONG
oSize := MemAlloc( _SizeOf( _winSIZE ) )
GetTextExtentPoint32( GetDC( hWnd), String2Psz(sText), INT(SLen(sText)),
oSize )
iWidth := oSize.cx
MemFree( oSize )
RETURN iWidth
HTH
Gerhard
"Craig Dawson" <craig@control.nospam.net.au> schrieb im Newsbeitrag
news:4dceae1f$0$47016$c30e37c6@pit-reader.telstra.net...
> 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
>
>
>
[toc] | [prev] | [next] | [standalone]
| From | "Craig Dawson" <craig@control.nospam.net.au> |
|---|---|
| Date | 2011-05-17 21:55 +1000 |
| Subject | Re: Highlighting Buttons on tab page freezes program - Solved! |
| Message-ID | <4dd26220$0$32865$c30e37c6@pit-reader.telstra.net> |
| In reply to | #1118 |
Thanks Gerhard,
Yes understood, nice bit of code! Will check things out here and very much
appreciated.
Regards, Craig.
"Gerhard Bunzel" <g.bunzel@domonet.de> wrote in message
news:iqpis8$qgv$1@news.m-online.net...
> Craig,
>
> ...
> dwSize := DWORD(_CAST, MakeLong(WORD(_CAST, winSize.cx),
> WORD(_CAST,winSize.cy)))
> nWidth := LoWord( dwSize )
> ....
>
> ...why call a MAKELONG(...) to use the LoWord(..)? You can simply use
> winSize.cx.
>
> Have a look at this function, to get the Textsize:
>
> FUNCTION GetTextExtentWidth ( hWnd AS PTR, sText AS STRING ) AS LONG
> PASCAL
> LOCAL oSize AS _winSIZE
> LOCAL iWidth AS LONG
>
> oSize := MemAlloc( _SizeOf( _winSIZE ) )
> GetTextExtentPoint32( GetDC( hWnd), String2Psz(sText), INT(SLen(sText)),
> oSize )
> iWidth := oSize.cx
> MemFree( oSize )
>
> RETURN iWidth
>
>
> HTH
>
> Gerhard
>
>
>
> "Craig Dawson" <craig@control.nospam.net.au> schrieb im Newsbeitrag
> news:4dceae1f$0$47016$c30e37c6@pit-reader.telstra.net...
>> 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
>>
>>
>>
>
>
[toc] | [prev] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-05-17 07:19 -0500 |
| Subject | Re: Highlighting Buttons on tab page freezes program - Solved! |
| Message-ID | <iqtp4t$rdv$1@speranza.aioe.org> |
| In reply to | #1117 |
Craig,
I am glad that you got it worked out. I am back from DevShare. Here is the
code that I use for IconPushButton (works in 2.8 and Vulcan). It inherits
from pushbutton.
Regards,
Willie
CLASS IconPushButton INHERIT PushButton
// Author : Heiko Mueller
// Email : 113255.1100@compuserve.com
// Date : 18 June 1998
// --------------
/*
Updated 7Sep98 by Paul Piko paul@piko.com.au
- Changed Dispatch method to check for BM_SETSTATE message to determine
whether button should display pressed or not. This meant
MouseButtonDown/Up,
KeyDown/Up methods could be removed since they were just watching to
change
the _lPressed variable. Watching for BM_SETSTATE is also better because
we
regain the standard button behaviour that if you click and hold the
mouse
button down on the pushbutton, then move the mouse off the pushbutton
(while
keeping the mouse button pressed) the pushbutton should return to the
unpressed state.
- Changed DrawTheButton method. It will now use the font assigned to the
button (previously it ignored the font setting).
* Sparse docs for VO2Forum Library added by Richard Press 15 August 1998
*/
//l Pushbutton with icons
//p Pushbutton with icons for up, down & disabled states
//d To use this class, place a pushbutton on your your window, and
change the
//d Inherit From property to IconPushButton. Then, in your PostInit()
method, assign
//d the appropriate icons for the up, down and disabled states.
//g GUI
/*
Darstellung von PushButtons mit einem Icon
*/
PROTECT _oIconUp AS Icon
PROTECT _oIconDown AS Icon
PROTECT _oIconDisabled AS Icon
PROTECT _lPressed AS LOGIC
PROTECT _nLeft AS LONG
PROTECT _lFocus AS LOGIC
PROTECT _nButtonColor AS DWORD
PROTECT _lDisabled AS LOGIC
PROTECT _lFirstDraw AS LOGIC
_DLL FUNC DrawIconEx(hDC AS PTR, nLeft AS INT,nTop AS INT, hIcon AS PTR,
nxWidth AS INT, nyWidth AS INT, ;
nStepAniCursor AS DWORD, hbrFlickerFreeDraw AS PTR, dwFlags AS
DWORD ) AS LOGIC PASCAL:USER32.DrawIconEx#160
ASSIGN ButtonTextColor(nColor) CLASS IconPushButton
//l Assign text color
//a nColor - color number
//x o:ButtonTextColor := nColor --> nColor
RETURN (_nButtonColor:=nColor)
METHOD Disable() CLASS IconPushButton
IF _lDisabled==FALSE
_lDisabled:=TRUE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ENDIF
SUPER:Disable()
RETURN NIL
METHOD Dispatch(oEvent) CLASS IconPushButton
DO CASE
CASE oEvent:Message == BM_SETSTATE
// Has the button state changed, i.e. pressed or not
IF ! SELF:_lPressed .AND. oEvent:wParam == 1
SELF:_lPressed := TRUE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ELSEIF SELF:_lPressed .AND. oEvent:wParam == 0
SELF:_lPressed := FALSE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ENDIF
CASE oEvent:uMsg == WM_PAINT
SELF:Expose(oEvent)
RETURN 0L
ENDCASE
RETURN SUPER:Dispatch(oEvent)
METHOD Enable() CLASS IconPushButton
IF _lDisabled==TRUE
_lDisabled:=FALSE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ENDIF
SUPER:Enable()
RETURN NIL
METHOD Expose(oEvent) CLASS IconPushButton
SELF:DrawTheButton()
RETURN NIL
ASSIGN IconDisabled(oIco) CLASS IconPushButton
//l Set the icon for disabled state
//p Set the icon for disabled state
//x o:IconDisabled := oIco --> oIco
//a oIco - an icon object
//r The icon for disabled state
_oIconDisabled:=oIco
IF _lFirstDraw==FALSE .AND. _lDisabled==TRUE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ENDIF
RETURN _oIconDisabled
ASSIGN IconDown(oIco) CLASS IconPushButton
//l Set the icon for down state
//p Set the icon for down state.
//d Note: if there is no icon for the up state, it will also be set to
this icon.
//x o:IconDown := oIco --> oIco
//a oIco - an icon object
//r The icon for the down state
_oIconDown:=oIco
IF _oIconUp==NULL_OBJECT
_oIconUp:=oIco
ENDIF
IF _lFirstDraw==FALSE .AND. _lPressed==TRUE .AND. _lDisabled==FALSE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ENDIF
RETURN _oIconDown
ASSIGN IconUp(oIco) CLASS IconPushButton
//l Set the icon for up state
//p Set the icon for up state
//x o:IconUp := oIco --> oIco
//d Note: if there is on icon for the down state, it will also be set to
this icon.
//a oIco - an icon object
//r the icon for the up state
_oIconUp:=oIco
IF _oIconDown==NULL_OBJECT
_oIconDown:=oIco
ENDIF
IF _lFirstDraw==FALSE .AND. _lPressed==FALSE .AND. _lDisabled==FALSE
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
ENDIF
RETURN _oIconUp
METHOD Init(oOwner,nId,oPoint,oDimension,cText) CLASS IconPushButton
//l Constructor for this class
SUPER:Init(oOWner,nID,oPoint,oDimension,cText)
SELF:SetStyle(BS_OWNERDRAW)
SELF:SetStyle(BS_NOTIFY)
_lPressed:=FALSE
_nLeft:=4
_lFocus:=FALSE
_nButtonColor:=0
_lDisabled:=FALSE
_lFirstDraw:=TRUE
RETURN SELF
ASSIGN LeftIconBorder(nLeft) CLASS IconPushButton
//l Set left border for icon
//x o:LeftIconBorder := nLeft --> nLeft
//a nLeft - probably pixels
//r nLeft
RETURN (_nLeft:=nLeft)
STATIC FUNCTION MoveTo(hWnd AS PTR, x AS INT, y AS INT)
RETURN MoveToEx(hWnd,x,y,NULL_PTR)
METHOD DrawTheButton() CLASS IconPushButton
LOCAL hDC, handle AS PTR
LOCAL nIconHeight AS LONG
LOCAL Rect IS _WINRECT
LOCAL ps IS _WinPaintStruct
LOCAL hFont, hPenBlack AS PTR
LOCAL lKillFont AS LOGIC
_lFirstDraw:=FALSE
handle:=SELF:Handle()
hDC:=BeginPaint(handle,@ps)
SetBkMode(hDC, TRANSPARENT)
hPenBlack:=CreatePen(PS_SOLID,0,GetSysColor(COLOR_BTNTEXT))
// den Button zeichnen
rect.Top:=0
rect.Bottom:=SELF:Size:Height
rect.Left:=0
rect.Right:=SELF:Size:Width
IF _lPressed==FALSE
IF _lFocus
SelectObject(hDC,hPenBlack)
MoveTo(hDC,rect.Left,rect.Top)
LineTo(hDC,rect.Right,rect.Top)
LineTo(hDC,rect.Right,rect.Bottom)
LineTo(hDC,rect.Left,rect.Bottom)
LineTo(hDC,rect.Left,rect.Top)
rect.Left+=1
rect.Top+=1
DrawFrameControl(hDC,@rect,DFC_BUTTON,DFCS_BUTTONPUSH)
ELSE
rect.Bottom+=1
rect.Right+=1
DrawFrameControl(hDC,@rect,DFC_BUTTON,DFCS_BUTTONPUSH)
ENDIF
ELSE
SelectObject(hDC,hPenBlack)
MoveTo(hDC,rect.Left,rect.Top)
LineTo(hDC,rect.Right,rect.Top)
LineTo(hDC,rect.Right,rect.Bottom)
LineTo(hDC,rect.Left,rect.Bottom)
LineTo(hDC,rect.Left,rect.Top)
rect.Left+=1
rect.Top+=1
DrawFrameControl(hDC,@rect,DFC_BUTTON,DFCS_BUTTONPUSH+DFCS_PUSHED)
ENDIF
// das Icon zeichnen
IF _oIconUp#NULL_OBJECT
nIconHeight := LONG(SELF:Size:Height-4)
IF _lPressed==FALSE
IF _lDisabled .AND. _oIconDisabled#NULL_OBJECT
DrawIconEx(hDC,_nLeft,2,_oIconDisabled:handle(),nIconHeight,nIconHeight,0,NULL_PTR,DI_NORMAL)
ELSE
DrawIconEx(hDC,_nLeft,2,_oIconUp:handle(),nIconHeight,nIconHeight,0,NULL_PTR,DI_NORMAL)
ENDIF
ELSE
DrawIconEx(hDC,_nLeft,2,_oIconDown:handle(),nIconHeight,nIconHeight,0,NULL_PTR,DI_NORMAL)
ENDIF
ELSE
nIconHeight:=0
ENDIF
// den Text zeichnen
lKillFont := FALSE
// Has the button been assigned a font? If not, use default as per VO
SDK
// otherwise pick up the handle of the button font
IF SELF:oFont == NULL_OBJECT
lKillFont := TRUE
hFont := GetStockObject(DEFAULT_GUI_FONT)
IF hFont == NULL_PTR
hFont := GetStockObject(SYSTEM_FONT)
ENDIF
ELSE
hFont := SELF:oFont:handle()
ENDIF
SelectObject(hDC,hFont)
rect.top+=2
rect.bottom-=3
rect.right-=4
rect.left+=(nIconHeight+4)
IF _lDisabled==FALSE
IF _nButtonColor>0
SetTextColor(hDC,_nButtonColor)
ELSE
SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT))
ENDIF
IF _lPressed
rect.Top+=1
rect.Left+=1
ENDIF
DrawText(hDC, SELF:Caption , LONG(SLen(SELF:Caption)), @rect,
DT_CENTER+DT_SINGLELINE+DT_VCENTER)
ELSE
rect.Top+=1
rect.Left+=1
rect.Bottom+=1
rect.Right+=1
SetTextColor(hDC,GetSysColor(COLOR_3DHILIGHT))
DrawText(hDC, SELF:Caption , LONG(SLen(SELF:Caption)), @rect,
DT_CENTER+DT_SINGLELINE+DT_VCENTER)
rect.Top-=1
rect.Left-=1
rect.Bottom-=1
rect.Right-=1
SetTextColor(hDC,GetSysColor(COLOR_3DSHADOW))
DrawText(hDC, SELF:Caption , LONG(SLen(SELF:Caption)), @rect,
DT_CENTER+DT_SINGLELINE+DT_VCENTER)
ENDIF
IF _lFocus
SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT))
DrawFocusRect(hDC,@rect)
ENDIF
EndPaint(handle,@ps)
IF lKillFont
// Clean up object we obtained from Windows
DeleteObject(hFont)
ENDIF
DeleteObject(hPenBlack)
ReleaseDC(handle,hDC)
RETURN NIL
METHOD FocusChange(oEvent) CLASS IconPushButton
SUPER:FocusChange(oEvent)
IF oEvent:GotFocus
_lFocus:=TRUE
ELSE
_lFocus:=FALSE
ENDIF
SELF:Owner:RepaintBoundingBox(BoundingBox{SELF:Origin,SELF:Size})
RETURN NIL
[toc] | [prev] | [next] | [standalone]
| From | "Paul D B" <polleke@NOMORESPAMhnt.be> |
|---|---|
| Date | 2011-05-18 17:00 +0200 |
| Subject | Re: Highlighting Buttons on tab page freezes program - Solved! |
| Message-ID | <4dd3df13$0$14256$ba620e4c@news.skynet.be> |
| In reply to | #1117 |
Craig
Allright should have read the whole thread until the very end!!
Glad you found the culprit, and your fix should be implemented by everyone
using this iconpushbutton class, in fact.
And I'll try to found out where I borrowed that getDisplayTextWidth function
because the bug is in there too...
Thanks a lot for solving this
Paul
"Craig Dawson" schreef in bericht
news:4dceae1f$0$47016$c30e37c6@pit-reader.telstra.net...
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
[toc] | [prev] | [next] | [standalone]
| From | Sherlock <sherlock@sherlock.com.au> |
|---|---|
| Date | 2011-05-10 05:01 -0700 |
| Message-ID | <040bad33-5ec5-4b98-a8db-64e373107817@17g2000prr.googlegroups.com> |
| In reply to | #1076 |
Craig What is the Dynsize( ) setting on your program. DO you have SetEnvionment() type call for your apps? Try ; DynSize( 115) or say SynSize(180) // Resize the dynamic memory pool to a specific number of pages. (20) Does this change the problem in how long it takes to see the problem. Have you added a COLLECTFORCED() in your code when you say return to you say main menu screen. It sounds like memory and resources. You are still using Vo2.7 and I can tell Vo.28 2837 eats VO2.7 as a stable product. I built webservices with 2.7, went back to 2,5b3 and could not get them stable for a week. With VO2.8 they run for years, they never fail and ironically they process your Control files 24x7. Else I would be rechecking your button classes not resetting something that is unique to this operation, verse touch screen. Happy to have a look if you have a small sample and the methodology to kill it. I have some really good tools I built in for debugging things like this which related to Menus doing some odd things and the appropriate Destroy fixed it all Phil McGuinness
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web