//---------------------------------------------------------------------------
void __fastcall TOsnova::Paint()
{
this->Canvas->Brush->Color=clSkyBlue;
this->Canvas->Font->Size=this->Height/20;
this->Canvas->TextOutA(this->Width/4,3," ");
}
//---------------------------------------------------------------------------
Paint() .
7 WndProc(TMessage& Message)
, , WndProc(). , Windows VCL .
WndProc(), . CreateWnd():
SetTimer (Handle, 1, FSkorosty, 0). , 1 - , FSkorosty - ) 0 , , . , Windows WM_TIMER .
:
KillTimer (Handle, 1);
WM_TIMER:
//---------------------------------------------------------------------------
void __fastcall TOsnova::WndProc(TMessage& Message)
{
TCustomControl::WndProc(Message); //
if (Message.Msg == WM_TIMER)
{
//,
if ((N==true)&&(this->Width!=NewWidth)&&(this->Height!=NewHeight))
{
this->Width=NewWidth;
this->Height=NewHeight;
D=this->Width/5*4;
d=this->Width/5*3;
Marshrut->Width=this->Width;
Marshrut->Height=this->Height
Shar->Width=(Dd)/2;
Shar->Height=(Dd)/2;
Shar->Left=(this->Width-D)/2+D-Shar->Width;
Shar->Top=this->Height/2-Shar->Height/2;
this->Canvas->Font->Size=this->Height/20;
this->Canvas->TextOutA(this->Width/4,3," ");
this->Invalidate();//
N=false;//
} a+=0.2;// ( )
Shar->Left=(Marshrut->Width-(D-(Dd)/2))/2+(D-(Dd)/2)/2+(D-(Dd)/2)/2*cos(a)-
Shar->Width/2;
Shar->Top=(Marshrut->Height-(D-(Dd)/2))/2+(D-(Dd)/2)/2-(D-(Dd)/2)/2*sin(a)-
Shar->Height/2;
}
}
//---------------------------------------------------------------------------
TCustomControl::WndProc(Message), ( ), Invalidate() , .
8 CanResize(int &NewWidth, int &NewHeight).
|
|
, , .
//---------------------------------------------------------------------------
bool __fastcall TOsnova::CanResize(int &NewWidth, int &NewHeight)
{ //
if (ComponentState.Contains(csDesigning))
{
D=this->Width/5*4; //
d=this->Width/5*3;
Marshrut->Width=this->Width; // . Marshrut
Marshrut->Height=this->Height;
Shar->Width=(Dd)/2; // . Shar
Shar->Height=(Dd)/2;
Shar->Left=(this->Width-D)/2+D-Shar->Width;
Shar->Top=this->Height/2-Shar->Height/2;
this->Canvas->Font->Size=this->Height/20; //
this->Canvas->TextOutA(this->Width/4,3," "); //
this->Invalidate(); //
}
if (NewWidth!=NewHeight) NewWidth=NewHeight;
return(NewWidth, NewHeight);
}
//---------------------------------------------------------------------------
CanResize() (NewWidth) (NewHeight), WndProc(TMessage& Message), , .
, , . , OnClick, , Sender:
void fastcall TForml::FormClick(TObject *Sender).
VCL TNotifyEvent.
, ,
TNotifyEvent. OnMyClick, TOsnova . :
__property TNotifyEvent OnMyClick = {read=FOnMyClick, write=FOnMyClick};
, , . ( - ) .
, OnMyClick, DoOnMyClick():
//---------------------------------------------------------------------------
void __fastcall TOsnova::DoOnMyClick()
{
if (FOnMyClick)
FOnMyClick(this);
}
//---------------------------------------------------------------------------
, . , , FOnMyClick, (this). Events .
Builder :
//---------------------------------------------------------------------------
void __fastcall TForm1::Osnova1MyClick(TObject *Sender)
{
//
}
//---------------------------------------------------------------------------
(File New Application).
(Project Add to Project) Osnova.cpp, Marshrut.cpp Shar.cpp.
|
|
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)
{
TOsnva *Osnova;
Osnova=new TOsnova(this);
Osnova->Parent=this;
}
//---------------------------------------------------------------------------
.
Register(), C++ Builder. namespace . , . Register classes TComponentClass . RegisterComponents , classes ( ) Samples ( ).
//---------------------------------------------------------------------------
namespace Osnova
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TOsnova)};
RegisterComponents("Samples", classes, 0);
}
}
//---------------------------------------------------------------------------
Component, Install Component.
Into new package ( ), (APPKOsnova) . .
No, - TMarshrut Shar. (Package Manager) Add, Add Unit Marshrut.cpp Shar.cpp
.
, Project - > Options - >Remove.