TBtnFlat

Fuente: source/classes/btnflat.prg

Inherits from: TControl

TBtnFlat is a flat borderless button with a hover highlight effect. It draws its caption centered over a solid color background and reacts to mouse clicks via a code block action. The button can optionally display a border, and its text and pane colors are fully customizable.

Key DATA Members

DATATypeDescription
cCaptionCharacterButton caption text
bActionBlockCode block executed when the button is clicked
nClrTextNumericText color (RGB value, default CLR_WHITE)
nClrPaneNumericBackground pane color (RGB value, default CLR_BLUE)
oFontObjectFont object for the caption text
lBorderLogicalShow a border around the button
lTransparentLogicalTransparent background (no fill)
lPressedLogicalWhether the button is currently pressed
nClrTextDisNumericText color when disabled
nClrPaneDisNumericPane color when disabled

Methods

MethodDescription
New( nTop, nLeft, nW, nH, cPrompt, oWnd, oFont, bAction, bWhen, lUpdate, lBorder, nClrText, nClrPane, lCancel, lDefault )Create a new flat button
ReDefine( nId, bAction, oWnd, ... )Redefine from a dialog resource
Click()Execute the button action (evaluates bWhen, then bAction)
Paint()Draw the button background and centered caption
LButtonDown( nRow, nCol, nFlags )Handle mouse down with working state tracking
LButtonUp( nRow, nCol )Handle mouse up and trigger click if within control
DrawMultiLine( cText, oFont, nColor, nAlign )Draw multi-line caption text with alignment

Example: Flat Button with Hover

#include "FiveWin.ch"

function Main()

   local oWnd, oBtn

   DEFINE WINDOW oWnd TITLE "TBtnFlat Demo" SIZE 400, 200

   @ 40, 60 FLATBTN oBtn ;
      PROMPT "&Click Me" ;
      OF oWnd ;
      SIZE 100, 30 ;
      ACTION MsgInfo( "Flat button pressed!" ) ;
      COLOR CLR_WHITE, CLR_BLUE

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Ver También