|
그대로 C++Builder로 변경하면 아래와 같이 됩니다.
void __fastcall TForm1::Shape1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if( ((TShape *)Sender)->Brush->Color==clRed )
((TShape *)Sender)->Brush->Color=clLime;
else
((TShape *)Sender)->Brush->Color=clRed;
}
Shape가 여러개일경우
원하는 모든 Shape의 MouseDown이벤트 핸들러를 Shape1MouseDown 메소드에 걸어야 겠지요
그럼..
나래피오 님이 쓰신 글 :
: Shape 컨트롤이 100개 정도 있습니다. MouseDown 이벤트를 통해서 각각 색을 변경하려고 하는대요.
: (Shape은 OnClick 이벤트가 없네요..ㅡㅡ)
:
: 각각 코딩을 하지 않고 참조해서 쓰는 방법이 어찌 되는지 알려주세요.
:
: 참고로 델파이 로직은 아래와 같습니다.
:
: procedure TForm1.Shape_01MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
:
: if TShape(Sender).Brush.Color = clRed then
: begin
: TShape(Sender).Brush.Color := clLime;
: end
:
: else
: begin
: TShape(Sender).Brush.Color := clRed;
: end;
:
: 이걸 참조해서 Shape_02에 사용하믄 색이 바끼네요.
:
:
:
: 이 방식대로 C++로 코딩하믄 에러 발생하네요.ㅎ
|