rm_insp.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,244 行 · 第 1/3 页
PAS
1,244 行
tmp := TRMPictureEditorForm.Create(nil);
try
tmp.PictureTypes := ' (*.bmp)|*.bmp';
tmp.Picture.Assign(TBitmap(GetOrdValue(0)));
if tmp.ShowModal = mrOK then
SetOrdValue(Longint(tmp.Picture.Bitmap));
finally
tmp.Free;
end;
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ TRMInspForm }
procedure TRMInspForm.OnGetEditorClassEvent(Sender: TObject;
AInstance: TPersistent; APropInfo: PPropInfo; var AEditorClass: TELPropEditorClass);
begin
aEditorClass := nil;
if aPropInfo.PropType^.Kind = tkMethod then
begin
aEditorClass := TMethodEditor;
end;
end;
constructor TRMInspForm.Create(AOwner: TComponent);
procedure _RegisterPropEditor;
var
i: Integer;
liItem: TRMAddinPropEditor;
begin
FInsp.RegisterPropEditor(TypeInfo(TStrings), nil, 'Memo', TStringsPropEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'ChildBand', TChildBandEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBandHeader, 'DataBandName', TGroupHeaderBandEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBandFooter, 'DataBandName', TGroupHeaderBandEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBandGroupHeader, 'MasterBandName', TGroupHeaderBandEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBandGroupFooter, 'GroupHeaderBandName', TGroupFooterBandEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBandDetailData, 'MasterBandName', TGroupHeaderBandEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMCustomBandView, 'DataSetName', TDataSetEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBandCrossData, 'DataSource', TCrossDataBandDataSourceEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBandGroupHeader, 'GroupCondition', TGroupConditionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcMemoView, 'ResultExpression', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'PrintCondition', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'NewPageCondition', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'OutlineText', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(TRMHighlight), TRMCustomMemoView, 'Highlight', THighlightEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMHighlight, 'Condition', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'ShiftWith', TShiftWithEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'StretchWith', TShiftWithEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'ShiftRelativeTo', TShiftWithEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'DataField', TDataFieldEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMRepeatedOptions, 'MasterMemoView', TMasterMemoViewEditor);
FInsp.RegisterPropEditor(TypeInfo(string), nil, 'DisplayFormat', TDisplayFormatEditor);
FInsp.RegisterPropEditor(TypeInfo(TRMCalcOptions), TRMCalcMemoView, 'CalcOptions', TCalcOptionsEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'Filter', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'IntalizeValue', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'AggregateValue', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'AggrBandName', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'ResetGroupName', TExpressionEditor);
FInsp.RegisterPropEditor(TypeInfo(TPicture), TRMPictureView, 'Picture', TPictureView_PictureEditor);
FInsp.RegisterPropEditor(TypeInfo(TPicture), TRMReportPage, 'BackPicture', TPageBackPictureEditor);
FInsp.RegisterPropEditor(TypeInfo(TPicture), nil, 'Picture', TPicturePropEditor);
FInsp.RegisterPropEditor(TypeInfo(TBitmap), nil, '', TBitmappropEditor);
if FAddinPropEditors <> nil then
begin
for i := 0 to FAddinPropEditors.Count - 1 do
begin
liItem := FAddinPropEditors[i];
with liItem do
FInsp.RegisterPropEditor(TypeInfo, ObjectClass, PropName, EditorClass);
end;
end;
end;
begin
inherited Create(AOwner);
FPanelTop := TPanel.Create(Self);
FPanelTop.Parent := Self;
FPanelTop.Align := alTop;
FPanelTop.Height := 26;
FPanelTop.BevelOuter := bvNone;
FcmbObjects := TComboBox.Create(Self);
with FcmbObjects do
begin
Parent := FPanelTop;
SetBounds(0, 2, 21, 169);
Style := csOwnerDrawFixed;
DropDownCount := 12;
ItemHeight := 15;
Sorted := True;
OnClick := cmbObjectsClick;
OnDrawItem := cmbObjectsDrawItem;
OnDropDown := cmbObjectsDropDown;
end;
FTab := TTabControl.Create(Self);
with FTab do
begin
Parent := Self;
HotTrack := True;
Align := alClient;
OnChange := OnTabChangeEvent;
end;
FInsp := TELPropertyInspector.Create(Self);
with FInsp do
begin
Parent := FTab;
Align := alClient;
OnClick := Insp_OnClick;
OnGetEditorClass := OnGetEditorClassEvent;
end;
_RegisterPropEditor;
FSplitter1 := TSplitter.Create(Self);
with FSplitter1 do
begin
Parent := Self;
Align := alBottom;
Cursor := crVSplit;
end;
FPanelBottom := TPanel.Create(Self);
with FPanelBottom do
begin
Parent := Self;
Align := alBottom;
Height := 54;
BevelOuter := bvNone;
BorderWidth := 2;
end;
FPanel2 := TPanel.Create(Self);
with FPanel2 do
begin
Parent := FPanelBottom;
SetBounds(2, 2, 172, 50);
Align := alClient;
BevelOuter := bvLowered;
OnResize := Panel2Resize;
end;
FLabelTitle := TLabel.Create(Self);
with FLabelTitle do
begin
Parent := FPanel2;
SetBounds(6, 1, 155, 13);
AutoSize := False;
end;
FLabelCommon := TLabel.Create(Self);
with FLabelCommon do
begin
Parent := FPanel2;
SetBounds(12, 17, 154, 28);
AutoSize := False;
Color := clBtnFace;
WordWrap := True;
end;
{$IFDEF USE_TB2k}
Parent := TWinControl(AOwner);
Floating := True;
{$ENDIF}
FullSize := False;
CloseButtonWhenDocked := True;
UseLastDock := False;
SetBounds(438, 179, 184, 308);
FSaveHeight := ClientHeight;
OnResize := OnResizeEvent;
OnVisibleChanged := OnVisibleChangedEvent;
OnMove := OnMoveEvent;
OnResizeEvent(nil);
Localize;
end;
destructor TRMInspForm.Destroy;
begin
inherited Destroy;
end;
procedure TRMInspForm.SetCurReport(aObject: TObject);
begin
FCurReport := TRMReport(aObject);
end;
procedure TRMInspForm.Localize;
begin
Font.Name := RMLoadStr(SRMDefaultFontName);
Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
Font.Charset := StrToInt(RMLoadStr(SCharset));
FInsp.Font.Assign(Font);
RMSetStrProp(Self, 'Caption', rmRes + 70);
Tab.Tabs.Add(RMLoadStr(rmRes + 71));
Tab.Tabs.Add(RMLoadStr(rmRes + 72));
FLabelCommon.Font.Color := clBlue;
end;
procedure TRMInspForm.BeginUpdate;
begin
FInsp.BeginUpdate;
end;
procedure TRMInspForm.EndUpdate;
begin
FInsp.EndUpdate;
Insp_OnClick(nil);
end;
procedure TRMInspForm.AddObject(aObject: TPersistent);
begin
FInsp.Add(aObject);
end;
procedure TRMInspForm.ClearObjects;
begin
FInsp.Clear;
end;
procedure TRMInspForm.SetCurrentObject(aClassName, s: string);
begin
if (FcmbObjects.ItemIndex < 0) or (FcmbObjects.Items[FcmbObjects.ItemIndex] <> s) then
begin
FCurObjectClassName := aClassName;
cmbObjectsDropDown(nil);
FcmbObjects.ItemIndex := FcmbObjects.Items.IndexOf(s);
end;
end;
procedure TRMInspForm.cmbObjectsDropDown(Sender: TObject);
var
s: string;
begin
if FcmbObjects.ItemIndex <> -1 then
s := FcmbObjects.Items[FcmbObjects.ItemIndex]
else
s := '';
if Assigned(FOnGetObjects) then
FOnGetObjects(FcmbObjects.Items);
FcmbObjects.ItemIndex := FcmbObjects.Items.IndexOf(s);
end;
procedure TRMInspForm.cmbObjectsClick(Sender: TObject);
begin
if Assigned(FOnSelectionChanged) then
FOnSelectionChanged(FcmbObjects.Items[FcmbObjects.ItemIndex]);
end;
procedure TRMInspForm.cmbObjectsDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with FcmbObjects.Canvas do
begin
FillRect(Rect);
if FcmbObjects.DroppedDown then
TextOut(Rect.Left + 2, Rect.Top + 1, FcmbObjects.Items[Index])
else
TextOut(Rect.Left + 2, Rect.Top + 1, FcmbObjects.Items[Index] + ': ' + FCurObjectClassName);
end;
end;
procedure TRMInspForm.OnResizeEvent(Sender: TObject);
begin
FSaveHeight := ClientHeight;
FcmbObjects.Width := ClientWidth;
end;
procedure TRMInspForm.OnVisibleChangedEvent(Sender: TObject);
begin
end;
function TRMInspForm.GetSplitterPos: Integer;
begin
Result := FInsp.Splitter;
end;
procedure TRMInspForm.SetSplitterPos(Value: Integer);
begin
if (Value > 10) and (Value < FInsp.ClientWidth - 10) then
begin
FInsp.Splitter := Value;
end;
end;
function TRMInspForm.GetSplitterPos1: Integer;
begin
Result := FInsp.Height;
end;
procedure TRMInspForm.SetSplitterPos1(Value: Integer);
begin
FInsp.Height := Value;
end;
procedure TRMInspForm.OnTabChangeEvent(Sender: TObject);
begin
BeginUpdate;
if FTab.TabIndex = 0 then
FInsp.PropKinds := [pkProperties]
else
FInsp.PropKinds := [pkEvents];
EndUpdate;
end;
procedure TRMInspForm.WMLButtonDBLCLK(var Message: TWMNCLButtonDown);
var
liSaveHeight: Integer;
begin
FInsp.ClosePopup;
if ClientHeight > 0 then
begin
liSaveHeight := ClientHeight;
ClientHeight := 0;
FSaveHeight := liSaveHeight;
end
else
ClientHeight := FSaveHeight;
end;
procedure TRMInspForm.RestorePos;
begin
if ClientHeight > 0 then
begin
end
else
ClientHeight := FSaveHeight;
end;
procedure TRMInspForm.WMRButtonDBLCLK(var Message: TWMNCRButtonDown);
var
liSaveHeight: Integer;
begin
FInsp.ClosePopup;
if ClientHeight > 0 then
begin
liSaveHeight := ClientHeight;
ClientHeight := 0;
FSaveHeight := liSaveHeight;
end
else
ClientHeight := FSaveHeight;
end;
procedure TRMInspForm.OnMoveEvent(Sender: TObject);
begin
FInsp.ClosePopup;
end;
procedure TRMInspForm.Panel2Resize(Sender: TObject);
begin
FLabelTitle.Width := FPanel2.ClientWidth - FLabelTitle.Left - 2;
FLabelCommon.Width := FPanel2.ClientWidth - FLabelCommon.Left - 2;
FLabelCommon.Height := FPanel2.ClientHeight - FLabelCommon.Top - 2;
end;
procedure TRMInspForm.Insp_OnClick(Sender: TObject);
var
lActiveItem: TELPropsPageItem;
begin
lActiveItem := FInsp.ActiveItem;
if lActiveItem = nil then
begin
FLabelTitle.Caption := '';
FLabelCommon.Caption := '';
end
else
begin
if RMLocalizedPropertyNames then
FLabelTitle.Caption := lActiveItem.VirtualCaption
else
FLabelTitle.Caption := lActiveItem.Caption;
FLabelCommon.Caption := lActiveItem.PropCommon;
end;
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
procedure ClearPropeditors;
var
i: Integer;
begin
if FAddinPropEditors <> nil then
begin
for i := 0 to FAddinPropEditors.Count - 1 do
begin
TRMAddinPropEditor(FAddinPropEditors[i]).Free;
end;
FAddinPropEditors.Clear;
end;
end;
initialization
finalization
if FAddinPropEditors <> nil then
begin
ClearPropeditors;
FAddinPropEditors.Free;
FAddinPropEditors := nil;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?