Q&A

  • [답변대로 했는데도 안됩니다.] stringgrid에서 이미지 교체....
stringgrid에서 이미지를 삽입하고, 다시 로그할때 다른것으로 바꾸는 건데,

마우스로 클릭해야만 바뀌는 현상입니다.

별짓을 다 해봐도 안되는군요,

소스는 아래와 같습니다.



procedure TfrmMain.gridDrawCell(Sender: TObject; ACol, ARow: Integer;

Rect: TRect; State: TGridDrawState);

var LeftPos,i: Integer;

dRect: TRect;

begin

if (ACol = 2) then begin



Rect := (Sender as TStringGrid).CellRect(ACol, ARow); //답변해주신 부분

dRect := Classes.Rect(0,0, (Rect.Right-Rect.Left), rect.Bottom-rect.Top);



if (조건) then begin

(Sender as TStringGrid).Canvas.BrushCopy(Rect,

bmpFalse, dRect,clBtnFace); //bmpFalse 는 Bitmap 이미지

end

else (Sender as TStringGrid).Canvas.BrushCopy(Rect, bmpTrue,

dRect,clBtnFace);

end;

end;



위 소스에서 처음에 bmpTrue를 화면에 보입니다. 그러다 조건에 거리면 bmpFalse로

바뀌어야 하는데, 정말 정말 안됩니다.

제발 도와 주십시요.



1  COMMENTS
  • Profile
    김영석 2000.12.20 02:06
    그걸 조건에 걸리는 곳에다 넣고 다시 그리기를 하세요.

    GridDrawCell 안에서 REct 를 구하지 말고..

    조건이 걸리는 때 있죠?

    if (조건) then

    begin

    Rect := StringGrid1.CellRect(ACol, ARow); //답변해주신 부분

    StringGrid1.Canvas.BrushCopy(Rect,

    bmpFalse, dRect,clBtnFace); //bmpFalse 는 Bitmap 이미지

    end;



    GridDrawCell 안에 다시 그리는 걸 넣어면 아무 소용이 없어요.

    조건이 걸릴때 if 문 안에서 넣어주면 됩니다..

    마우스 클릭하면 DrawCell 메시지를 주니까 그때 다시 그린겁니다.

    마우스 클릭안해도 되게 하려면 OnDrawCell 은 필요없고 그림바뀌는 조건있죠?

    그때 바로 해줘야 되요..





    진현주 wrote:

    > stringgrid에서 이미지를 삽입하고, 다시 로그할때 다른것으로 바꾸는 건데,

    > 마우스로 클릭해야만 바뀌는 현상입니다.

    > 별짓을 다 해봐도 안되는군요,

    > 소스는 아래와 같습니다.

    >

    > procedure TfrmMain.gridDrawCell(Sender: TObject; ACol, ARow: Integer;

    > Rect: TRect; State: TGridDrawState);

    > var LeftPos,i: Integer;

    > dRect: TRect;

    > begin

    > if (ACol = 2) then begin

    >

    > Rect := (Sender as TStringGrid).CellRect(ACol, ARow); //답변해주신 부분

    > dRect := Classes.Rect(0,0, (Rect.Right-Rect.Left), rect.Bottom-rect.Top);

    >

    > if (조건) then begin

    > (Sender as TStringGrid).Canvas.BrushCopy(Rect,

    > bmpFalse, dRect,clBtnFace); //bmpFalse 는 Bitmap 이미지

    > end

    > else (Sender as TStringGrid).Canvas.BrushCopy(Rect, bmpTrue,

    > dRect,clBtnFace);

    > end;

    > end;

    >

    > 위 소스에서 처음에 bmpTrue를 화면에 보입니다. 그러다 조건에 거리면 bmpFalse로

    > 바뀌어야 하는데, 정말 정말 안됩니다.

    > 제발 도와 주십시요.

    >