Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
FLabel.cpp
Package: FLabel.rar [view]
Upload User: hnxhmj
Upload Date: 2020-10-13
Package Size: 14k
Code Size: 3k
Category:
Static control
Development Platform:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "FLabel.h"
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- // ValidCtrCheck is used to assure that the components created do not have
- // any pure virtual functions.
- //
- static inline void ValidCtrCheck(TFLabel *)
- {
- new TFLabel(NULL);
- }
- //---------------------------------------------------------------------------
- __fastcall TFLabel::TFLabel(TComponent* Owner)
- : TLabel(Owner)
- {
- }
- //---------------------------------------------------------------------------
- namespace Flabel
- {
- void __fastcall PACKAGE Register()
- {
- TComponentClass classes[1] = {__classid(TFLabel)};
- RegisterComponents("Custom", classes, 0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFLabel::SetTextSpace(int Value)
- {
- if(FTextSpace!=Value)
- {
- //int Diff=Value-FTextSpace;
- FTextSpace=Value;
- //int len=(WideString(Caption)).Length()-1;
- //if(len) Width+=len*Diff;//加上TextSpace
- Width++;
- Width--;
- //AdjustBounds();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFLabel::DoDrawText(TRect &Rect, int Flags)
- {
- AnsiString Text;
- Text = GetLabelText();
- if( (Flags && DT_CALCRECT!=0) && ((Text == "") || ( ShowAccelChar && Text.c_str()[0] == '&' && Text.c_str()[1] == '')))
- Text = Text + " ";
- if(!ShowAccelChar) Flags = Flags | DT_NOPREFIX;
- Flags = DrawTextBiDiModeFlags(Flags);
- Canvas->Font = Font;
- SetTextCharacterExtra(Canvas->Handle,TextSpace); //设置字符间距;
- if(!Enabled)
- {
- OffsetRect(&Rect, 1, 1);
- Canvas->Font->Color = clBtnHighlight;
- DrawText(Canvas->Handle, Text.c_str(), Text.Length(), &Rect, Flags);
- OffsetRect(&Rect, -1, -1);
- Canvas->Font->Color = clBtnShadow;
- DrawText(Canvas->Handle, Text.c_str(), Text.Length(), &Rect, Flags);
- }
- else
- DrawText(Canvas->Handle, Text.c_str(), Text.Length(), &Rect, Flags);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFLabel::SetBorder(int Value)
- {
- if(FBorder!=Value)
- {
- FBorder=Value;
- Paint();
- Width++;
- Width--;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFLabel::Paint()
- {
- TLabel::Paint();
- Canvas->Pen->Style=FBorder?psSolid:psClear;
- Canvas->Pen->Color=FBorder?clRed:clBlack;
- if(FBorder==0 || FBorder==1)
- Canvas->Rectangle(0,0,Width,Height);
- else if(FBorder==2)
- Canvas->RoundRect(0,0,Width,Height,20,20);
- }