⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 suiform.pas

📁 SUIPack是一款为Delphi和C++Builder开发的所见即所得的界面增强VCL组件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
////////////////////////////////////////////////////////////////////////////////
//
//
//  FileName    :   SUIForm.pas
//  Creator     :   Shen Min
//  Date        :   2002-05-21 V1-V3
//                  2003-06-19 V4
//                  2004-07-02 V5
//                  2006-06-18 V6
//  Comment     :
//
//  Copyright (c) 2002-2006 Sunisoft
//  http://www.sunisoft.com
//  Email: support@sunisoft.com
//
////////////////////////////////////////////////////////////////////////////////

unit SUIForm;

interface

{$I SUIPack.inc}

uses Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Graphics, Forms,
     ComCtrls, Menus, Dialogs, Buttons, AppEvnts, Math,
     SUITitleBar, SUIThemes, SUIMgr, SUIButton, SUIScrollBar, frmMSNPop,
     SUI2Define;

type
    TsuiForm = class;
    TsuiMDIForm = class;
    TsuiMenuBar = class(TToolBar)
    private
        m_Form : TsuiForm;
        m_MDIForm : TsuiMDIForm;

        procedure OnMenuPopup(Sender : TObject);
        procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
        
    protected
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;

    end;

    TsuiForm = class(TCustomPanel)
    private
        m_TitleBar : TsuiTitleBar;
        m_MenuBar : TsuiMenuBar;
        m_Menu : TMainMenu;
        m_OldWndProc : TWndMethod;
        m_BottomBorderWidth : Integer;
    	m_OldBottomBorderWidth : Integer;
        m_LeftBorderWidth : Integer;
	    m_OldLeftBorderWidth : Integer;
        m_RightBorderWidth : Integer;
        m_BottomBufRgn : TBitmap;
        m_TransparentColor : TColor;
        m_TitleNeedRegion : Boolean;
        m_BottomNeedRegion : Boolean;
        m_TitleRegionMin,
        m_TitleRegionMax,
        m_BottomRegionMin,
        m_BottomRegionMax : Integer;
        m_MaxFlag : Boolean;
        m_MaxFlag2 : Boolean;
        m_MaxFlag3 : Boolean;       
               
        m_OldBorderStyle : TFormBorderStyle;        

        m_Form : TForm;
        m_Color : TColor;
        m_Panel : TCustomPanel;
        m_Width : Integer;
        m_UIStyle : TsuiUIStyle;
        m_FileTheme : TsuiFileTheme;        
        m_MenuBarColor : TColor;
        m_MenuBarToColor : TColor;
        m_MenuBarHeight : Integer;
        m_UIStyleAutoUpdateSub : Boolean;
        m_Destroyed : Boolean;
        m_AppEvent : TApplicationEvents; 

        m_FormInitRect : TRect;
        m_FormInitMax : Boolean;
        m_MDIChildFormTitleVisible : Boolean;
        m_SelfChanging : Boolean;

        procedure NewParentWndProc(var Msg: TMessage);
        procedure ProcessKeyPress(var Msg : TMessage);
        procedure WMERASEBKGND(var Msg : TMessage); message WM_ERASEBKGND;
        procedure SetButtons(const Value : TsuiTitleBarButtons);
        function GetButtons() : TsuiTitleBarButtons;

        function GetOnBtnClick() : TsuiTitleBarButtonClickEvent;
        procedure SetOnBtnClick(const Value : TsuiTitleBarButtonClickEvent);
        function GetOnHelpBtnClick() : TsuiTitleBarButtonClickEvent;
        procedure SetOnHelpBtnClick(const Value : TsuiTitleBarButtonClickEvent);

        function GetFont() : TFont;
        procedure SetFont(const Value : TFont);
        function GetCaption() : TCaption;
        procedure SetCaption(const Value : TCaption);

        procedure SetMenu(const Value : TMainMenu);
        procedure SetMenuBarColor(const Value : TColor);
        function GetSections: TsuiTitleBarSections;
        procedure SetSections(const Value: TsuiTitleBarSections);
        procedure SetColor(const Value: TColor);
        function GetDrawAppIcon: Boolean;
        procedure SetDrawAppIcon(const Value: Boolean);
        procedure SetMenuBarHeight(const Value: Integer);
        procedure SetTitleBarVisible(const Value: Boolean);
        function GetTitleBarVisible: Boolean;
        function GetMDIChild: Boolean;
        function GetRoundCorner: Integer;
        procedure SetRoundCorner(const Value: Integer);
        function GetRoundCornerBottom: Integer;
        procedure SetRoundCornerBottom(const Value: Integer);
        procedure SetFileTheme(const Value: TsuiFileTheme);

        procedure DrawButton(Sender: TToolBar; Button: TToolButton; State: TCustomDrawState; var DefaultDraw: Boolean);
        procedure DrawMenuBar(Sender: TToolBar; const ARect: TRect; var DefaultDraw: Boolean);

        procedure OnApplicationMessage(var Msg: TMsg; var Handled: Boolean);
{$IFDEF SUIPACK_D5}
        procedure OnApplicationHint(Sender : TObject);
{$ENDIF}
        function GetTitleBarHeight: Integer;
        function GetTitleBarCustom: Boolean;
        procedure SetTitleBarCustom(const Value: Boolean);
        function GetVersion: String;
        procedure SetVersion(const Value: String);

        procedure RegionWindow();
        function GetInactiveCaptionColor: TColor;
        procedure SetInactiveCaptionColor(const Value: TColor);
        procedure SetMenuBarToColor(const Value: TColor);
        function GetMenuBarHeight: Integer;

    protected
        procedure SetPanel(const Value : TCustomPanel);
        procedure SetBorderWidth(const Value : Integer);
        procedure SetUIStyle(const Value : TsuiUIStyle);
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;
        procedure Paint(); override;
        procedure Resize(); override;
        procedure Loaded(); override;

        procedure CreateMenuBar();
        procedure DestroyMenuBar();

    public
        constructor Create(AOwner : TComponent); override;
        destructor Destroy(); override;

        procedure UpdateMenu();
        procedure UpdateTopMenu();
        procedure RepaintMenuBar();
        procedure PaintFormBorder();        
        
        property MDIChild : Boolean read GetMDIChild;
        property TitleBarHeight : Integer read GetTitleBarHeight;
        procedure ReAssign;
        
    published
        property TitleBarCustom : Boolean read GetTitleBarCustom write SetTitleBarCustom;
        property FileTheme : TsuiFileTheme read m_FileTheme write SetFileTheme;
        property UIStyle : TsuiUIStyle read m_UIStyle write SetUIStyle;
        property UIStyleAutoUpdateSub : Boolean read m_UIStyleAutoUpdateSub write m_UIStyleAutoUpdateSub;
        property BorderColor : TColor read m_Color write SetColor;
        property BorderWidth : Integer read m_Width write SetBorderWidth;
        property TitleBarVisible : Boolean read GetTitleBarVisible write SetTitleBarVisible default True;
        property BiDiMode;
        property Color;
        property Caption : TCaption read GetCaption write SetCaption;
        property FormPanel : TCustomPanel read m_Panel write SetPanel;
        property TitleBarButtons : TsuiTitleBarButtons read GetButtons write SetButtons;
        property TitleBarSections : TsuiTitleBarSections read GetSections write SetSections;
        property TitleBarDrawAppIcon : Boolean read GetDrawAppIcon write SetDrawAppIcon;
        property Font : TFont read GetFont write SetFont;
        property Menu : TMainMenu read m_Menu write SetMenu;
        property MenuBarColor : TColor read m_MenuBarColor write SetMenuBarColor;
        property MenuBarToColor : TColor read m_MenuBarToColor write SetMenuBarToColor;
        property MenuBarHeight : Integer read GetMenuBarHeight write SetMenuBarHeight;
        property RoundCorner : Integer read GetRoundCorner write SetRoundCorner;
        property RoundCornerBottom : Integer read GetRoundCornerBottom write SetRoundCornerBottom;
        property PopupMenu;
        property Version : String read GetVersion write SetVersion;
        property InactiveCaptionColor : TColor read GetInactiveCaptionColor write SetInactiveCaptionColor;        

        property OnTitleBarCustomBtnsClick : TsuiTitleBarButtonClickEvent read GetOnBtnClick write SetOnBtnClick;
        property OnTitleBarHelpBtnClick : TsuiTitleBarButtonClickEvent read GetOnHelpBtnClick write SetOnHelpBtnClick;
        property OnMouseDown;
    	property OnMouseMove;
        property OnClick;
        property OnMouseUp;

    end;

    TsuiMDIForm = class(TComponent)
    private
        m_Form : TForm;
        m_OldWndProc : TWndMethod; 
        m_PrevClientWndProc: Pointer;
        m_TopPanel : TPanel;
        m_TitleBar : TsuiTitleBar;
        m_MenuBar : TsuiMenuBar;
        m_ControlBtns : array [1..3] of TsuiToolBarSpeedButton;
        m_DrawChildCaptions : Boolean;
        m_DrawChildMenus : Boolean;
        m_Destroyed : Boolean;
        m_BottomBorderWidth : Integer;
    	m_OldBottomBorderWidth : Integer;
        m_LeftBorderWidth : Integer;
    	m_OldLeftBorderWidth : Integer;
    	m_RightBorderWidth : Integer;
        m_BottomBufRgn : TBitmap;
        m_TransparentColor : TColor;
        m_TitleNeedRegion : Boolean;
        m_BottomNeedRegion : Boolean;
        m_TitleRegionMin,
        m_TitleRegionMax,
        m_BottomRegionMin,
        m_BottomRegionMax : Integer;

        m_Menu : TMainMenu;
        m_TopMenu : TMainMenu;
        m_UIStyle : TsuiUIStyle;
        m_FileTheme : TsuiFileTheme;
        m_MenuBarColor : TColor;
        m_MenuBarToColor : TColor;
        m_BorderColor : TColor;
        m_BorderWidth : Integer;
        m_RoundCorner : Integer;
        m_RoundCornerBottom : Integer;
        m_AppEvent : TApplicationEvents;
        m_WindowMenuList : TList;
        m_ControlBtnsColor : TColor;
        m_ControlBtnsToColor : TColor;        

        procedure NewParentWndProc(var Msg: TMessage);
        procedure NewClientWndProc(var Msg : TMessage);
        procedure ProcessKeyPress(var Msg : TMessage);
        procedure OnControlButtonClick(Sender : TObject);
        procedure OnApplicationMessage(var Msg: TMsg; var Handled: Boolean);
        procedure OnTopPanelResize(Sender : TObject);
        procedure OnWindowMenuClick(Sender : TObject);
        procedure SetMenu(const Value: TMainMenu);
        procedure SetMenuBarColor(const Value : TColor);
        procedure SetUIStyle(const Value : TsuiUIStyle);
        procedure SetFileTheme(const Value: TsuiFileTheme);
        procedure SetBorderColor(const Value: TColor);
        function GetCaption: TCaption;
        procedure SetCaption(const Value: TCaption);

        procedure PaintBorder();
        function GetActiveChildSUIForm() : TsuiForm;

        procedure CreateMenuBar();
        procedure DestroyMenuBar();
        procedure ShowMenuBar();
        procedure HideMenuBar();
        procedure ShowControlButtons();
        procedure HideControlButtons();
        function GetMainMenu() : TMainMenu;

        procedure SetDrawAppIcon(const Value: Boolean);
        function GetDrawAppIcon: Boolean;
        function GetTitleBarCustom: Boolean;
        procedure SetTitleBarCustom(const Value: Boolean);
        procedure SetTitleBarVisible(const Value: Boolean);
        function GetTitleBarVisible: Boolean;
        function GetSections: TsuiTitleBarSections;
        procedure SetSections(const Value: TsuiTitleBarSections);
        procedure SetButtons(const Value : TsuiTitleBarButtons);
        function GetButtons() : TsuiTitleBarButtons;

        procedure DrawButton(Sender: TToolBar; Button: TToolButton; State: TCustomDrawState; var DefaultDraw: Boolean);
        procedure DrawMenuBar(Sender: TToolBar; const ARect: TRect; var DefaultDraw: Boolean);
        procedure SetRoundCorner(const Value: Integer);
        procedure SetRoundCornerBottom(const Value: Integer);

        procedure RegionWindow();
        function GetInactiveCaptionColor: TColor;
        procedure SetInactiveCaptionColor(const Value: TColor);
        procedure SetMenuBarToColor(const Value: TColor);

    protected
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;
        procedure Loaded(); override;

    public
        constructor Create(AOwner : TComponent); override;
        destructor Destroy(); override;

        procedure UpdateMenu();
        procedure UpdateWindowMenu();
        procedure Cascade();
        procedure Tile();

        function GetTitleBarHeight: integer;

    published
        property UIStyle : TsuiUIStyle read m_UIStyle write SetUIStyle;
        property FileTheme : TsuiFileTheme read m_FileTheme write SetFileTheme;
        property Menu : TMainMenu read m_Menu write SetMenu;
        property MenuBarColor : TColor read m_MenuBarColor write SetMenuBarColor;
        property MenuBarToColor : TColor read m_MenuBarToColor write SetMenuBarToColor;
        property BorderColor : TColor read m_BorderColor write SetBorderColor;
        property Caption : TCaption read GetCaption write SetCaption;
        property TitleBarDrawAppIcon : Boolean read GetDrawAppIcon write SetDrawAppIcon default False;
        property TitleBarCustom : Boolean read GetTitleBarCustom write SetTitleBarCustom default False;
        property TitleBarVisible : Boolean read GetTitleBarVisible write SetTitleBarVisible default True;
        property TitleBarButtons : TsuiTitleBarButtons read GetButtons write SetButtons;
        property TitleBarSections : TsuiTitleBarSections read GetSections write SetSections;
        property TitleBarDrawChildCaptions : Boolean read m_DrawChildCaptions write m_DrawChildCaptions default True;
        property TitleBarDrawChildMenus : Boolean read m_DrawChildMenus write m_DrawChildMenus default True;
        property RoundCorner : Integer read m_RoundCorner write SetRoundCorner;
        property RoundCornerBottom : Integer read m_RoundCornerBottom write SetRoundCornerBottom;
        property InactiveCaptionColor : TColor read GetInactiveCaptionColor write SetInactiveCaptionColor;        
    end;

    TsuiMSNPopForm = class(TComponent)
    private
        m_Form : TfrmMSNPopForm;
        m_AnimateTime : Integer;
        m_StayTime : Integer;
        m_X : Integer;
        m_Y : Integer;
        m_AutoPosition : Boolean;
        m_ClickHide : Boolean;
        m_Title : TCaption;
        m_Text : String;
        m_TextFont : TFont;
        m_TitleFont : TFont;
        m_OnTitleClick : TNotifyEvent;
        m_OnClick : TNotifyEvent;
        m_OnClose : TNotifyEvent;
        m_OnShow : TNotifyEvent;

        procedure InternalOnTitleClick(Sender : TObject);
        procedure InternalOnClick(Sender : TObject);
        procedure InternalOnClose(Sender : TObject);
        procedure SetTextFont(const Value: TFont);
        procedure SetTitleFont(const Value: TFont);

    public
        constructor Create(AOwner : TComponent); override;
        destructor Destroy(); override;

        procedure Popup();
        procedure Close();

    published
        property AnimateTime : Integer read m_AnimateTime write m_AnimateTime;
        property StayTime : Integer read m_StayTime write m_StayTime;
        property PositionX : Integer read m_X write m_X;
        property PositionY : Integer read m_Y write m_Y;
        property AutoPosition : Boolean read m_AutoPosition write m_AutoPosition;
        property ClickHide : Boolean read m_ClickHide write m_ClickHide;
        property Title : TCaption read m_Title write m_Title;
        property MessageText : String read m_Text write m_Text;

        property TitleFont : TFont read m_TitleFont write SetTitleFont;
        property MessageFont : TFont read m_TextFont write SetTextFont;

        property OnTitleClick : TNotifyEvent read m_OnTitleClick write m_OnTitleClick;
        property OnClick : TNotifyEvent read m_OnClick write m_OnClick;
        property OnClose : TNotifyEvent read m_OnClose write m_OnClose;
        property OnShow : TNotifyEvent read m_OnShow write m_OnShow;
    end;


implementation

uses SUIResDef, SUIPublic, SUIImagePanel, SUIMainMenu, SUIMenu, SUIProgressBar;

const
    SUIPACK_MSG_GETBOTTOMBORDER     = WM_APP + 2000;
    SUIPACK_MSG_GETLEFTBORDER       = WM_APP + 2001;

{ TsuiForm }

constructor TsuiForm.Create(AOwner: TComponent);
var
    i : Integer;
    c : Integer;
    P : TPoint;
begin
    inherited;

    if not (AOwner is TForm) then
        Exit;

    m_Form := AOwner as TForm;
    c := 0;
    for i := 0 to m_Form.ControlCount - 1 do

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -