아래 소스는 BitBtn1을 누르면 스트링그리드에 프로그램의 각 폼 이름과 첵크박스를 나타내는 소스입니다.
델파이 7 소스인데요... 뭐 만족하지는 않지만 그럭저럭 사용하고 있습니다.
문제는 Win32탭의 XPManifest1을 폼에 가져다 놓고 하면 평상시 1~3초면 되던것이
1분이 걸려도 안 끝납니다. 조 아래 StringGrid1DrawCell 이벤트가 문제 인듯 한데요...
어찌 해결 할 수 있을까요? XP스타일 된다고 좋아하다가 이것 땜시 못쓰고 있습니다.
procedure TMe030F.BitBtn1Click(Sender: TObject);
var i,j,k,y : integer;
Mchk,Uchk : string;
begin
StringGrid1.Cells[0, 0] := ' ';
StringGrid1.Cells[1, 0] := ' 메 뉴'; //Title을 나타낸다
StringGrid1.Cells[2, 0] := ' 메뉴이름';
StringGrid1.Cells[3, 0] := '판매시스템';
StringGrid1.Cells[4, 0] := '통합시스템';
StringGrid1.ColWidths[0] := 20;
StringGrid1.ColWidths[1] := 300;
StringGrid1.ColWidths[2] := 80;
StringGrid1.ColWidths[3] := 80;
StringGrid1.ColWidths[4] := 80;
//StringGrid1.ColCount := Fieldcount; //그리드 컬럼수 지정
StringGrid1.Rowcount := 1;//그리드 레코드수 지정
k := 0;
for i := 1 to MainFm.MainMenu1.items.count -1 do begin
for j := 0 to MainFm.MainMenu1.items[i].Count -1 do begin
if MainFm.MainMenu1.Items[i].Items[j].Caption = '-' then continue;
inc(K);
StringGrid1.Rowcount := StringGrid1.Rowcount+1;
StringGrid1.Cells[0, k] := IntToStr(K);
StringGrid1.Cells[1, k] := MainFm.MainMenu1.Items[i].Items[j].Caption;
StringGrid1.Cells[2, k] := MainFm.MainMenu1.Items[i].Items[j].Name;
end;
end;
//첵크박스를 나타낸다
for y := 1 to StringGrid1.RowCount -1 do begin
StringGrid1.Objects[3,y] := TcheckBox.Create(StringGrid1);
with DataMd.SQLcode do begin
close;
sql.Clear;
sql.add('select * from tr020t');
sql.add('where tr_kubn = '''+TR_prog+''' ');
sql.add(' and tr_name = :p_name ');
parambyname('p_name').asstring := Trim(StringGrid1.Cells[2, y]);
open;
if FieldByname('tr_mypg').asstring = 'N' then
Mchk := 'N' else
Mchk := 'Y';
if FieldByname('tr_unit').asstring = 'N' then
Uchk := 'N' else
Uchk := 'Y';
end;
with TCheckBox(StringGrid1.Objects[3,y]) do begin
OnMouseUp := CheckBoxMouseUp;
Parent := StringGrid1;
BoundsRect := StringGrid1.CellRect(3, y);
Width := 20;//StringGrid1.ColWidths[1];
Height := StringGrid1.RowHeights[1];
Caption := '';
if Mchk = 'N' then
Checked := True else
Checked := False;
end;
if Copy(StringGrid1.Cells[2,y],1,2) = 'Tr' then Continue;
if Copy(StringGrid1.Cells[2,y],1,2) = 'Ae' then Continue;
StringGrid1.Objects[4,y] := TcheckBox.Create(StringGrid1);
with TCheckBox(StringGrid1.Objects[4,y]) do begin
OnMouseUp := CheckBoxMouseUp;
Parent := StringGrid1;
BoundsRect := StringGrid1.CellRect(4, y);
Width := 20;//StringGrid1.ColWidths[1];
Height := StringGrid1.RowHeights[1];
Caption := '';
if Uchk = 'N' then
Checked := True else
Checked := False;
end;
end;
end;
procedure TMe030F.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var i : integer;
begin
with Sender as TStringGrid do begin
//타이틀에 색을 나타낸다
//if (ACol = 0) and (ARow < 4) then
if (ARow = 0) and (ARow <= 4) then begin
Canvas.Font.Size := 10;
Canvas.Font.Name := '굴림';
Canvas.Brush.Color := clSilver;
end;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left + 3, Rect.Top+6 , Cells[ACol, ARow]);
end;
//스트링그리드가 변할때 첵크박스를 같이 변하게 해준다.
for i := 1 to StringGrid1.RowCount-1 do begin
if StringGrid1.objects[3,i] <> nil then begin
Rect:=StringGrid1.cellrect(3,i);
TCheckBox(StringGrid1.objects[3 ,i]).top := Rect.Top;
TCheckBox(StringGrid1.objects[3 ,i]).Left := Rect.Left+30;
if (Rect.Top<=0)then
TCheckBox(StringGrid1.objects[3 ,i]).Visible := False
else begin
TCheckBox(StringGrid1.objects[3 ,i]).Visible := True;
end;
TCheckBox(StringGrid1.objects[3 ,i]).Refresh;
end;
if StringGrid1.objects[4,i] <> nil then begin
Rect:=StringGrid1.cellrect(4,i);
TCheckBox(StringGrid1.objects[4 ,i]).top := Rect.Top;
TCheckBox(StringGrid1.objects[4 ,i]).Left := Rect.Left+30;
if (Rect.Top<=0)then
TCheckBox(StringGrid1.objects[4 ,i]).Visible := False
else begin
TCheckBox(StringGrid1.objects[4 ,i]).Visible := True;
end;
TCheckBox(StringGrid1.objects[4 ,i]).Refresh;
end;
end;
end;