C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[61266] 사각형이나 원 그리는 법좀
김준석 [] 967 읽음    2010-05-31 05:35
//---------------------------------------------------------------------------

#include 
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CGRID"
#pragma resource "*.dfm"
int a = 0;
TForm1 *Form1;
TPoint MPoint, StartDot;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
        Image1->Picture->Bitmap->Height =  305;
        Image1->Picture->Bitmap->Width = 320;
        ListBox1->ItemIndex = 0;

        this->DoubleBuffered=true;

}
//---------------------------------------------------------------------------
TPoint stPt1,stPt2;   
int iPBrushWid=3;
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
        if(Shift.Contains(ssLeft)){
        if(a==1){  // 연필
        Image1->Picture->Bitmap->Canvas->LineTo(X,Y);
        }
        if(a==2){ // 빗금
        TPoint cuPt1,cuPt2,cuPt3,cuPt4;
        cuPt1=Point(X-iPBrushWid,Y-iPBrushWid);
        cuPt2=Point(X+iPBrushWid,Y+iPBrushWid);

        TPoint p[5]={stPt1,stPt2,cuPt2,cuPt1,stPt1};
        Image1->Canvas->Polygon(&p[0],4);
        stPt1=cuPt1;
        stPt2=cuPt2;
        }
        if(a==3)//사각형
        {

        }
        }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Image1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
        Image1->Canvas->Brush->Color= CColorGrid1->ForegroundColor;
        Image1->Picture->Bitmap->Canvas->Pen->Color = CColorGrid1->ForegroundColor;
        Image1->Picture->Bitmap->Canvas->Pen->Width = ListBox1->ItemIndex+1;
        if(a==1){
        Image1->Picture->Bitmap->Canvas->MoveTo(X,Y);}
        if(a==2){
        stPt1=Point(X-iPBrushWid,Y-iPBrushWid);
        stPt2=Point(X+iPBrushWid,Y+iPBrushWid);
        }
        if(a==3){


        }


}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        if (SaveDialog1->Execute())
	Image1->Picture->Bitmap->SaveToFile(SaveDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
        if (OpenDialog1->Execute())
	Image1->Picture->Bitmap->LoadFromFile(OpenDialog1->FileName);
}
//---------------------------------------------------------------------------


void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
        a = 2;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
        a = 1;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
        a = 3;
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
61266 사각형이나 원 그리는 법좀 김준석 967 2010/05/31
61273     Re:사각형이나 원 그리는 법좀 공부중 1175 2010/05/31
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.