CnPack Forum


 
Subject: 代码输入助手 不能用,与my_ide控件冲突
chenshaizi
新警察
Rank: 1



UID 851
Digest Posts 0
Credits 9
Posts 9
点点分 9
Reading Access 10
Registered 2005-5-19
Status Offline
Post at 2005-8-23 17:13  Profile | Blog | P.M. 
代码输入助手 不能用,与my_ide控件冲突

代码输入助手 不能用,与my_ide控件冲突:
my_ide控件可以自动引藏控件面板和属性窗口,我挺喜欢用的,但两者不兼容,一山不容二虎!

//Add MultiLinePalette function by luyear 20021101
//Add the function to forbid Autohide function by luyear 20021102
unit My_IDE;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, Forms, ComCtrls;

type
TAutoHider = class(TObject)
protected
procedure DelphiOnMessage(var Msg: TMsg; var Handled: Boolean);
procedure MyDockDrop(Sender: TObject; Source: TDragDockObject; X, Y: Integer);
procedure MyDestroy(Sender: TObject);
public
OldDockDrop: TDockDropEvent;
OldDestroy: TNotifyEvent;

Delphi: TApplication;
Bar_Top: TForm;
Bar_Left: TForm;
ObjInspector: TForm;
DockHost: TForm;

Bar_Top_Rect: TRect;
Bar_Left_Rect: TRect;

F_AtTop: Boolean;
F_AtLeft: Boolean;

procedure Init_Bar_Left;
procedure Bar_Left_Visible(val: Boolean);
procedure Bar_Top_Visible(Value: Boolean);
end;

TMultiLinePalette = class //?《摸
public
procedure ResizeComponentPalette(Sender : TObject);
end;

var
AutoHider: TAutoHider;
MultiLinePalette : TMultiLinePalette; //?《跑秖

implementation

{?《}
procedure TMultiLinePalette.ResizeComponentPalette(Sender : TObject);
var
AHeight : integer;
begin
with (Sender as TTabControl) do begin
AHeight := Height + DisplayRect.Top - DisplayRect.Bottom + 29;
Constraints.MinHeight := AHeight;
Parent.Constraints.MaxHeight := AHeight;
end;
end; {ResizeMultiLineComponentPalette}

procedure SetMultiLineComponentPalette(MultiLine : boolean);
var
AppBuilder : TForm;
TabControl : TTabControl;
begin
AppBuilder := TForm(Application.FindComponent('AppBuilder'));
if (AppBuilder <> nil) then begin
TabControl := TTabControl(AppBuilder.FindComponent('TabControl'));
if (TabControl <> nil) then begin
TabControl.MultiLine := MultiLine;
if MultiLine then
TabControl.OnResize := MultiLinePalette.ResizeComponentPalette
else
TabControl.OnResize := nil;
end;
end;
end; {SetMultiLineComponentPalette}


{ TAutoHide }

procedure Restore_Bar_Left;
begin
AutoHider.ObjInspector.OnDockDrop := nil;

if AutoHider.DockHost <> nil then
begin
AutoHider.DockHost.OnDestroy := nil;
end;
AutoHider.Bar_Left.BoundsRect := AutoHider.Bar_Left_Rect;
end;

procedure Restore_Bar_Top;
begin
AutoHider.Bar_Top.BoundsRect := AutoHider.Bar_Top_Rect;
end;

procedure InitAutoHider(Value: Boolean);
begin
if Value then
begin
AutoHider.Delphi := Application;
AutoHider.Bar_Top := TForm(Application.FindComponent('AppBuilder'));
if AutoHider.Bar_Top <> nil then
begin
AutoHider.Bar_Top_Rect := AutoHider.Bar_Top.BoundsRect;

AutoHider.ObjInspector := AutoHider.Bar_Top.FindComponent('PropertyInspector')
as TForm;
AutoHider.Bar_Left_Rect := AutoHider.ObjInspector.BoundsRect;

AutoHider.OldDockDrop := AutoHider.ObjInspector.OnDockDrop;
AutoHider.ObjInspector.OnDockDrop := AutoHider.MyDockDrop;

AutoHider.DockHost := nil;
AutoHider.Init_Bar_Left;

AutoHider.F_AtTop := True;
AutoHider.F_AtLeft := True;
AutoHider.Delphi.OnMessage := AutoHider.DelphiOnMessage;
end;
end
else
begin
Restore_Bar_Left;
Restore_Bar_Top;
end;
end;

procedure TAutoHider.Bar_Top_Visible(Value: Boolean);
begin
if Value = F_AtTop then Exit;

if Value OR (Bar_top.windowstate=wsMaximized) then
begin
Bar_Top.Top := 0;
Bar_Top.Show;
end
else
begin
Bar_Top.Top := -Bar_Top.Height + 3;
end;

F_AtTop := Value;
end;

procedure TAutoHider.Bar_Left_Visible(val: Boolean);
begin
if val = F_AtLeft then Exit;

if val OR (Bar_Left.windowstate=wsMaximized) then
begin
Bar_Left.Left := 0;
Bar_Left.Top := 0;
Bar_Left.Height :=Screen.height;// Screen.WorkAreaHeight; by chenshaizi
Bar_Left.Show;
end
else
begin
Bar_Left.Left := -Bar_Left.Width + 3;
end;

F_AtLeft := val;
end;

procedure TAutoHider.DelphiOnMessage(var Msg: TMsg; var Handled: Boolean);
begin
if not Delphi.Active then Exit;
if (Msg.message = WM_LBUTTONDOWN) then Exit;

if (Msg.message = WM_MOUSEMOVE) or (Msg.message = WM_NCMOUSEMOVE) then
begin
if F_AtTop then
if Mouse.CursorPos.Y > Bar_Top.Height + 50 then
begin
Bar_Top_Visible(False);
end;
if not F_AtTop then
if Mouse.CursorPos.Y < 3 then
begin
Bar_Top_Visible(True);
end;

if F_AtLeft then
if (Mouse.CursorPos.x > Bar_Left.Width + 50) and (not Bar_left.Active) then
begin
Bar_Left_Visible(False);
end;
if not F_AtLeft then
if Mouse.CursorPos.X < 3 then
begin
Bar_Left_Visible(True);
end;
end;
end;

procedure TAutoHider.MyDestroy(Sender: TObject);
begin
if Sender is TApplication then
begin
Bar_Top_Visible(False);
Bar_Left_Visible(False);
end
else
begin
if Assigned(OldDestroy) then OldDestroy(Sender);
DockHost := nil;
Bar_Left := ObjInspector;
end;
end;

procedure TAutoHider.Init_Bar_Left;
begin
if (Delphi.FindComponent('TabDockHostForm') as TForm) <> nil then
DockHost := Delphi.FindComponent('TabDockHostForm') as TForm
else if (Delphi.FindComponent('JoinDockForm') as TForm) <> nil then
DockHost := Delphi.FindComponent('JoinDockForm') as TForm;

if DockHost <> nil then
begin
DockHost.Top := 0;
DockHost.Height :=Screen.height;// Screen.WorkAreaHeight; by chenshaizi
OldDestroy := DockHost.OnDestroy;
DockHost.OnDestroy := MyDestroy;
Bar_Left := DockHost;
end
else
begin
Bar_Left := ObjInspector;
end;
//Add by luyear 021104
Bar_left.Constraints.MaxWidth:=500;
Bar_left.BorderStyle:= bsSizeAble;
end;

procedure TAutoHider.MyDockDrop(Sender: TObject; Source: TDragDockObject; X,
Y: Integer);
begin
if Assigned(OldDockDrop) then OldDockDrop(Sender, Source, X, Y);
Init_Bar_Left;
end;

initialization
MultiLinePalette := TMultiLinePalette.Create;
SetMultiLineComponentPalette(true);

AutoHider := TAutoHider.Create;
InitAutoHider(True);

finalization
InitAutoHider(False);
AutoHider.Delphi.OnMessage := nil;
AutoHider.Free;

SetMultiLineComponentPalette(false);
MultiLinePalette.Free;
end.
Top
 




All times are GMT++8, the time now is 2024-11-23 10:18

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007941 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP