적절한 제목을 결정하기가 힘드네요
StringGrid 옵션에서 goRowSelect를 true 로 해 놓으면
같은 Row에 전체 Column이 선택됩니다.
아래와 같이
그런데 문제는
다음그림과 같이 Column이 많아서 가로로 죽 Scroll해서 뒷쪽에 보고있다가
마우스로 다른 row를 클릭하면 다른 Row가 선택되면서
다음 그림처럼 HScroll이 맨 앞으로 가 버립니다.
뒷쪽 컬럼을 보고 싶으면 다시 scroll해야하는 불편함이 있죠
옛날에 어떤 프로그램을 만들때 고객이 불편하다고 했었는데
원래 그런거라고 대충 얼버무린 기억이...
오늘 델마당에 누가 질문해서 한번 만들어 봤습니다.
http://www.delmadang.com/community/bbs_view.asp?bbsNo=17&page=&bbsCat=&st=&keyword=&indx=408108
//delphi 버젼
TStringGrid = class (Grids.TStringGrid)
protected
procedure WndProc(var Message: TMessage); override;
end;
implementation
procedure TStringGrid.WndProc(var Message: TMessage);
var
MMsg: TWMMouse;
ARow,ACol: Integer;
iShiftKey: Smallint;
begin
if (Message.Msg=WM_LBUTTONDOWN) then
begin
MMsg:=TWMMouse(Message);
MouseToCell(MMsg.XPos,MMsg.YPos,ACol,ARow);
iShiftKey:=GetKeyState(VK_SHIFT);
if(ARow<>Row) and ( goRowSelect in self.Options ) and (iShiftKey>=0) then
begin
self.Options:=self.Options-[goRowSelect];
self.FocusCell(self.LeftCol, ARow, true);
self.Options:=self.Options+[goRowSelect];
Exit;
end;
end;
inherited;
end;
그런데 C++Builder에서는 델파이와 똑같이 하니까 select에 약간 문제가 있더군요
그래서 좀더 심플하게 아래와 같이 햇습니다.
가끔 약간 껌벅거리는 현상이 나타나기도 합니다만 별로 표가 많이 나지는 않습니다.
class TStringGrid : public Grids::TStringGrid
{
virtual void __fastcall WndProc(Messages::TMessage &Message)
{
TWMMouse MMsg ;
int ARow,ACol;
Smallint iShiftKey;
if(Message.Msg==WM_LBUTTONDOWN)
{
memcpy(&MMsg,&Message,sizeof(MMsg));
MouseToCell(MMsg.XPos,MMsg.YPos,ACol,ARow);
iShiftKey=GetKeyState(VK_SHIFT);
if( (ARow!=Row) && Options.Contains(goRowSelect) && (iShiftKey>=0))
{
int iLeftCol=this->LeftCol;
Grids::TStringGrid::WndProc(Message);
this->LeftCol=iLeftCol;
return;
}
}
Grids::TStringGrid::WndProc(Message);
}
};
#define TStringGrid ::TStringGrid
그럼..
|