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
[26721] 해미님-> 파스칼 소스의 이해(수정)->200%부족 --; (또 시작임다^^*)
요구르트 [] 984 읽음    2003-08-14 02:08
아예 소스를 몽땅 올려봅니다..
매번 정말 죄송해요..^^*

#include <vcl.h>
#pragma hdrstop

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



void __fastcall TForm1::CColorGrid1Click(TObject *Sender)
{
Image1->Canvas->Pen->Color = CColorGrid1->ForegroundColor;
Image1->Canvas->Brush->Color = CColorGrid1->BackgroundColor;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::CSpinEdit1Change(TObject *Sender)
{
Image1->Canvas->Pen->Width = CSpinEdit1->Value;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ButtonKind(TPenMode PenMode)
{
Image1->Canvas->Pen->Mode = PenMode;

if(DrawBtn->Down == true) {
   Image1->Canvas->LineTo(MPoint.x, MPoint.y);
   }

// 선을 그릴 때.
if(LineBtn->Down == true) {
   Image1->Canvas->MoveTo(StartDot.x, StartDot.y);
   Image1->Canvas->LineTo(MPoint.x, MPoint.y);
   }

// 사각형을 그릴 때.
if(RectBtn->Down == true) {
   Image1->Canvas->Rectangle(StartDot.x, StartDot.y, MPoint.x, MPoint.y);
   }

// 원을 그릴 때.
if(EllipseBtn->Down == true) {
   Image1->Canvas->Ellipse(StartDot.x, StartDot.y, MPoint.x, MPoint.y);
   }

// 둥근 사각형을 그릴 때.
if(RoundBtn->Down == true) {
   Image1->Canvas->RoundRect(StartDot.x, StartDot.y, MPoint.x, MPoint.y, ((StartDot.x - MPoint.x)/2), ((StartDot.y - MPoint.y)/2));
   }
// 지우개.
if(EraseBtn->Down == true) {
   Image1->Canvas->Pen->Mode = pmWhite;
   Image1->Canvas->LineTo(MPoint.x, MPoint.y);
   }

// 선택된 공간 채우기.
if(FillBtn->Down == true) {
   Image1->Canvas->Brush->Color = CColorGrid1->ForegroundColor;
   Image1->Canvas->FloodFill((StartDot.x), (StartDot.y), CColorGrid1->ForegroundColor, fsSurface);
   Image1->Canvas->Brush->Color = clWhite;
   }
}

void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
if(Button == mbLeft) {
  isButtonClick = true;
  Image1->Canvas->MoveTo(X, Y);
  StartDot = Point(X, Y);
  MPoint = StartDot;

  if(FillBtn->Down == true)  {
     Image1->Canvas->Brush->Color = CColorGrid1->ForegroundColor;
     Image1->Canvas->FloodFill(X, Y, clBlack, fsBorder);
  }
}
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
if(isButtonClick == true) {
   if(DrawBtn->Down == false || EraseBtn->Down == false)   {
      ButtonKind(pmNotXor);
      MPoint = Point(X, Y);
      ButtonKind(pmNotXor);
   }
   else   {
      MPoint = Point(X, Y);
      ButtonKind(pmCopy);
      StartDot = MPoint;
   }
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
if(isButtonClick == true) {
  MPoint = Point(X, Y);
  ButtonKind(pmCopy);
}
IsButtonClick = false;       
}
//---------------------------------------------------------------------------

[질문1]
먼저 님이 가르쳐주신대로..하니깐
void __fastcall TForm1::ButtonKind(TPenMode PenMode)
부분에서는 에러가 잡히지 않았거든요..

근데..
마우스 컨트롤하는 함수부분에서 에러가 나더라구요..

isButtonClick = true; 이 부분에서 에러가 나는데..
에러 이유가
[C++ Error] Unit1.cpp(121): E2451 Undefined symbol 'isButtonClick'
이렇게 나오거든요..

isButtonClick가 선언되지 않았다는 말 같다는거 같은데..
헬프를 찾아봐도 isButtonClick에 관련된거 없어서 다른걸로 함 바꿔서 해보지도 못하겠더라구요..--;


[질문2]
지난 답변에서 ButtonKind(pmCopy); 부분에 pmCopy를 적당히 지정하라고 하셨는데..
이건 델파이 책 그대로 적은건데 맞나요??

이 외에도..
파일 저장등의 소스가 있지만,,
그건 크게 문제가 없을듯 싶어서 위의 소스만 올려봅니다..
부디 좋은 답변 부탁드려요..^^*

앗!!
헤더파일은 첨부파일로 올립니다..
public에 void __fastcall TForm1::ButtonKind(TPenMode PenMode)쓰라고 하셨는데..
일단 에러는 나지 않던데..
맞는지 몰라서요..--;

+ -

관련 글 리스트
26715 그림판 만들기에서 브러시와 펜의 속성 지정..?(그림판 소스없나요??) 요구르트 2032 2003/08/13
26717     [답변] 파스칼 소스의 이해(수정) 정성훈.해미 1088 2003/08/13
26721         해미님-> 파스칼 소스의 이해(수정)->200%부족 --; (또 시작임다^^*) 요구르트 984 2003/08/14
33079             Re:해미님-> 파스칼 소스의 이해(수정)->200%부족 --; (또 시작임다^^*) 정성훈.해미 808 2003/08/14
33078             Re:해미님-> 파스칼 소스의 이해(수정)->200%부족 --; (또 시작임다^^*) 꼴.시크릿 894 2003/08/14
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.