⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shape.cpp

📁 《C Builder 5技术内幕》程序源代码
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <TypInfo.hpp>
#pragma hdrstop

#include "Shape.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormShape *FormShape;
//---------------------------------------------------------------------------
__fastcall TFormShape::TFormShape(TComponent* Owner)
    : TForm(Owner)
{
  ShapeMain->Left = 0;
  ShapeMain->Top  = 0;
  PPropInfo PropInfo = GetPropInfo( PTypeInfo( ClassInfo( __classid( TShape ) ) ), "Shape" );
  for( int i = 0; i < 6; i++ )
    ComboBoxShape->Items->Add( GetEnumName( *(PropInfo->PropType), i ) );
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::MenuItemColorShapeClick(TObject *Sender)
{
  if( ColorDialog->Execute() )
    ShapeMain->Brush->Color = ColorDialog->Color;
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::MenuItemColorFormClick(TObject *Sender)
{
  if( ColorDialog->Execute() )
    FormShape->Color = ColorDialog->Color;
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::ScrollBarHorizontalChange(TObject *Sender)
{
  ShapeMain->Width = ScrollBarHorizontal->Position;
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::ScrollBarVerticalChange(TObject *Sender)
{
  ShapeMain->Height = ScrollBarVertical->Position;
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::FormResize(TObject *Sender)
{
  ScrollBarHorizontal->Max = ClientWidth - ( ScrollBarVertical->Width + 1 );
  ScrollBarVertical->Max = ClientHeight - ( ScrollBarHorizontal->Height + 1 );
  ScrollBarHorizontal->Left = 0;
  ScrollBarVertical->Top = 0;
  ScrollBarVertical->Left = ClientWidth - ScrollBarVertical->Width;
  ScrollBarVertical->Height = ClientHeight;
  ScrollBarHorizontal->Top = ClientHeight - ScrollBarHorizontal->Height;
  ScrollBarHorizontal->Width = ClientWidth - ScrollBarVertical->Width;
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::MenuItemShapesExitClick(TObject *Sender)
{
  Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::MenuItemShapesRectangleClick(TObject *Sender)
{
  ShapeMain->Shape = TShapeType( dynamic_cast< TMenuItem* >( Sender )->Tag );
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::MenuItemShapesRoundSquareClick(TObject *Sender)
{
  ShapeMain->Shape = TShapeType( dynamic_cast< TMenuItem* >( Sender )->Tag );
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::MenuItemShapesEllipseClick(TObject *Sender)
{
  ShapeMain->Shape = TShapeType( dynamic_cast< TMenuItem* >( Sender )->Tag );
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::MenuItemShapesCircleClick(TObject *Sender)
{
  ShapeMain->Shape = TShapeType( dynamic_cast< TMenuItem* >( Sender )->Tag );
}
//---------------------------------------------------------------------------
void __fastcall TFormShape::ComboBoxShapeChange(TObject *Sender)
{
  ShapeMain->Shape = TShapeType( ComboBoxShape->ItemIndex );
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -