📄 wwrcdvw.pas
字号:
TwwCustomControlItem=class
control: TWinControl;
Left, Top, Width, Height: integer;
OldParent: TWinControl;
OldVisible: boolean;
ButtonFlat, ButtonTransparent: boolean;
end;
{ function wwIsCustomEditCell(
Component: TComponent;
ownerForm: TComponent;
curField: TField;
var customEdit: TCustomEdit) : boolean;
}
function wwIsCheckBox(Component: TComponent;
curField: TField; var checkboxOn, checkboxOff: string): boolean;
var
wwRecordViewForm: TwwRecordViewForm;
implementation
uses
{$ifdef wwDelphi6Up}
variants,
{$endif}
wwdbgrid;
const Spacing=13;
// FixedEditWidthConst=20;
{$R *.DFM}
type
{TwwRecordViewScrollbox = class(TScrollBox)
private
Dialog: TwwRecordViewDialog;
FCanvas: TControlCanvas;
protected
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
public
destructor Destroy; override;
end;
}
TwwMemoDialogPopup = class(TwwMemoDialog)
private
Field: TField;
protected
procedure DoInitDialog; override;
public
MemoControl: TCustomEdit; //wwDBMemo;
end;
procedure TwwDBMemo.KeyDown(var key: word; shift: TShiftState);
var curField: TField;
begin
inherited; {9/27/98 }
if (key=vk_f2) then begin
curField:= datasource.dataset.findField(datafield);
if curField<>Nil then begin
with TwwMemoDialogPopup.create(self) do begin
Field:= curField;
datasource:= self.datasource;
dataField:= curfield.fieldName;
caption:= dataField;
MemoControl:= Self;
{7/19/97 - Don't show cancel button in memodialog if readonly }
if curfield.readonly or
((curfield.dataset is TTable) and (curField.dataset as TTable).readonly) then
MemoAttributes:= MemoAttributes + [mViewOnly];
if modified then
curfield.assign(self.Lines); {Flush to tfield }
Execute;
Free;
end;
key:= 0;
end
end
end;
constructor TwwDBEditMemo.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
AutoSize:= False;
WantReturns := True;
WordWrap:= True;
AutoSelect:= False;
end;
procedure TwwDBEditMemo.KeyDown(var key: word; shift: TShiftState);
var curField: TField;
begin
inherited; {9/27/98 }
if (key=vk_f2) then begin
curField:= datasource.dataset.findField(datafield);
if curField<>Nil then begin
with TwwMemoDialogPopup.create(self) do begin
datasource:= self.datasource;
dataField:= curfield.fieldName;
caption:= dataField;
MemoControl:= Self;
Field:= curField;
{7/19/97 - Don't show cancel button in memodialog if readonly }
if curfield.readonly or
((curfield.dataset is TTable) and (curField.dataset as TTable).readonly) then
MemoAttributes:= MemoAttributes + [mViewOnly];
if modified then
UpdateRecord;
Execute;
Free;
end;
key:= 0;
end
end
end;
procedure TwwMemoDialogPopup.DoInitDialog;
begin
Form.Memo.selStart:= MemoControl.selStart;
Form.Memo.Font.Assign(TEdit(MemoControl).Font);
// Form.Caption := MemoControl.Field.DisplayLabel; {7/21/97}
Form.Caption := Field.DisplayLabel; {7/21/97}
end;
function wwIsCheckBox(Component: TComponent;
curField: TField; var checkboxOn, checkboxOff: string): boolean;
var fldName: string;
i: integer;
parts : TStrings;
controlType: TStrings;
begin
result:= False;
fldName:= curField.fieldName;
parts:= TStringList.create;
controlType:= nil; { 6/22/99 - ADO datasets store in component, not dataset }
if wwGetControlInfoInDataSet(Component) then
controlType:= wwGetControlType(curfield.dataset);
if controlType=nil then
controlType:= wwGetControlType(Component);
for i:= 0 to ControlType.count-1 do begin
strBreakapart(controlType[i], ';', parts);
if parts.count<4 then continue;
if parts[0]<>fldName then continue;
if parts[1]='CheckBox' then begin
CheckBoxOn:= parts[2];
CheckBoxOff:= parts[3];
result:= True;
break;
end
end;
parts.free;
end;
constructor TwwRecordViewDialog.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FixedEditWidthConst:=20;
Patch:= VarArrayCreate([0, 0], varVariant);
Patch[0]:= False; { Set to True to preserve old behavior of ignoreing maximizememowidth with vertical display}
FDataLink:= TDataLink.create;
FEditSpacing:= TwwEditSpacing.create;
with FEditSpacing do begin
VerticalView:= TwwVertEditSpacing.create;
VerticalView.BetweenRow:= 2;
VerticalView.BetweenLabelEdit:= 5;
VerticalView.Owner:= nil;
HorizontalView:= TwwHorzEditSpacing.create;
HorizontalView.BetweenRow:= 2;
HorizontalView.BetweenLabelEdit:= 1;
HorizontalView.BetweenEditsInRow:= 5;
HorizontalView.LabelIndent:= 1;
HorizontalView.Owner:= nil;
end;
FMargin:= TwwMargin.create;
with FMargin do begin
LeftOffset:= 5;
RightOffset:=5;
TopOffset:= 5;
BottomOffset:=5;
Owner:= nil;
end;
FFormPosition:= TwwFormPosition.create;
with FFormPosition do begin
Left:= 0; { Auto-center }
Top:= 0; { Auto-center }
Width:= 0; { Auto-size }
Height:= 0; { Auto-size }
end;
FOptions:= [rvoShortenEditBox, rvoUseCustomControls, rvoModalForm, rvoConfirmCancel,
rvoCloseIsCancel, rvoMaximizeMemoWidth, rvoUseDateTimePicker];
FOKCancelOptions:= [rvokShowOKCancel, rvokAutoPostRec, rvokAutoCancelRec];
FFont := TFont.Create;
FLabelFont:= TFont.create;
FControlList:= TList.create;
FLabelList:= TList.create;
FCaption:= 'Record View';
FReadOnlyColor:= clInactiveCaptionText;
FStyle:= rvsVertical;
FSelected:= TStringList.create;
FUseTFields:= False;
FNavigatorFlat := True;
// FNavigatorVisibleButtons:= [nbFirst,nbPrior,nbNext,nbLast,
// nbInsert,nbDelete,nbEdit,nbPost,
// nbCancel,nbRefresh];
FNavigatorButtons := [nbsFirst, nbsPrior, nbsNext, nbsLast,
nbsInsert, nbsDelete, nbsEdit, nbsPost, nbsCancel, nbsRefresh,
nbsNextPage, nbsPriorPage, nbsSaveBookmark, nbsRestoreBookmark];
CloseAction := rvcControlMenuClose;
CustomControlList:= TList.create;
BorderStyle:= bsSizeable;
FControlType:= TStringList.create;
FControlInfoInDataset:= True;
FPictureMasks:= TStringList.create;
FPictureMaskFromDataSet:= True;
FLinesPerMemoControl:= 2;
FDefaultEditFrame:= TwwEditFrame.create(self);
end;
destructor TwwEditSpacing.Destroy;
begin
FHorizontalView.Free;
FVerticalView.Free;
inherited destroy;
end;
destructor TwwRecordViewDialog.Destroy;
var i: integer;
begin
FDefaultEditFrame.Free;
if not (csDestroying in Application.ComponentState) then
RecordViewForm.Free;
RecordViewForm:= Nil;
FDataLink.free;
FDataLink:= nil;
FEditSpacing.Free;
FMargin.Free;
FFormPosition.Free;
FFont.Free;
FLabelFont.Free;
FControlList.Free;
FLabelList.Free;
FSelected.Free;
for i:= 0 to CustomControlList.count-1 do TwwCustomControlItem(CustomControlList[i]).Free;
CustomControlList.Free;
CustomControlList:= nil; // 10/5/00
FControlType.Free;
FPictureMasks.Free;
inherited destroy;
end;
procedure TwwRecordViewDialog.SetDataSource(value : TDataSource);
begin
FDataLink.dataSource:= value;
end;
Function TwwRecordViewDialog.getDataSource: TDataSource;
begin
Result:= FdataLink.dataSource as TDataSource;
end;
procedure TwwRecordViewDialog.setFont(val: TFont);
begin
FFont.assign(Val);
end;
procedure TwwRecordViewDialog.setLabelFont(val: TFont);
begin
FLabelFont.assign(Val);
end;
Function TwwRecordViewDialog.ShowField(field: TField; curFieldReadOnly: boolean): boolean;
begin
if field=nil then result:= False
else if (rvoHideReadOnly in Options) and curFieldReadOnly then result:= False
else if (rvoHideCalculated in Options) and field.calculated then result:= False
else result:= True;
end;
procedure TwwRecordViewDialog.FormShow(Sender: TObject);
var i: integer;
begin
if (rvoLabelsBeneathControl in Options) and (Style=rvsHorizontal) then
begin
for i:= 0 to FControlList.count-1 do begin
curLabel:= TLabel(FLabelList[i]);
curLabel.top:=
TControl(FControlList[i]).Top +
TControl(FControlList[i]).height +
EditSpacing.HorizontalView.BetweenLabelEdit-1;
end;
end;
DoInitDialog(Sender as TwwRecordViewForm);
Screen.cursor:= crDefault;
end;
function TwwRecordViewDialog.IsControlModified(Control: TWinControl): boolean;
begin
result:= SendMessage(Control.Handle, EM_GETMODIFY, 0, 0)=1;
end;
procedure TwwRecordViewForm.KeyDown(var Key: Word; Shift: TShiftState);
var Dlg: TwwRecordViewDialog;
Function GetWantReturns(Control: TControl): boolean;
var PropInfo: PPropInfo;
begin
Result:= False;
PropInfo:= Typinfo.GetPropInfo(Control.ClassInfo,'WantReturns');
if PropInfo<>Nil then
result:= Boolean(GetOrdProp(Control, PropInfo))
else if Control is TCustomMemo then
result:= TMemo(Control).wantReturns
else if Control is TwwDBEditMemo then
result:= TwwDBEditMemo(Control).wantReturns;
end;
Function GetWantTabs(Control: TControl): boolean;
var PropInfo: PPropInfo;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -