Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #1122
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: Highlighting Buttons on tab page freezes program - Solved! |
| Date | 2011-05-17 07:19 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <iqtp4t$rdv$1@speranza.aioe.org> (permalink) |
| References | (6 earlier) <4dcc4a3f$0$47020$c30e37c6@pit-reader.telstra.net> <4dccc7db$0$18690$91cee783@newsreader03.highway.telekom.at> <4dcdb621$0$47014$c30e37c6@pit-reader.telstra.net> <4dce2c3c$0$47014$c30e37c6@pit-reader.telstra.net> <4dceae1f$0$47016$c30e37c6@pit-reader.telstra.net> |
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
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-10 07:39 +1000
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-09 21:51 -0500
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-10 14:09 +1000
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-10 05:52 -0500
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-11 01:53 +1000
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-10 11:57 -0500
Re: Highlighting Buttons on tab page freezes program "Willie Moore" <williem@wmconsulting.com> - 2011-05-10 11:57 -0500
Re: Highlighting Buttons on tab page freezes program "Bernhard Mayer" <Idonotexisthere@nowhere.com> - 2011-05-11 07:35 +0200
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-13 06:59 +1000
Re: Highlighting Buttons on tab page freezes program "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> - 2011-05-13 08:57 +1000
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-14 08:47 +1000
Re: Highlighting Buttons on tab page freezes program "Bernhard Mayer" <Idonotexisthere@nowhere.com> - 2011-05-13 07:55 +0200
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-14 08:52 +1000
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-14 17:16 +1000
Re: Highlighting Buttons on tab page freezes program - Solved! "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-15 02:30 +1000
Re: Highlighting Buttons on tab page freezes program - Solved! "Gerhard Bunzel" <g.bunzel@domonet.de> - 2011-05-16 00:08 +0200
Re: Highlighting Buttons on tab page freezes program - Solved! "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-17 21:55 +1000
Re: Highlighting Buttons on tab page freezes program - Solved! "Willie Moore" <williem@wmconsulting.com> - 2011-05-17 07:19 -0500
Re: Highlighting Buttons on tab page freezes program - Solved! "Paul D B" <polleke@NOMORESPAMhnt.be> - 2011-05-18 17:00 +0200
Re: Highlighting Buttons on tab page freezes program Sherlock <sherlock@sherlock.com.au> - 2011-05-10 05:01 -0700
Re: Highlighting Buttons on tab page freezes program "Craig Dawson" <craig@control.nospam.net.au> - 2011-05-11 01:58 +1000
Re: Highlighting Buttons on tab page freezes program "Paul D B" <polleke@NOMORESPAMhnt.be> - 2011-05-18 16:39 +0200
Re: Highlighting Buttons on tab page freezes program "Paul D B" <polleke@NOMORESPAMhnt.be> - 2011-05-18 16:42 +0200
csiph-web