604
社区成员
发帖
与我相关
我的任务
分享
private: // User declarations
void __fastcall NewEditWndProc(TMessage &Msg);
.cpp文件中:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Edit1->Ctl3D = false;
Edit1->WindowProc = NewEditWndProc;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NewEditWndProc(TMessage &Msg)
{
Edit1->Dispatch(&Msg);
if (Msg.Msg == WM_PAINT)
{
TControlCanvas *canvas = new TControlCanvas;
canvas->Control = Edit1;
TRect rct(0, 0, Edit1->Width, Edit1->Height);
canvas->Brush->Color = Color;
canvas->FillRect(rct);
canvas->Pen->Color = clBlue;
canvas->MoveTo(rct.Left, rct.Bottom - 1);
canvas->LineTo(rct.Right, rct.Bottom - 1);
canvas->Font->Color = Edit1->Font->Color;
InflateRect(&rct, -1, -1);
canvas->TextRect(rct, 2, 2, Edit1->Text);
delete canvas;
}
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TEdit *edt = new TEdit(this);
edt->Parent = this;
edt->Left = 100;
edt->Top = 100;
edt->BorderStyle = bsNone;
edt->Font->Size = 10;
edt->ParentColor = true;
edt->Show();
TBevel *bvl = new TBevel(this);
bvl->Parent = this;
bvl->Shape = bsBottomLine;
bvl->SetBounds(edt->Left, edt->Top, edt->Width, edt->Height);
bvl->Height = bvl->Height + 2;
bvl->Show();
}