1. Drop the taskbar to top.
2. Open delphi and open a project(Can use default new project).
3. Set the code editor can full screen.
4. Maxisize code editor.
5. Normal code editor.
Now you can't look the IDE main window's title bar.
You can replace CnEditorZoomFullScreen.pas file to fix this BUG.
CnEditorZoomFullScreen.pas:
{******************************************************************************}
{ CnPack For Delphi/C++Builder }
{ 中国人自己的开放源码第三方开发包 }
{ (C)Copyright 2001-2006 CnPack 开发组 }
{ ------------------------------------ }
{ }
{ 本开发包是开源的自由软件,您可以遵照 CnPack 的发布协议来修 }
{ 改和重新发布这一程序。 }
{ }
{ 发布这一开发包的目的是希望它有用,但没有任何担保。甚至没有 }
{ 适合特定目的而隐含的担保。更详细的情况请参阅 CnPack 发布协议。 }
{ }
{ 您应该已经和开发包一起收到一份 CnPack 发布协议的副本。如果 }
{ 还没有,可访问我们的网站: }
{ }
{ 网站地址:http://www.cnpack.org }
{ 电子邮件:master@cnpack.org }
{ }
{******************************************************************************}
unit CnEditorZoomFullScreen;
{* |<PRE>
================================================================================
* 软件名称:CnWizards IDE 专家工具包
* 单元名称:代码窗口全屏幕切换工具单元
* 单元作者:周劲羽 (zjy@cnpack.org)
* 备 注:
* 开发平台:PWin2000Pro + Delphi 5.01
* 兼容测试:PWin9X/2000/XP + Delphi 5/6/7 + C++Builder 5/6
* 本 地 化:该窗体中的字符串均符合本地化处理方式
* 单元标识:$Id: CnEditorZoomFullScreen.pas,v 1.7 2006/01/13 12:39:10 passion Exp $
* 修改记录:2005.02.22 V1.2
* 增加代码窗口最大化时自动隐藏主窗口的功能
* 2003.03.06 V1.1
* IDE 启动后代码窗口最大化
* 2002.12.11 V1.0
* 创建单元,实现功能
================================================================================
|</PRE>}
interface
{$I CnPack.inc}
{$IFNDEF BDS}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, IniFiles, ToolsAPI, CnWizIdeUtils, CnConsts, CnCommon,
CnWizConsts, CnEditorWizard, CnWizUtils, CnWizMultiLang;
type
TCnEditorZoomFullScreenForm = class(TCnTranslateForm)
GroupBox1: TGroupBox;
cbAutoZoom: TCheckBox;
btnOK: TButton;
btnCancel: TButton;
chkAutoHideMainForm: TCheckBox;
chkRestoreNormal: TCheckBox;
private
{ Private declarations }
public
{ Public declarations }
end;
//==============================================================================
// 代码窗口全屏幕切换工具类
//==============================================================================
{ TCnEditorZoomFullScreen }
TCnEditorZoomFullScreen = class(TCnBaseEditorTool)
private
// Save main IDE top
MainIDETop: Integer;
FTimer: TTimer;
FUpdating: Boolean;
FAutoZoom: Boolean;
FAutoHideMainForm: Boolean;
FLastAutoHideMainForm: Boolean;
FRestoreNormal: Boolean;
procedure AdjustEditorForm(FullScreen: Boolean);
procedure SetAutoHideMainForm(const Value: Boolean);
procedure UpdateAutoHide;
procedure UpdateMainFormPos(AShow: Boolean);
function CheckMousePos(var AMouseEnter: Boolean): Boolean;
procedure OnTimer(Sender: TObject);
function GetFullScreen: Boolean;
procedure SetFullScreen(const Value: Boolean);
protected
function GetHasConfig: Boolean; override;
function NeedAutoHide: Boolean;
public
constructor Create(AOwner: TCnEditorWizard); override;
destructor Destroy; override;
function GetState: TWizardState; override;
function GetCaption: string; override;
function GetHint: string; override;
function GetDefShortCut: TShortCut; override;
procedure LoadSettings(Ini: TCustomIniFile); override;
procedure SaveSettings(Ini: TCustomIniFile); override;
procedure Loaded; override;
procedure Execute; override;
procedure GetEditorInfo(var Name, Author, Email: string); override;
procedure Config; override;
property FullScreen: Boolean read GetFullScreen write SetFullScreen;
published
property AutoZoom: Boolean read FAutoZoom write FAutoZoom;
property AutoHideMainForm: Boolean read FAutoHideMainForm write SetAutoHideMainForm;
property RestoreNormal: Boolean read FRestoreNormal write FRestoreNormal;
end;
implementation
{$IFDEF DEBUG}
uses
CnDebug;
{$ENDIF}
{$R *.DFM}
//==============================================================================
// 代码窗口全屏幕切换工具类
//==============================================================================
{ TCnEditorZoomFullScreen }
const
csZoomFullScreen = 'ZoomFullScreen';
csBarWidth = 4;
constructor TCnEditorZoomFullScreen.Create(AOwner: TCnEditorWizard);
begin
inherited;
FUpdating := False;
FLastAutoHideMainForm := False;
FTimer := TTimer.Create(nil);
FTimer.Enabled := False;
FTimer.Interval := 200;
FTimer.OnTimer := OnTimer;
end;
destructor TCnEditorZoomFullScreen.Destroy;
begin
FTimer.Free;
inherited;
end;
procedure TCnEditorZoomFullScreen.AdjustEditorForm(FullScreen: Boolean);
var
EditorForm, IdeMainForm: TCustomForm;
IdeBottom: Integer;
i: Integer;
begin
for i := 0 to Screen.CustomFormCount - 1 do
if IsIdeEditorForm(Screen.CustomForms[i]) then
begin
EditorForm := Screen.CustomForms[i];
if EditorForm.WindowState = wsNormal then // 未最大化时直接最大化
EditorForm.WindowState := wsMaximized
else
begin
if FullScreen then // 全屏方式下直接设置为工作区域
with GetWorkRect do
SetWindowPos(EditorForm.Handle, HWND_TOP, Left, Top, Right - Left,
Bottom - Top, SWP_SHOWWINDOW)
else
begin
if RestoreNormal then
EditorForm.WindowState := wsNormal
else
begin
IdeMainForm := GetIdeMainForm;
if Assigned(IdeMainForm) then // 找到 IDE 主窗口时设置在主窗口下方
begin
IdeBottom := IdeMainForm.Top + IdeMainForm.Height;
with GetWorkRect do
SetWindowPos(EditorForm.Handle, HWND_TOP, Left, IdeBottom,
Right - Left, Bottom - IdeBottom, SWP_SHOWWINDOW);
end
else
begin // 没办法,只好先常规化再最大化
EditorForm.WindowState := wsNormal;
EditorForm.WindowState := wsMaximized;
end;
end;
end;
end;
Exit;
end;
end;
procedure TCnEditorZoomFullScreen.Execute;
begin
FullScreen := not FullScreen;
UpdateAutoHide;
AdjustEditorForm(FullScreen);
end;
procedure TCnEditorZoomFullScreen.Loaded;
begin
if Active and FAutoZoom then
begin
AdjustEditorForm(FullScreen);
end;
end;
function TCnEditorZoomFullScreen.GetFullScreen: Boolean;
var
Options: IOTAEnvironmentOptions;
begin
Options := CnOtaGetEnvironmentOptions;
if Assigned(Options) then
Result := Options.GetOptionValue(csZoomFullScreen)
else
Result := False;
end;
procedure TCnEditorZoomFullScreen.SetFullScreen(const Value: Boolean);
var
Options: IOTAEnvironmentOptions;
begin
Options := CnOtaGetEnvironmentOptions;
if Assigned(Options) then
Options.SetOptionValue(csZoomFullScreen, Value);
end;
function TCnEditorZoomFullScreen.GetCaption: string;
begin
Result := SCnEditorZoomFullScreenMenuCaption;
end;
function TCnEditorZoomFullScreen.GetDefShortCut: TShortCut;
begin
Result := 0;
end;
function TCnEditorZoomFullScreen.GetHint: string;
begin
Result := SCnEditorZoomFullScreenMenuHint;
end;
procedure TCnEditorZoomFullScreen.GetEditorInfo(var Name, Author, Email: string);
begin
Name := SCnEditorZoomFullScreen;
Author := SCnPack_Yygw;
Email := SCnPack_YygwEmail;
end;
function TCnEditorZoomFullScreen.GetState: TWizardState;
begin
Result := [];
if Active and (wsEnabled in inherited GetState) then
Include(Result, wsEnabled);
if FullScreen then
Include(Result, wsChecked);
end;
//------------------------------------------------------------------------------
// 主窗体自动隐藏
//------------------------------------------------------------------------------
function TCnEditorZoomFullScreen.NeedAutoHide: Boolean;
var
IdeMainForm: TCustomForm;
function IsEditorMaximized: Boolean;
var
i: Integer;
begin
Result := False;
for i := 0 to Screen.CustomFormCount - 1 do
if IsIdeEditorForm(Screen.CustomForms[i]) then
begin
Result := Screen.CustomForms[i].WindowState = wsMaximized;
Exit;
end;
end;
begin
IdeMainForm := GetIdeMainForm;
// 代码窗口全屏最大化且主窗口没有最大化时才自动隐藏
Result := Active and FAutoHideMainForm and Assigned(IdeMainForm) and
(IdeMainForm.WindowState = wsNormal) and FullScreen and IsEditorMaximized;
end;
procedure TCnEditorZoomFullScreen.SetAutoHideMainForm(
const Value: Boolean);
begin
FAutoHideMainForm := Value;
FTimer.Enabled := Value;
UpdateAutoHide;
end;
procedure TCnEditorZoomFullScreen.OnTimer(Sender: TObject);
begin
UpdateAutoHide;
end;
function TCnEditorZoomFullScreen.CheckMousePos(var AMouseEnter: Boolean):
Boolean;
var
MousePos: TPoint;
IdeMainForm: TCustomForm;
begin
Result := False;
if GetCursorPos(MousePos) then
begin
IdeMainForm := GetIdeMainForm;
if Assigned(IdeMainForm) then
begin
with IdeMainForm do
AMouseEnter := PtInRect(Bounds(Left, Top - MainIDETop, Width, Height), MousePos) or
(Top = -Height) and PtInRect(Bounds(Left, 0, Width, csBarWidth), MousePos);
Result := GetShiftState * [ssLeft, ssRight, ssMiddle, ssDouble] = [];
end;
end;
end;
procedure TCnEditorZoomFullScreen.UpdateAutoHide;
var
MouseEnter: Boolean;
IdeMainForm: TCustomForm;
begin
IdeMainForm := GetIdeMainForm;
if NeedAutoHide then
begin
if not FLastAutoHideMainForm then
begin
FLastAutoHideMainForm := True;
UpdateMainFormPos(False);
if Assigned(IdeMainForm) then
StayOnTop(IdeMainForm.Handle, True);
end
else
begin
if CheckMousePos(MouseEnter) then
begin
if not Application.Active or not MouseEnter then
UpdateMainFormPos(False)
else if not ScreenHasModalForm then
UpdateMainFormPos(True);
end;
end;
end
else if FLastAutoHideMainForm then
begin
FLastAutoHideMainForm := False;
UpdateMainFormPos(True);
if Assigned(IdeMainForm) then
StayOnTop(IdeMainForm.Handle, False);
end;
end;
procedure TCnEditorZoomFullScreen.UpdateMainFormPos(AShow: Boolean);
var
WorkRect: TRect;
IdeMainForm: TCustomForm;
begin
if FUpdating then
Exit;
FUpdating := True;
try
IdeMainForm := GetIdeMainForm;
if Assigned(IdeMainForm) then
begin
if IdeMainForm.WindowState = wsNormal then
begin
WorkRect := GetWorkRect;
if IdeMainForm.Left <> WorkRect.Left then
IdeMainForm.Left := WorkRect.Left;
if IdeMainForm.Width <> WorkRect.Right - WorkRect.Left then
IdeMainForm.Width := WorkRect.Right - WorkRect.Left;
if AShow then
begin
if IdeMainForm.Top <> 0 then
begin
IdeMainForm.Top := MainIDETop;
StayOnTop(IdeMainForm.Handle, True);
end;
end
else
begin
if IdeMainForm.Top <> -IdeMainForm.Height then
begin
MainIDETop := IdeMainForm.Top;
IdeMainForm.Top := -IdeMainForm.Height;
end;
end;
end;
end;
finally
FUpdating := False;
end;
end;
//------------------------------------------------------------------------------
// 设置相关
//------------------------------------------------------------------------------
procedure TCnEditorZoomFullScreen.Config;
begin
with TCnEditorZoomFullScreenForm.Create(nil) do
try
cbAutoZoom.Checked := FAutoZoom;
chkAutoHideMainForm.Checked := FAutoHideMainForm;
chkRestoreNormal.Checked := FRestoreNormal;
if ShowModal = mrOk then
begin
AutoZoom := cbAutoZoom.Checked;
AutoHideMainForm := chkAutoHideMainForm.Checked;
RestoreNormal := chkRestoreNormal.Checked;
end;
finally
Free;
end;
end;
function TCnEditorZoomFullScreen.GetHasConfig: Boolean;
begin
Result := True;
end;
const
csAutoZoom = 'AutoZoom';
csAutoHideMainForm = 'AutoHideMainForm';
csRestoreNormal = 'RestoreNormal';
procedure TCnEditorZoomFullScreen.LoadSettings(Ini: TCustomIniFile);
begin
inherited;
AutoZoom := Ini.ReadBool('', csAutoZoom, False);
AutoHideMainForm := Ini.ReadBool('', csAutoHideMainForm, True);
RestoreNormal := Ini.ReadBool('', csRestoreNormal, False);
end;
procedure TCnEditorZoomFullScreen.SaveSettings(Ini: TCustomIniFile);
begin
inherited;
Ini.WriteBool('', csAutoZoom, AutoZoom);
Ini.WriteBool('', csAutoHideMainForm, AutoHideMainForm);
Ini.WriteBool('', csRestoreNormal, RestoreNormal);
end;
initialization
RegisterCnEditor(TCnEditorZoomFullScreen); // 注册专家
{$ELSE}
implementation
{$ENDIF}
end.
[
Last edited by kendling on 2006-3-18 at 18:07 ]