wwrcdpnl.pas
来自「infopower 4000 for delphi 2006」· PAS 代码 · 共 1,684 行 · 第 1/5 页
PAS
1,684 行
begin
if ((rvopShortenEditBox in Options) or
(rvopConsistentEditWidth in Options) or
(not isSingleLineEditControl(TWinControl(Control)))) then
if (Width>FixedEditWidth) then
begin
Width:= FixedEditWidth;
end;
end
end
end
end;
if ((rvopShortenEditBox in Options) or
(rvopConsistentEditWidth in Options)) then
MaxEditWidth:= wwMin(MaxEditWidth, FixedEditWidth)
else begin
MaxEditWidth:= 0;
for j:= 0 to ControlPositions.count-1 do
begin
cp:= TControlPosition(ControlPositions[j]);
MaxEditWidth:= wwMax(MaxEditWidth, cp.width);
end
end
end
else ShowingVertScrollBar:= False;
HorzScrollBar.Margin:= 6;
if (rvopConsistentEditWidth in Options) then
HorzScrollBar.Range := MaxEditWidth
else begin
HorzScrollBar.Range :=
EditStartOffset + MaxEditWidth + Margin.RightOffset;
if ShowingVertScrollBar then
HorzScrollBar.Range:=
HorzScrollBar.Range - GetSystemMetrics(SM_CXHThumb);
end;
for i:= 0 to ControlPositions.count-1 do
begin
cp:= TControlPosition(ControlPositions[i]);
with cp do
begin
if (Control is TWinControl) then
SetWindowPos ((control as TWinControl).Handle, 0,
left, top, width, height, SWP_NOACTIVATE)
else
control.SetBounds(left, top, width, height);
end
end;
BackgroundImage:= False; // 8/7/00
for i:= 0 to ControlCount-1 do
begin
if (Controls[i] is TGraphicControl) and
not (Controls[i] is TLabel) then
begin
BackgroundImage:=True;
end
end;
for i:= 0 to ControlCount-1 do
begin
Controls[i].visible:= True;
if Patch[1] and EditFrame.enabled and EditFrame.Transparent and BackgroundImage then
Update; // 8/6/00 - Need to complete imager painting if present
end;
{ Set focus to first wincontrol }
{ if Focused and Recreate then
begin
for i:= 0 to ControlCount-1 do
begin
if Controls[i] is TWinControl then
begin
TWinControl(Controls[i]).setFocus;
break;
end
end;
end
}
finally
Bitmap.Free;
for i:= 0 to ControlPositions.count-1 do TControlPosition(ControlPositions[i]).Free;
ControlPositions.Clear;
end;
end;
function TwwRecordViewPanel.IsSingleLineEditControl(EditControl: TWinControl): boolean;
begin
result:= ((EditControl is TwwDBEdit) or (EditControl is TwwDBDateTimePicker));
end;
Procedure TwwRecordViewPanel.DisplayHorizontal(Recreate: boolean);
const FixedEditWidthConst=0;
var
OrigMaxEditWidth, MaxEditWidth: integer;
APos, i, j, numFields: integer;
curFieldDisplayWidth: integer;
curFieldEditWidth: integer;
curFieldLabelWidth: integer;
curFieldDisplayLabel: wwSmallString;
curFieldReadOnly: boolean;
RealMaxLineWidth, MaxLineWidth,curLineWidth: integer;
LastEditHeight:integer;
LastLabelHeight:integer;
curField: TField;
curLabel: Tlabel;
customEdit: TWinControl;
wwDbEdit: TwwDBEdit;
checkbox: TwwDBCheckBox;
FixedEditWidth: integer;
accept: boolean;
PrevTop: integer;
checkboxOn, checkboxOff: wwSmallString;
Bitmap: TBitmap;
curEditControl: TControl;
NextTabOrder: integer;
TempWidth: integer;
TempControlCount: integer;
PanelWidth: integer;
ControlPositionLeft, ControlPositionTop,
ControlPositionWidth, ControlPositionHeight: integer;
cp: TControlPosition;
EditControl: TWinControl;
ShowingVertScrollBar: boolean;
OldWidth: integer;
BackgroundImage: boolean;
Function GetControlPosition(control: TControl): TControlPosition;
var i: integer;
begin
result:= nil;
for i:= 0 to ControlPositions.count-1 do
if TControlPosition(ControlPositions[i]).Control=control then
result:= TControlPosition(ControlPositions[i]);
end;
procedure UpdateTopPosition(Height: integer; var TopPosition: integer);
begin
if (rvopLabelsBeneathControl in Options) and (style=rvpsHorizontal) then
begin
TopPosition:= GetControlPosition(curLabel).Top;
GetControlPosition(curLabel).Top:=
TopPosition + Height + EditSpacing.HorizontalView.BetweenLabelEdit-1;
end
end;
Function CreateEditControl(EditControl: TWinControl): boolean;
var
tempMask: string;
tempAutoFill: boolean;
tempUsePictureMask: boolean;
begin
result:= False;
{ 1/5/2000 - Fix bug with picture masks for non wwdatasets }
if EditControl is TwwDBCustomEdit then
begin
if wwGetPictureControl(self)=self then { Picture masks do not come from dataset }
begin
wwPictureByField(self, curField.FieldName, False,
tempMask, tempAutoFill, tempUsePictureMask);
with TwwDBEdit(EditControl).Picture do
begin
PictureMaskFromDataSet:= False;
PictureMask:= tempMask;
AutoFill:=tempAutoFill;
end
end
end;
with EditControl do begin
if recreate then begin
curLabel.FocusControl:= EditControl;
visible:= False;
parent:= self;
if not wwSetControlDataSource(EditControl, self.datasource) then exit;
if not wwSetControlDataField(EditControl, curField.fieldName) then exit;
if curFieldReadonly or curField.calculated then
begin
TEdit(EditControl).color:= ReadOnlyColor;
EditControl.tabStop:= False;
end;
if (EditControl is TwwDBEdit) then
begin
if curField is TStringField then {7/29/97 - Limit length to field size }
if curField.editmask='' then // 9/9/02
TEdit(EditControl).maxlength:= curField.Size;
end;
end;
ControlPositionleft:= EditStartOffset+curLineWidth;
ControlPositiontop:= PrevTop+EditSpacing.HorizontalView.BetweenLabelEdit+curlabel.Height;
TempWidth:= (curFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3;
if EditControl is TwwDBDateTimePicker then
begin
TempWidth:=
TempWidth + TwwDBDateTimePicker(EditControl).Button.Width
end;
if not IsSingleLineEditControl(EditControl) then
begin
if (rvopMaximizeMemoWidth in Options) then begin
ControlPositionleft:= EditStartOffset;
ControlPositionTop:= PrevTop+EditSpacing.HorizontalView.BetweenLabelEdit+curlabel.Height;
TempWidth:= wwMax(OrigMaxEditWidth, FixedEditWidth);
end
end;
if (rvopShortenEditBox in Options) and (TempWidth>FixedEditWidth) then
TempWidth:= FixedEditWidth;
if IsSingleLineEditControl(EditControl) then
ControlPositionHeight:= EditControl.Height
else
ControlPositionHeight:= Bitmap.Canvas.TextHeight('0') * LinesPerMemoControl + 8; {2 lines of Memo}
if Recreate and CurFieldReadOnly then enabled:=False;
end;
if not Recreate then begin
ControlPositionWidth:= TempWidth;
ControlPositionHeight:= EditControl.Height;
UpdateTopPosition(ControlPositionHeight, ControlPositionTop);
AddControlPosition(EditControl, ControlPositionLeft, ControlPositionTop,
ControlPositionWidth, ControlPositionHeight);
end
else begin
EditControl.Left:= ControlPositionLeft;
EditControl.Top:= ControlPositionTop;
EditControl.Height:= ControlPositionHeight;
OldWidth:= EditControl.Width; { 10/22/98 }
DoOnAfterCreateControl(self, curField, EditControl);
if EditControl.Width<>OldWidth then { 10/22/98 }
TempWidth:= EditControl.Width;
if (rvopShortenEditBox in Options) and (TempWidth>FixedEditWidth) then
TempWidth:= FixedEditWidth;
EditControl.Width:= TempWidth;
end;
curFieldEditWidth:= TempWidth;
MaxEditWidth:= wwmax(MaxEditWidth, TempWidth);
LastEditHeight:= wwMax(LastEditHeight, EditControl.Height);
EditControl.tabOrder:= NextTabOrder; {9/3/98 - Fix tab order problem }
inc(NextTabOrder);
result:= True;
if recreate then curField.FreeNotification(self);
end;
begin
tempControlCount:= 0;
for i:= 0 to ControlCount-1 do
if Controls[i].owner=self then inc(TempControlCount);
if TempControlCount=0 then Recreate:= True;
if FDataLink.Active or (DataSource=Nil) or (Datasource.dataset=Nil) then
begin
if (Recreate) then FreeNonCustomControls(True);
if (DataSource=nil) or (Datasource.dataset=nil) then exit;
end
else begin
// if (Recreate) then FreeNonCustomControls; { If inactive then don't show controls }
exit;
end;
PrevTop:= Margin.TopOffset;
if (selected.count=0) then numFields:= DataSource.DataSet.FieldCount
else numFields:= Selected.count;
Bitmap:= TBitmap.create;
ControlPositions.Clear;
try
Bitmap.Canvas.Font := Font;
{ Compute desired form length }
MaxEditWidth:= 0;
RealMaxLineWidth:= 0;
curFieldDisplayWidth:= 0;
for i:= 0 to numFields-1 do begin
if (Selected.count=0)then
begin
curField:= DataSource.dataset.fields[i];
curFieldDisplayWidth:= curField.DisplayWidth;
curFieldReadOnly:= curfield.ReadOnly;
end
else begin
APos:= 1;
curField:= DataSource.dataset.findField(strGetToken(Selected[i], #9, APos));
if curfield<>nil then begin
curFieldDisplayWidth:= strToInt(strGetToken(Selected[i], #9, APos));
strGetToken(Selected[i], #9, APos); { Display label }
curFieldReadOnly := (strGetToken(Selected[i], #9, APos) = 'T')
end
end;
if not ShowField(curfield, curFieldReadOnly) then continue;
MaxEditWidth:= wwmax(MaxEditWidth,
(CurFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3);
end;
OrigMaxEditWidth:= MaxEditWidth;
{ Limit form length }
EditStartOffset:= Margin.LeftOffset;
MaxEditWidth:= 0;
lastEditHeight := 0;
lastLabelHeight := 0;
CurLineWidth:= 0;
NextTabOrder:= 0;
FixedEditWidth:= Width - (EditStartOffset + Margin.RightOffset + FixedEditWidthConst);
if BorderStyle=bsSingle then FixedEditWidth:= FixedEditWidth - 4;
MaxLineWidth:= FixedEditWidth;
// MinEditHeight:= 21;
for i:= 0 to numFields-1 do begin
APos:= 1;
if (Selected.count=0) or FUseTFields then
begin
curField:= DataSource.dataset.fields[i];
curFieldDisplayWidth:= curfield.DisplayWidth;
curFieldDisplayLabel:= curField.displayLabel;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?