旱
旱秧田
Unregistered / Unconfirmed
GUEST, unregistred user!
自已做了了个控件,将数个控件集中在一起,代码如下:
unit TjPanel;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls,StdCtrls,ComCtrls,Grids;
const
WM_ButtonClick = WM_App+1;
type
TDownButton = class(TButton)
public
LinkCol:Integer;
LinkRow:Integer;
constructor Create(AOwner: TComponent); override;
procedure ButtonClick(Sender:TObject);
end;
TDownButtons = array of array of TDownButton;
TTjPanel = class(TPanel)
ZbLabel : TLabel;
lbJcrq: TLabel;
dtJcrq: TDateTimePicker;
lbDoctor : TLabel;
edDoctor : TEdit;
lbXj : TLabel;
edXj : TEdit;
InputGrid:TStringGrid;
SelectList:TListBox;
private
FZbCode : integer;
FZbCaption:String;
FRowCount:Integer;
FSelectCol,FSelectRow:Integer;
FSelectStrings:TStringList;
FedDoctorExit:TNotifyEvent;
FInputGridDrawCell:TDrawCellEvent;
Function GetDownButtonVisible(ACol,ARow:Integer):Boolean;
procedure SetDownButtonVisible(ACol,ARow:Integer;Status:boolean);
procedure SetSelectStrings(Value:TStringList);
public
ItemCodeList:array of array of Integer;
ResultList:array of array of String;
DownButtons:TDownButtons;
constructor Create(AOwner: TComponent); override;
procedure CreateDownButton;
procedure InputGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure InputGridResize(Sender:TObject);
procedure SetZbCaption(ZbCaption:String);
procedure DownButtonClick(var Msg:TMessage);Message WM_ButtonClick;
procedure MyButtonClick(Sender:TObject);
procedure edDoctorExit(Sender:TObject);
procedure SelectListExit(Sender:TObject);
procedure SelectListClick(Sender:TObject);
procedure RemerberResult;
procedure SetRowCount(NewCount:Integer);
property DownButtonVisible[ACol,ARow:Integer]:boolean read GetDownButtonVisible write SetDownButtonVisible;
published
property ZbCode:Integer read FZbCode write FZbCode;
property ZbCaption:String read FZbCaption write SetZbCaption;
property RowCount:Integer read FRowCount write SetRowCount;
property SelectStrings:TStringList read FSelectStrings write SetSelectStrings;
property OnedDoctorExit:TNotifyEvent read FedDoctorExit write FedDoctorExit;
property OnInputGridDrawCell:TDrawCellEvent read FInputGridDrawCell write FInputGridDrawCell;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples',[TTjPanel]);
end;
constructor TDownButton.Create(AOwner: TComponent);
begin
inherited ;
Caption := '▼';
Width := 18;
Font.Size := 9;
OnClick := ButtonClick;{此处指定OnClick过程}
end;
procedure TDownButton.ButtonClick(Sender:TObject);
begin
showmessage('2');{这个过程根本没进入}
SendMessage(TWinControl(TDownButton(Sender).Owner).Handle,WM_ButtonClick,LinkCol,LinkRow);
end;
procedure TTjPanel.CreateDownButton;
var
i,j:Integer;
begin
for i := 0 to Length(DownButtons)-1 do
for j := 0 to Length(DownButtons)-1 do
DownButtons[i,j].Free;
with InputGrid do
begin
SetLength(DownButtons,2);
SetLength(DownButtons[0],RowCount-1);
SetLength(DownButtons[1],RowCount-1);
for i := 0 to RowCount-2 do
begin
DownButtons[0,i] := TDownButton.Create(Self);
DownButtons[0,i].Parent := InputGrid;{???此处如果InputGrid改为Self,则OnClick事件能得到响应,
但是这样,当网格滚动时,小按钮会显示不正常}
DownButtons[0,i].Left := -100;
DownButtons[0,i].Top := -100;
DownButtons[1,i] := TDownButton.Create(Self);
DownButtons[1,i].Parent := InputGrid;
DownButtons[1,i].Left := -100;
DownButtons[1,i].Top := -100;
end;
end;
end;
constructor TTjPanel.Create(AOwner: TComponent);
var
tmpTop : Integer;
i,j : Integer;
begin
inherited Create(AOwner);
ZbLabel := TLabel.Create(Application);
with ZbLabel do
begin
Parent := Self;
Left := 10;
Top := 10;
Font.Name := '宋体';
Font.Size := 20;
tmpTop := Top+(Height div 2)-5;
end;
lbJcrq := TLabel.Create(Application);
with lbJcrq do
begin
Parent := Self;
Caption := '检查日期';
Left := ZbLabel.Left+ZbLabel.Width+40;
Top := tmpTop-(Height div 2);
end;
dtJcrq := TDateTimePicker.Create(Self);
with dtJcrq do
begin
Parent := Self;
Date := Date;
Left := lbJcrq.Left+lbJcrq.Width+20;
Top := tmpTop-(Height div 2);
end;
lbDoctor := TLabel.Create(Self);
with lbDoctor do
begin
Parent := Self;
lbDoctor.Caption := '医生';
Left := dtJcrq.Left+dtJcrq.Width+40;
Top := tmpTop-(Height div 2);
end;
edDoctor := TEdit.Create(Application);
with edDoctor do
begin
Parent := Self;
Left :=lbDoctor.Left+lbDoctor.Width+10;
Top := tmpTop-(Height div 2);
OnExit := edDoctorExit;
end;
InputGrid := TStringGrid.Create(Self);
with InputGrid do
begin
Parent := Self;
ScrollBars := ssBoth;
DefaultRowHeight := 24;
Left :=ZbLabel.Left;
Top := ZbLabel.Top+ZbLabel.Height+10;
Height := 400;
Width := 580;
OnDrawCell := InputGridDrawCell;
RowCount := 15;
ColCount := 4;
FixedCols := 0;
CreateDownButton;
Cells[0,0] := '项目';
Cells[1,0] := '结果';
Cells[2,0] := '项目';
Cells[3,0] := '结果';
SetLength(ItemCodeList,ColCount);
for i := 0 to ColCount-1 do
begin
SetLength(ItemCodeList,RowCount-1);
for j := 0 to RowCount-2 do
ItemCodeList[i,j] := -1;
end;
SetLength(ResultList,ColCount);
for i := 0 to ColCount-1 do
begin
SetLength(ResultList,RowCount-1);
for j := 0 to RowCount-2 do
ResultList[i,j] := '';
end;
end;
lbXj := TLabel.Create(Self);
with lbXj do
begin
Parent := Self;
Caption := '小结';
Left := InputGrid.Left;
Top := InputGrid.Top+InputGrid.Height+20;
end;
edXj := TEdit.Create(Self);
with edXj do
begin
Parent := Self;
Left := lbXj.Left+lbXj.Width+2;
Top := lbXj.Top;
Width := (InputGrid.Left+InputGrid.Width)-Left;
end;
FSelectStrings := TStringList.Create;
SelectList := TListBox.Create(Self);
with SelectList do
begin
Visible := False;
Parent := Self;
OnExit := SelectListExit;
OnClick := SelectListClick;
end;
OnResize := InputGridResize;
end;
procedure TTjPanel.SetZbCaption(ZbCaption:String);
begin
FZbCaption := ZbCaption;
ZbLabel.Caption := FZbCaption;
end;
procedure TTjPanel.DownButtonClick(var Msg:TMessage);
var
Rect : TRect;
Point : TPoint;
DownButton : TDownButton;
begin
DownButton := DownButtons[(Msg.WParam div 2),(Msg.LParam-1)];
Showmessage('1');
with DownButton do
begin
FSelectCol := LinkCol;
FSelectRow := LinkRow;
end;
with SelectList do
begin
Visible := True;
Rect := InputGrid.CellRect(FSelectCol,FSelectRow);
Point.x := Rect.Left;
Point.y := Rect.Top;
Point := Self.ScreenToClient(InputGrid.ClientToScreen(Point));
Width := Rect.Right-Rect.Left;
Height := InputGrid.Height div 2;
Left := Point.x;
Top := Point.y+(Rect.Bottom-Rect.Top)+2;
if Top+Height > InputGrid.Top+InputGrid.Height then
Top := Top-Height-(Rect.Bottom-Rect.Top)-2;
end;
end;
procedure TTjPanel.MyButtonClick(Sender:TObject);
begin
ShowMessage('bai');
end;
procedure TTjPanel.SetRowCount(NewCount:Integer);
begin
if NewCount <= InputGrid.FixedRows then
Exit;
FRowCount := NewCount;
InputGrid.RowCount := FRowCount;
CreateDownButton;
end;
Function TTjPanel.GetDownButtonVisible(ACol,ARow:Integer):Boolean;
begin
Result := False;
if (ACol < 0) or(ARow < 0 ) then
Exit;
if (ACol mod 2) = 0 then
Exit;
if (ACol div 2) > (Length(DownButtons)-1) then
Exit;
if ARow > Length(DownButtons[0]) then
Exit;
Result := DownButtons[(ACol div 2),ARow-1].Visible;
end;
procedure TTjPanel.SetDownButtonVisible(ACol,ARow:Integer;Status:boolean);
begin
if (ACol < 0) or(ARow < 0 ) then
Exit;
if (ACol mod 2) = 0 then
Exit;
if (ACol div 2) > (Length(DownButtons)-1) then
Exit;
if ARow > Length(DownButtons[0]) then
Exit;
DownButtons[(ACol div 2),ARow-1].Visible := Status;
end;
procedure TTjPanel.SetSelectStrings(Value:TStringList);
begin
FSelectStrings.Assign(Value);
SelectList.Items.Assign(Value);
end;
procedure TTjPanel.edDoctorExit(Sender:TObject);
begin
if Assigned(FedDoctorExit) then
FedDoctorExit(Sender);
end;
procedure TTjPanel.SelectListExit(Sender:TObject);
begin
SelectList.Visible := False;
end;
procedure TTjPanel.SelectListClick(Sender:TObject);
var
i : integer;
begin
with SelectList do
for i := 0 to Items.Count-1 do
if Selected then
begin
InputGrid.Cells[FSelectCol,FSelectRow] := Items;
InputGrid.SetFocus;
InputGrid.Col := FSelectCol;
InputGrid.Row := FSelectRow;
end;
end;
procedure TTjPanel.InputGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
tmpLeft : Integer;
tmpTop : Integer;
Point:TPoint;
DownButton : TDownButton;
begin
with TStringGrid(Sender) do
begin
if gdFixed in State then
begin
Canvas.Brush.Color := clTeal;
Canvas.Font.Size := 11;
Canvas.Font.Color := clYellow;
end
else
begin
Case ACol of
0,2 :
begin
Canvas.Brush.Color := clInfoBk;
Canvas.Font.Color := clWindowText;
end;
else
begin
Canvas.Brush.Color := clWindow;
DownButton := DownButtons[(ACol div 2),ARow-1];
DownButton.Height :=Rect.Bottom-Rect.Top;
DownButton.Top := Rect.Top;
DownButton.Left := Rect.Left+(Rect.Right-Rect.Left)-DownButton.Width;
{Point.x := Rect.Left;
Point.y := Rect.Top;
Point := Self.ScreenToClient(ClientToScreen(Point));
DownButton.Top := Point.y;
DownButton.Left := Point.x+(Rect.Right-Rect.Left)-DownButton.Width; }
DownButton.LinkCol := ACol;
DownButton.LinkRow := ARow;
end;
end;
Canvas.Font.Size := 9;
end;
Canvas.FillRect(Rect);
//标题栏置中
if gdFixed in State then
tmpLeft := Rect.Left+(Rect.Right-Rect.Left-Canvas.TextWidth(Cells[ACol,ARow])) div 2
else
tmpLeft := Rect.Left+3;
//end
tmpTop := Rect.Top+(Rect.Bottom-Rect.Top-Canvas.TextHeight(Cells[ACol,ARow])) div 2;
Canvas.TextOut(tmpLeft,tmpTop,Cells[ACol,ARow]);
end;
if Assigned(FInputGridDrawCell) then
FInputGridDrawCell(Sender,ACol,ARow,Rect,State);
end;
procedure TTjPanel.InputGridResize(Sender:TObject);
begin
with InputGrid do
begin
Height := Self.Height-100;
Width := Self.Width-10;
ColWidths[0] := (Width div 18)*5-8;
ColWidths[1] := (Width div 9)*2-8;
ColWidths[2] := (Width div 18)*5-8;
ColWidths[3] := (Width div 9)*2-8;
lbXj.Left := InputGrid.Left;
lbXj.Top := InputGrid.Top+InputGrid.Height+20;
edXj.Left := lbXj.Left+lbXj.Width+5;
edXj.Top := lbXj.Top;
edXj.Width := (Left+Width)-edXj.Left;
lbJcrq.Left := ZbLabel.Left+ZbLabel.Width+40;
dtJcrq.Left := lbJcrq.Left+lbJcrq.Width+5;
lbDoctor.Left := dtJcrq.Left+dtJcrq.Width+40;
edDoctor.Left :=lbDoctor.Left+lbDoctor.Width+5;
Repaint;
end;
end;
procedure TTjPanel.RemerberResult;
var
co,ro : Integer;
begin
with InputGrid do
begin
for co := 0 to ColCount -1 do
for ro := 1 to RowCount-1 do
if (co mod 2) = 0 then
ResultList[co,ro-1] := ''
else
ResultList[co,ro-1] := Trim(Cells[co,ro]);
end;
end;
end.
{,如何又要按钮显示正常,OnClick事件又能得到响应?}
unit TjPanel;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls,StdCtrls,ComCtrls,Grids;
const
WM_ButtonClick = WM_App+1;
type
TDownButton = class(TButton)
public
LinkCol:Integer;
LinkRow:Integer;
constructor Create(AOwner: TComponent); override;
procedure ButtonClick(Sender:TObject);
end;
TDownButtons = array of array of TDownButton;
TTjPanel = class(TPanel)
ZbLabel : TLabel;
lbJcrq: TLabel;
dtJcrq: TDateTimePicker;
lbDoctor : TLabel;
edDoctor : TEdit;
lbXj : TLabel;
edXj : TEdit;
InputGrid:TStringGrid;
SelectList:TListBox;
private
FZbCode : integer;
FZbCaption:String;
FRowCount:Integer;
FSelectCol,FSelectRow:Integer;
FSelectStrings:TStringList;
FedDoctorExit:TNotifyEvent;
FInputGridDrawCell:TDrawCellEvent;
Function GetDownButtonVisible(ACol,ARow:Integer):Boolean;
procedure SetDownButtonVisible(ACol,ARow:Integer;Status:boolean);
procedure SetSelectStrings(Value:TStringList);
public
ItemCodeList:array of array of Integer;
ResultList:array of array of String;
DownButtons:TDownButtons;
constructor Create(AOwner: TComponent); override;
procedure CreateDownButton;
procedure InputGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure InputGridResize(Sender:TObject);
procedure SetZbCaption(ZbCaption:String);
procedure DownButtonClick(var Msg:TMessage);Message WM_ButtonClick;
procedure MyButtonClick(Sender:TObject);
procedure edDoctorExit(Sender:TObject);
procedure SelectListExit(Sender:TObject);
procedure SelectListClick(Sender:TObject);
procedure RemerberResult;
procedure SetRowCount(NewCount:Integer);
property DownButtonVisible[ACol,ARow:Integer]:boolean read GetDownButtonVisible write SetDownButtonVisible;
published
property ZbCode:Integer read FZbCode write FZbCode;
property ZbCaption:String read FZbCaption write SetZbCaption;
property RowCount:Integer read FRowCount write SetRowCount;
property SelectStrings:TStringList read FSelectStrings write SetSelectStrings;
property OnedDoctorExit:TNotifyEvent read FedDoctorExit write FedDoctorExit;
property OnInputGridDrawCell:TDrawCellEvent read FInputGridDrawCell write FInputGridDrawCell;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples',[TTjPanel]);
end;
constructor TDownButton.Create(AOwner: TComponent);
begin
inherited ;
Caption := '▼';
Width := 18;
Font.Size := 9;
OnClick := ButtonClick;{此处指定OnClick过程}
end;
procedure TDownButton.ButtonClick(Sender:TObject);
begin
showmessage('2');{这个过程根本没进入}
SendMessage(TWinControl(TDownButton(Sender).Owner).Handle,WM_ButtonClick,LinkCol,LinkRow);
end;
procedure TTjPanel.CreateDownButton;
var
i,j:Integer;
begin
for i := 0 to Length(DownButtons)-1 do
for j := 0 to Length(DownButtons)-1 do
DownButtons[i,j].Free;
with InputGrid do
begin
SetLength(DownButtons,2);
SetLength(DownButtons[0],RowCount-1);
SetLength(DownButtons[1],RowCount-1);
for i := 0 to RowCount-2 do
begin
DownButtons[0,i] := TDownButton.Create(Self);
DownButtons[0,i].Parent := InputGrid;{???此处如果InputGrid改为Self,则OnClick事件能得到响应,
但是这样,当网格滚动时,小按钮会显示不正常}
DownButtons[0,i].Left := -100;
DownButtons[0,i].Top := -100;
DownButtons[1,i] := TDownButton.Create(Self);
DownButtons[1,i].Parent := InputGrid;
DownButtons[1,i].Left := -100;
DownButtons[1,i].Top := -100;
end;
end;
end;
constructor TTjPanel.Create(AOwner: TComponent);
var
tmpTop : Integer;
i,j : Integer;
begin
inherited Create(AOwner);
ZbLabel := TLabel.Create(Application);
with ZbLabel do
begin
Parent := Self;
Left := 10;
Top := 10;
Font.Name := '宋体';
Font.Size := 20;
tmpTop := Top+(Height div 2)-5;
end;
lbJcrq := TLabel.Create(Application);
with lbJcrq do
begin
Parent := Self;
Caption := '检查日期';
Left := ZbLabel.Left+ZbLabel.Width+40;
Top := tmpTop-(Height div 2);
end;
dtJcrq := TDateTimePicker.Create(Self);
with dtJcrq do
begin
Parent := Self;
Date := Date;
Left := lbJcrq.Left+lbJcrq.Width+20;
Top := tmpTop-(Height div 2);
end;
lbDoctor := TLabel.Create(Self);
with lbDoctor do
begin
Parent := Self;
lbDoctor.Caption := '医生';
Left := dtJcrq.Left+dtJcrq.Width+40;
Top := tmpTop-(Height div 2);
end;
edDoctor := TEdit.Create(Application);
with edDoctor do
begin
Parent := Self;
Left :=lbDoctor.Left+lbDoctor.Width+10;
Top := tmpTop-(Height div 2);
OnExit := edDoctorExit;
end;
InputGrid := TStringGrid.Create(Self);
with InputGrid do
begin
Parent := Self;
ScrollBars := ssBoth;
DefaultRowHeight := 24;
Left :=ZbLabel.Left;
Top := ZbLabel.Top+ZbLabel.Height+10;
Height := 400;
Width := 580;
OnDrawCell := InputGridDrawCell;
RowCount := 15;
ColCount := 4;
FixedCols := 0;
CreateDownButton;
Cells[0,0] := '项目';
Cells[1,0] := '结果';
Cells[2,0] := '项目';
Cells[3,0] := '结果';
SetLength(ItemCodeList,ColCount);
for i := 0 to ColCount-1 do
begin
SetLength(ItemCodeList,RowCount-1);
for j := 0 to RowCount-2 do
ItemCodeList[i,j] := -1;
end;
SetLength(ResultList,ColCount);
for i := 0 to ColCount-1 do
begin
SetLength(ResultList,RowCount-1);
for j := 0 to RowCount-2 do
ResultList[i,j] := '';
end;
end;
lbXj := TLabel.Create(Self);
with lbXj do
begin
Parent := Self;
Caption := '小结';
Left := InputGrid.Left;
Top := InputGrid.Top+InputGrid.Height+20;
end;
edXj := TEdit.Create(Self);
with edXj do
begin
Parent := Self;
Left := lbXj.Left+lbXj.Width+2;
Top := lbXj.Top;
Width := (InputGrid.Left+InputGrid.Width)-Left;
end;
FSelectStrings := TStringList.Create;
SelectList := TListBox.Create(Self);
with SelectList do
begin
Visible := False;
Parent := Self;
OnExit := SelectListExit;
OnClick := SelectListClick;
end;
OnResize := InputGridResize;
end;
procedure TTjPanel.SetZbCaption(ZbCaption:String);
begin
FZbCaption := ZbCaption;
ZbLabel.Caption := FZbCaption;
end;
procedure TTjPanel.DownButtonClick(var Msg:TMessage);
var
Rect : TRect;
Point : TPoint;
DownButton : TDownButton;
begin
DownButton := DownButtons[(Msg.WParam div 2),(Msg.LParam-1)];
Showmessage('1');
with DownButton do
begin
FSelectCol := LinkCol;
FSelectRow := LinkRow;
end;
with SelectList do
begin
Visible := True;
Rect := InputGrid.CellRect(FSelectCol,FSelectRow);
Point.x := Rect.Left;
Point.y := Rect.Top;
Point := Self.ScreenToClient(InputGrid.ClientToScreen(Point));
Width := Rect.Right-Rect.Left;
Height := InputGrid.Height div 2;
Left := Point.x;
Top := Point.y+(Rect.Bottom-Rect.Top)+2;
if Top+Height > InputGrid.Top+InputGrid.Height then
Top := Top-Height-(Rect.Bottom-Rect.Top)-2;
end;
end;
procedure TTjPanel.MyButtonClick(Sender:TObject);
begin
ShowMessage('bai');
end;
procedure TTjPanel.SetRowCount(NewCount:Integer);
begin
if NewCount <= InputGrid.FixedRows then
Exit;
FRowCount := NewCount;
InputGrid.RowCount := FRowCount;
CreateDownButton;
end;
Function TTjPanel.GetDownButtonVisible(ACol,ARow:Integer):Boolean;
begin
Result := False;
if (ACol < 0) or(ARow < 0 ) then
Exit;
if (ACol mod 2) = 0 then
Exit;
if (ACol div 2) > (Length(DownButtons)-1) then
Exit;
if ARow > Length(DownButtons[0]) then
Exit;
Result := DownButtons[(ACol div 2),ARow-1].Visible;
end;
procedure TTjPanel.SetDownButtonVisible(ACol,ARow:Integer;Status:boolean);
begin
if (ACol < 0) or(ARow < 0 ) then
Exit;
if (ACol mod 2) = 0 then
Exit;
if (ACol div 2) > (Length(DownButtons)-1) then
Exit;
if ARow > Length(DownButtons[0]) then
Exit;
DownButtons[(ACol div 2),ARow-1].Visible := Status;
end;
procedure TTjPanel.SetSelectStrings(Value:TStringList);
begin
FSelectStrings.Assign(Value);
SelectList.Items.Assign(Value);
end;
procedure TTjPanel.edDoctorExit(Sender:TObject);
begin
if Assigned(FedDoctorExit) then
FedDoctorExit(Sender);
end;
procedure TTjPanel.SelectListExit(Sender:TObject);
begin
SelectList.Visible := False;
end;
procedure TTjPanel.SelectListClick(Sender:TObject);
var
i : integer;
begin
with SelectList do
for i := 0 to Items.Count-1 do
if Selected then
begin
InputGrid.Cells[FSelectCol,FSelectRow] := Items;
InputGrid.SetFocus;
InputGrid.Col := FSelectCol;
InputGrid.Row := FSelectRow;
end;
end;
procedure TTjPanel.InputGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
tmpLeft : Integer;
tmpTop : Integer;
Point:TPoint;
DownButton : TDownButton;
begin
with TStringGrid(Sender) do
begin
if gdFixed in State then
begin
Canvas.Brush.Color := clTeal;
Canvas.Font.Size := 11;
Canvas.Font.Color := clYellow;
end
else
begin
Case ACol of
0,2 :
begin
Canvas.Brush.Color := clInfoBk;
Canvas.Font.Color := clWindowText;
end;
else
begin
Canvas.Brush.Color := clWindow;
DownButton := DownButtons[(ACol div 2),ARow-1];
DownButton.Height :=Rect.Bottom-Rect.Top;
DownButton.Top := Rect.Top;
DownButton.Left := Rect.Left+(Rect.Right-Rect.Left)-DownButton.Width;
{Point.x := Rect.Left;
Point.y := Rect.Top;
Point := Self.ScreenToClient(ClientToScreen(Point));
DownButton.Top := Point.y;
DownButton.Left := Point.x+(Rect.Right-Rect.Left)-DownButton.Width; }
DownButton.LinkCol := ACol;
DownButton.LinkRow := ARow;
end;
end;
Canvas.Font.Size := 9;
end;
Canvas.FillRect(Rect);
//标题栏置中
if gdFixed in State then
tmpLeft := Rect.Left+(Rect.Right-Rect.Left-Canvas.TextWidth(Cells[ACol,ARow])) div 2
else
tmpLeft := Rect.Left+3;
//end
tmpTop := Rect.Top+(Rect.Bottom-Rect.Top-Canvas.TextHeight(Cells[ACol,ARow])) div 2;
Canvas.TextOut(tmpLeft,tmpTop,Cells[ACol,ARow]);
end;
if Assigned(FInputGridDrawCell) then
FInputGridDrawCell(Sender,ACol,ARow,Rect,State);
end;
procedure TTjPanel.InputGridResize(Sender:TObject);
begin
with InputGrid do
begin
Height := Self.Height-100;
Width := Self.Width-10;
ColWidths[0] := (Width div 18)*5-8;
ColWidths[1] := (Width div 9)*2-8;
ColWidths[2] := (Width div 18)*5-8;
ColWidths[3] := (Width div 9)*2-8;
lbXj.Left := InputGrid.Left;
lbXj.Top := InputGrid.Top+InputGrid.Height+20;
edXj.Left := lbXj.Left+lbXj.Width+5;
edXj.Top := lbXj.Top;
edXj.Width := (Left+Width)-edXj.Left;
lbJcrq.Left := ZbLabel.Left+ZbLabel.Width+40;
dtJcrq.Left := lbJcrq.Left+lbJcrq.Width+5;
lbDoctor.Left := dtJcrq.Left+dtJcrq.Width+40;
edDoctor.Left :=lbDoctor.Left+lbDoctor.Width+5;
Repaint;
end;
end;
procedure TTjPanel.RemerberResult;
var
co,ro : Integer;
begin
with InputGrid do
begin
for co := 0 to ColCount -1 do
for ro := 1 to RowCount-1 do
if (co mod 2) = 0 then
ResultList[co,ro-1] := ''
else
ResultList[co,ro-1] := Trim(Cells[co,ro]);
end;
end;
end.
{,如何又要按钮显示正常,OnClick事件又能得到响应?}