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
Unit1.cpp
Package: C++Builder.rar [view]
Upload User: lhxd_sz
Upload Date: 2014-10-02
Package Size: 38814k
Code Size: 2k
Category:
Visual C++ Books
Development Platform:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- StringGrid1->Cells[1][3]="北京n海淀区n中关村";
- StringGrid1->Cells[2][3]="中华人民共和国西安";
- StringGrid1->Cells[3][3]="上海";
- StringGrid1->Cells[4][3]="深圳";
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
- int ARow, TRect &Rect, TGridDrawState State)
- {
- int align;
- if(ACol<1)return;
- if(ARow<1)return;
- StringGrid1->Canvas->Pen->Color=clWhite;
- StringGrid1->Canvas->Brush->Color=clWhite;
- StringGrid1->Canvas->Brush->Style=bsSolid;
- StringGrid1->Canvas->Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
- align=2;
- PaintText(Rect.Left+2,Rect.Top+2,ACol,StringGrid1->Cells[ACol][ARow],align);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::PaintText(int x,int y,int col,AnsiString text,int align)
- {
- int ii,yy;
- TStringList *str;
- str=new TStringList();
- str->Text=text;
- yy=1;
- for(ii=0;ii<str->Count;ii++)
- {
- PaintText1(x,y+yy,col,str->Strings[ii],align);
- yy=yy+StringGrid1->Canvas->TextHeight(text);
- }
- delete str;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::PaintText1(int x,int y,int col,AnsiString text,int align)
- {
- int colwd,ww;
- colwd=StringGrid1->ColWidths[col];
- if(align==1)
- {
- ww=StringGrid1->Canvas->TextWidth(text);
- ww=colwd-ww;
- ww/=2;
- if(ww<0)ww=0;
- StringGrid1->Canvas->TextOut(x+ww,y,text);
- }
- else if(align==2)
- {
- ww=StringGrid1->Canvas->TextWidth(text);
- ww=colwd-ww;
- if(ww<0)ww=0;
- StringGrid1->Canvas->TextOut(x+ww,y,text);
- }
- else
- {
- StringGrid1->Canvas->TextOut(x,y,text);
- }
- }
- //---------------------------------------------------------------------------