📄 fdmain.pas.svn-base
字号:
if Value<>FTransparentChildren then
begin
FTransparentChildren:=Value;
if FActive and IsTransparent(Control) then Control:=nil;
end;
end;
procedure TCustomFormDesigner.DrawSelectRect;
var
SR: TRect;
begin
if Assigned(ParentForm) then
with FCanvas do
begin
Handle:=GetDCEx(ParentForm.Handle,0,DCX_CACHE or DCX_CLIPSIBLINGS);
try
with Pen do
begin
Style:=psSolid;
Mode:=pmXor;
Width:=1;
Style:=psDot;
Color:=clWhite;
end;
Brush.Style:=bsClear;
SR:=FSelectRect;
MapWindowPoints(0,ParentForm.Handle,SR,2);
with SR do Rectangle(Left+1,Top+1,Right,Bottom);
finally
ReleaseDC(0,FCanvas.Handle);
FCanvas.Handle:=0;
end;
end;
end;
procedure TCustomFormDesigner.DrawDragRects;
var
i: Integer;
DR: TRect;
Offset: TPoint;
begin
if not ValidControl(Control) then Exit;
if Assigned(ParentForm) then
with FCanvas do
begin
Handle:=GetDCEx(Control.Parent.Handle,0,DCX_CACHE or DCX_CLIPSIBLINGS or DCX_PARENTCLIP);
try
Offset.X:=FDragRect.Left-Control.Left;
Offset.Y:=FDragRect.Top-Control.Top;
with Control.Parent do
begin
DR:=ClientRect;
if GetParent(ParentForm.Handle)<>0 then
MapWindowPoints(0,GetParent(ParentForm.Handle),DR,2);
end;
with Pen do
begin
Style:=psSolid;
Mode:=pmXor;
Width:=2;
Color:=clGray;
end;
Brush.Style:=bsClear;
for i:=0 to Pred(ControlCount) do
begin
if i=0 then DR:=FDragRect
else
begin
DR:=Controls[i].BoundsRect;
OffsetRect(DR,Offset.X,Offset.Y);
end;
with DR do Rectangle(Left+1,Top+1,Right,Bottom);
end;
finally
ReleaseDC(0,FCanvas.Handle);
FCanvas.Handle:=0;
end;
end;
end;
procedure TCustomFormDesigner.DrawMultiSelect(AControl: TControl);
begin
if Assigned(FGrabHandles) and FGrabHandles.IsGrabHandle(AControl) then Exit;
Application.ProcessMessages;
if ValidControl(AControl) then
if AControl is TWinControl then
with TCanvas.Create do
try
Handle:=GetDC(TWinControl(AControl).Handle);
with Brush do
begin
Style:=bsSolid;
Color:=clGray;
end;
with AControl.ClientRect do
begin
Draw(Left,Top,FMultiGrab);
Draw(Left,Bottom-FGrabSize,FMultiGrab);
Draw(Right-FGrabSize,0,FMultiGrab);
Draw(Right-FGrabSize,Bottom-FGrabSize,FMultiGrab);
end;
finally
ReleaseDC(TWinControl(AControl).Handle,Handle);
Handle:=0;
Free;
end
else
begin
with TControlCanvas.Create do
try
Control:=AControl;
with Brush do
begin
Style:=bsSolid;
Color:=clGray;
end;
with AControl.ClientRect do
begin
Draw(Left,Top,FMultiGrab);
Draw(Left,Bottom-FGrabSize,FMultiGrab);
Draw(Right-FGrabSize,Top,FMultiGrab);
Draw(Right-FGrabSize,Bottom-FGrabSize,FMultiGrab);
end;
finally
Control:=nil;
Free;
end;
Application.ProcessMessages;
end;
end;
function TCustomFormDesigner.InTheList(List: TStrings; AControl: TControl): Boolean;
var
AName: string;
AComponent: TComponent;
begin
if Assigned(List) and ValidControl(AControl) then
begin
Result:=List.IndexOf(AControl.Name)<>-1;
if not Result then
begin
AComponent:=AControl.Owner;
AName:=AControl.Name;
while not Result and Assigned(AComponent) do
begin
AName:=AComponent.Name+'.'+AName;
Result:=List.IndexOf(AName)<>-1;
AComponent:=AComponent.Owner;
end;
end
end
else Result:=False;
end;
procedure TCustomFormDesigner.UpdateGrid;
var
X,Y: Integer;
DotColor: TColor;
begin
if Assigned(ParentForm) then
begin
with FDesignerBrush,Canvas do
begin
if FGridStep<8 then
begin
Width:=FGridStep*8;
Height:=FGridStep*8;
end
else
begin
Width:=FGridStep;
Height:=FGridStep;
end;
if FDesignerColor=clNone then Brush.Color:=ParentForm.Color
else Brush.Color:=FDesignerColor;
Brush.Style:=bsSolid;
FillRect(Rect(0,0,Width,Height));
if FGridColor=clNone then DotColor:=ParentForm.Font.Color
else DotColor:=FGridColor;
if FDisplayGrid then
if FGridStep<8 then
for Y:=0 to Height div FGridStep do
for X:=0 to Height div FGridStep do
Pixels[X*FGridStep,Y*FGridStep]:=DotColor
else Pixels[0,0]:=DotColor;
end;
if FActive then
with ParentForm do
begin
Brush.Bitmap:=nil;
Brush.Bitmap:=FDesignerBrush;
RedrawWindow(Handle,nil,0,RDW_INVALIDATE or RDW_NOCHILDREN or RDW_NOERASE);
end;
end;
end;
procedure TCustomFormDesigner.ShowHint(AHint: string; Mode: THintMode);
var
R: TRect;
P: TPoint;
Offset: Integer;
begin
if FShowMoveSizeHint then
with FHintWindow do
begin
R:=CalcHintRect(255,AHint,nil);
GetCursorPos(P);
if Mode=hmMove then Offset:=18
else Offset:=8;
OffsetRect(R,P.X,P.Y+Offset);
ActivateHint(R,AHint);
end;
end;
procedure TCustomFormDesigner.HideHint;
begin
FHintWindow.ReleaseHandle;
end;
function TCustomFormDesigner.GetControlsOrigin: TPoint;
var
i: Integer;
begin
case ControlCount of
0: Result:=Point(0,0);
1: with Control do Result:=Point(Left,Top);
else
begin
Result:=Point(MaxInt,MaxInt);
for i:=0 to Pred(ControlCount) do
with Controls[i],Result do
begin
if Left<X then X:=Left;
if Top<Y then Y:=Top;
end;
end;
end;
end;
function TCustomFormDesigner.CheckParent(AControl: TControl): Boolean;
var
i: Integer;
begin
Result:=False;
i:=0;
while i<ControlCount do
if (Controls[i].Parent<>AControl.Parent) or
IsLocked(Controls[i]) then
begin
Result:=IsLocked(Controls[i]);
Controls[i].Invalidate;
DeleteControl(Controls[i]);
end
else Inc(i);
if ControlCount=1 then Control.Invalidate;
end;
procedure TCustomFormDesigner.SetArrowCursor;
begin
{$IFNDEF STDCURSORS}
Screen.Cursor:=crArrow;
{$ELSE}
Screen.Cursor:=crDefault;
{$ENDIF}
end;
procedure TCustomFormDesigner.ClearForm;
var
OldActive: Boolean;
begin
OldActive:=Active;
Active:=False;
try
if Assigned(ParentForm) then
with ParentForm do
while ControlCount>0 do Controls[0].Free;
finally
Active:=OldActive;
end;
end;
function TCustomFormDesigner.ValidControl(AControl: TControl): Boolean;
begin
try
Result:=Assigned(AControl) and (AControl.ClassInfo<>nil);
except
Result:=False;
end;
end;
procedure TCustomFormDesigner.CreateContainers;
var
i: Integer;
begin
if FUseContainers then
with ParentForm do
for i:=0 to Pred(ComponentCount) do
if not (Components[i] is TControl) and (Components[i]<>Self) then
TComponentContainer.CreateWithComponent(ParentForm,Components[i]).Parent:=ParentForm;
end;
procedure TCustomFormDesigner.DestroyContainers;
var
i: Integer;
begin
i:=0;
with ParentForm do
while i<ComponentCount do
if Components[i] is TComponentContainer then Components[i].Free
else Inc(i);
end;
{$IFDEF TFDTRIAL}
procedure TCustomFormDesigner.ShowTrialWarning;
begin
MessageBox(
0,
'In the trial version of the component you can select'#13'only the control parented by form, not by another control.',
'Greatis Form Designer - Trial Version',
MB_OK or MB_ICONEXCLAMATION);
end;
{$ENDIF}
procedure TCustomFormDesigner.ListChange(Sender: TObject);
begin
if not (csDesigning in ComponentState) and Active then
try
Update;
except
end;
end;
procedure TCustomFormDesigner.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if not (csDestroying in ComponentState) and (Operation=opRemove) and
(AComponent is TControl) and (ControlIndex(TControl(AComponent))<>-1) then
begin
DeleteControl(TControl(AComponent));
if Assigned(FGrabHandles) then FGrabHandles.Control:=Control;
LeaveMouseAction;
Update;
end;
end;
function TCustomFormDesigner.FindNextControl(GoForward: Boolean): TControl;
var
i,StartIndex: Integer;
CurControl: TControl;
function ParentsVisible(Control: TControl): Boolean;
var
P: TWinControl;
begin
if ValidControl(Control) then
begin
Result:=True;
P:=Control.Parent;
while ValidControl(P) and (P<>ParentForm) do
begin
if not P.Visible then
begin
Result:=False;
Break;
end;
P:=P.Parent;
end;
end
else Result:=False;
end;
begin
Result:=nil;
CurControl:=Control;
if Assigned(ParentForm) then
with ParentForm do
begin
if ValidControl(CurControl) then
if ComponentCount>0 then
begin
for StartIndex:=0 to Pred(ComponentCount) do
if Components[StartIndex]=Control then Break
end
else StartIndex:=-1
else StartIndex:=-1;
if ComponentCount>0 then
begin
if StartIndex=-1 then
if GoForward then StartIndex:=Pred(ComponentCount)
else StartIndex:=0;
i:=StartIndex;
repeat
if GoForward then
begin
Inc(i);
if i=ComponentCount then i:=0;
end
else
begin
if i=0 then i:=ComponentCount;
Dec(i);
end;
if Components[i] is TControl then
begin
CurControl:=TControl(Components[i]);
if not (CurControl is TGrabHandle) and
CurControl.Visible and
ParentsVisible(CurControl) and
not IsTransparent(CurControl) and
not IsProtected(CurControl) and
(CurControl<>Control) then Result:=CurControl;
end;
until (Result<>nil) or (i=StartIndex);
end;
end;
end;
function TCustomFormDesigner.ControlAtPos(AParent: TWinControl; P: TPoint): TControl;
var
i: Integer;
SR: TRect;
begin
Result:=nil;
if AParent=nil then AParent:=ParentForm;
if Assigned(AParent) then
with AParent do
for i:=0 to Pred(ControlCount) do
with Controls[i] do
begin
SR:=BoundsRect;
SR.TopLeft:=ClientToScreen(SR.TopLeft);
SR.BottomRight:=ClientToScreen(SR.BottomRight);
if PtInRect(SR,ClientToScreen(P)) then
begin
Result:=Controls[i];
Break;
end;
end;
end;
function TCustomFormDesigner.FindWinControl(Wnd: HWND): TWinControl;
procedure FindInComponent(Wnd: HWND; Component: TComponent; var Control: TWinControl);
var
i: Integer;
begin
if Assigned(Component) and not Assigned(Control) then
if (Component is TWinControl) then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -