안녕하세요..
마우스 휠로 움직이게 하는 예제는 발견을 해서... 적용을 했는데..
마우스로 직접 스크롤을 붙잡고... A 그리드든 B 그리드든 위 아래로 움직이면.. 다른 그리드에서 같이 움직이며..
서로 같은 데이터가 표시 되게 하고 싶거든요..
왼쪽은 중요한 데이터 5칸이 표시되고.. 오른쪽은 그 중요 데이터의 금액들이 항목별로 정리되어 쭈욱 나오는데.. 많아요..
그래서.. 왼쪽 그리드의 스크롤을 마우스로 선택해서 움직일때가 문제가 되더군요..
방법이 없을까요?
부탁드립니다..
답변 감사드립니다..
늘 도움 주셔서 정말 감사합니다.
많은 도움이 되었습니다.. ^^
Window Procedure를 이용해서 scroll메시지를 다른쪽에 보내세요.
아래는 예제입니다.
type TForm1 = class(TForm) GridA: TStringGrid; GridB: TStringGrid; procedure FormCreate(Sender: TObject); private EventRaiser: TObject; GridA_OrgWndProc, GridB_OrgWndProc: TWndMethod; public procedure GridA_WndProc(var Message: TMessage); procedure GridB_WndProc(var Message: TMessage); end; implementation procedure TForm1.FormCreate(Sender: TObject); var Col, Row: Integer; begin for Row := 0 to 64 - 1 do begin for Col := 0 to 64 - 1 do begin GridA.Cells[Col, Row] := IntToStr(Row) +'*'+ IntToStr(Col) +'='+IntToStr(Col*Row); GridB.Cells[Col, Row] := IntToStr(Row) +'*'+ IntToStr(Col) +'='+IntToStr(Col*Row); end; end; EventRaiser := nil; GridA_OrgWndProc := GridA.WindowProc; GridB_OrgWndProc := GridB.WindowProc; GridA.WindowProc := GridA_WndProc; GridB.WindowProc := GridB_WndProc; end; procedure TForm1.GridA_WndProc(var Message: TMessage); begin if (Message.Msg = WM_VSCROLL) and (EventRaiser = nil) then begin EventRaiser := GridA; GridB.Perform(Message.Msg, Message.WParam, Message.LParam); EventRaiser := nil; end; GridA_OrgWndProc(Message); end; procedure TForm1.GridB_WndProc(var Message: TMessage); begin if (Message.Msg = WM_VSCROLL) and (EventRaiser = nil) then begin EventRaiser := GridB; GridA.Perform(Message.Msg, Message.WParam, Message.LParam); EventRaiser := nil; end; GridB_OrgWndProc(Message); end;