_fastcall TfmMainForm::Cancel1Click(TObject *Sender)
{
int i;
switch (PageControl1->ActivePage->Tag))
{
case 1:
for (i=0; i < ComponentCount; i++)
{
if (dynamic_cast(Components[i]))
dynamic_cast(Components[i])->Enabled = false;
}
Data->tbDetail->Cancel();
break;
case 2:
for (i=0; i < ComponentCount; i++)
{
if (dynamic_cast(Components[i]))
dynamic_cast(Components[i])->Enabled = false;
}
Data->tbDetail->Cancel();
break;
case 3:
for (i=0; i < ComponentCount; i++)
{
if (dynamic_cast(Components[i]))
dynamic_cast(Components[i])->Text = "";
}
default:
break;
}
}
向Query传递参数
// 直接从表向Query传递参数的一种方法
TQuery *Query = new TQuery(this);
Query->DatabaseName = "dbServer";
Query->SQL->Clear();
Query->SQL->Add("DELETE FROM ''Events.DB'' WHERE (TicketNo = " + Data->tbProblem->FieldByName("TicketNo")->AsString + ")" );
Query->ExecSQL();
Query->Close();
delete Query;
日期属性
TMaskEdit *meOpen;
TLabel *lbCount1;
TDateTime Date2;
void __fastcall TfmMainForm::CountOpen(TObject *Sender)
{
switch(dynamic_cast<TComponent&>(*Sender).Tag)
{
case 1:
count1 = StrToInt(lbCount1->Caption);
count1 += 1;
Date2 = Now() + count1;
meOpen->Text = Date2.DateString();
lbCount1->Caption = IntToStr(count1);
break;
case 2:
count1 = StrToInt(lbCount1->Caption);
count1 -= 1;
Date2 = Now() + count1;
meOpen->Text = Date2.DateString();
lbCount1->Caption = IntToStr(count1);
break;
}
}
绘制状态条
void __fastcall TForm1::StatusBar1DrawPanel(TStatusBar *StatusBar, TStatusPanel *Panel, const TRect &Rect)
{
TCanvas& c = *StatusBar->Canvas;
switch (Panel->Index)
{
case 0 :
{
StatusBar1->Panels->Items[0]->Text = "Hello C++";
c.Brush->Style = bsClear;
TRect temp = Rect;
temp.Top += 1;
temp.Left += 1;
c.Font->Color = clWhite;
DrawText(c.Handle,Panel->Text.c_str(),-1,(RECT*)&temp,DT_SINGLELINE|DT_CENTER);
c.Font->Color = clBlack;
DrawText(c.Handle,Panel->Text.c_str(),-1,(RECT*)&Rect,DT_SINGLELINE|DT_CENTER);
break;
}
case 1:
{
c.Brush->Color = clYellow;
c.FillRect(Rect);
c.Font->Color = clRed;
DrawText(c.Handle,"clYellow Color", -1, (RECT*)&Rect, DT_SINGLELINE | DT_CENTER);
break;
}
case 2:
{
Graphics::TBitmap* bm = new Graphics::TBitmap;
bm->Handle = LoadBitmap(NULL, MAKEINTRESOURCE(32760));
c.Draw(Rect.Left, Rect.Top, bm);
delete bm;
break;
}
}
}
|