?? infoform3.~cpp
字號(hào):
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "InfoForm3.h"
#include "MainForm1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TInfoForm *InfoForm;
//---------------------------------------------------------------------------
__fastcall TInfoForm::TInfoForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
/*
在InfoForm還沒(méi)有顯示之前進(jìn)行一些操作,就需要重載Loaded()函數(shù)。
具體做法是:
首先,調(diào)用基類的Loaded()函數(shù),以保證基類的動(dòng)作被繼承。然后,
設(shè)置Form的一些屬性,SetBounds()設(shè)置窗體的邊框大小。
*/
void __fastcall TInfoForm::Loaded()
{
TForm::Loaded();
Visible = false;
Position = poDefault;
BorderIcons = TBorderIcons();
BorderStyle = bsNone;
Color=clMenu;
HandleNeeded();
int X = MainForm->Width/2;
int Y = 0;
int H =MainForm->Height ;
int W = MainForm->Width/2;
SetBounds(X,Y,W,H);
}
//---------------------------------------------------------------------------
/*
當(dāng)VCL要構(gòu)造元件的窗口類時(shí),就會(huì)調(diào)用CreateParams()函數(shù)。
CreateParams()函數(shù)聲明如下:
virtual void __fastcall CreateParams(TCreateParams& Params);
唯一的參數(shù)是一個(gè) TCreateParams結(jié)構(gòu)。TCreateParams聲明如下:
struct TCreateParams
{
char *Caption;
int Style;
int ExStyle;
int X;
int Y;
int Width;
int Height;
HWND WndParent;
void *Param;
tagWNDCLASSA WindowClass();
char WinClassName[64];
};
大多數(shù)情況下需要重載CreateParams()函數(shù),以便改變?cè)拇翱陲L(fēng)格。
具體做法是:
首先,調(diào)用基類的CreateParams()函數(shù),以便繼承默認(rèn)的行為。然后,
在原有的窗口風(fēng)格基礎(chǔ)上加上WS_CHILD | WS_CLIPSIBLINGS。
*/
void __fastcall TInfoForm::CreateParams(TCreateParams& Params)
{
TForm::CreateParams(Params);
TForm* owner = dynamic_cast<TForm*>(Owner);
Params.WndParent = owner->Handle;
Params.Style = WS_CHILD | WS_CLIPSIBLINGS;
Params.X = 0;
Params.Y = 0;
}
//---------------------------------------------------------------------------
/*
公有自定義函數(shù)
初始化靜態(tài)文本框中的文本。 AnsiString類的文本賦值采用等號(hào)。
*/
void TInfoForm::Reset()
{
Timer->Caption="時(shí)間:";
Color1->Caption="紅方:";
RedInfo->Caption="紅方:";
BlackInfo->Caption="黑方:";
Level2->Caption="級(jí)別:";
Value->Caption="值:";
Nodes->Caption="節(jié)點(diǎn):";
Seconds->Caption="步/秒:";
Depth->Caption="深度:";
BestPath->Caption="";
Message->Caption="";
}
//---------------------------------------------------------------------------
/*
設(shè)置信息窗體背景
采用文件方式載入位圖。
如果位圖沒(méi)有保存在資源文件(.res)內(nèi),C++ Builder不能把從文件裝入的位圖
連接入最后的可執(zhí)行文件。因此,必須確保在c:\BcbChess下有必需的位圖文件。
很明顯,使用VCL函數(shù)比原始的API函數(shù)要方便得多。
使用后,應(yīng)將Canvas->Brush->Bitmap這個(gè)特性設(shè)為NULL,以釋放位圖。
如果不刪除位圖,將導(dǎo)致程序內(nèi)存不足。
*/
void TInfoForm::SetInfoWindowBk()
{
Graphics::TBitmap *BLKBrushBmp = new Graphics::TBitmap();
BLKBrushBmp->LoadFromFile("e:\\BKBrush.bmp");
//BLKBrushBmp->LoadFromFile("c:\\BcbChess\\BKBrush.bmp");
InfoForm->Canvas->Brush->Bitmap=BLKBrushBmp;
InfoForm->Canvas->FillRect(InfoForm->GetClientRect());
InfoForm->Canvas->Brush->Bitmap=NULL;
delete BLKBrushBmp;
}
//---------------------------------------------------------------------------
/*
公有自定義函數(shù)
AnsiString類的文本賦值采用等號(hào),非常方便。
*/
void TInfoForm::IterReset()
{
Color1->Caption="紅方";
Value->Caption="";
Nodes->Caption="";
Seconds->Caption="";
BestPath->Caption="";
}
//---------------------------------------------------------------------------
/*
信息窗體重畫(huà)函數(shù)。其背景用位圖填充。注意,由于位圖采用文件方式載入,
不能鏈接入可執(zhí)行文件中,請(qǐng)確保c:\BcbChess下有需要的位圖文件。
*/
void __fastcall TInfoForm::InfoPaint(TObject *Sender)
{
SetInfoWindowBk();
HDC PaintDC=GetDC(InfoForm->Handle);
DrawInfoFrame(PaintDC);
ReleaseDC(InfoForm->Handle, PaintDC);
}
//---------------------------------------------------------------------------
/*
公有自定義函數(shù)
繪制信息窗體凸起來(lái)的三維邊框
*/
void TInfoForm::DrawInfoFrame(HDC hDC)
{
DrawFrame(hDC, InfoRect);
}
//---------------------------------------------------------------------------
/*
信息窗體顯現(xiàn)事件處理函數(shù)
窗體顯現(xiàn)時(shí)獲取信息窗體的矩形框大小
*/
void __fastcall TInfoForm::FormShow(TObject *Sender)
{
InfoRect.right = MainForm->ClientWidth/2;
InfoRect.bottom = MainForm->ClientHeight;
InfoRect.left = 0 ;
InfoRect.top = 0 ;
}
//---------------------------------------------------------------------------
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -