#6 Паша © 04.09.07 09:40:24
// unit Delfi_Panel // // a form that acts like component it can be dropped on form at design time // and stays there it has caption bar so it can be moved at runtime ... // // version 1.0 2001 Delfi // // this component is freeware for non-commercial applications you use it on your own responsibility ! // you may modify this unit only for non-commercial applications // you may not change the AUTHOR you must leave this comment here ! // // if you improved this component add your comment after this line
// uses some routines from forms.pas
// IMPORTANT THERE ARE PROBLEMS IF THERE IS AN EDIT OR MEMO ON THIS COMPONENT !!! // IT HAS SEVERAL PROBLEMS BUT IT IS STABLE
unit Delfi_Panel;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;
type Tbordericons_ = (smsystem_menu, smMaximize, smMinimize); Tbordericons = set of Tbordericons_; TDelfi_Panel = class(TPanel) private { Private declarations } Fsizable:boolean; Fborder:boolean; Ftoolwindow:boolean; Fbordericons: Tbordericons; fIcon : TIcon; fonclosequery : TNotifyEvent; procedure Setsizable(value:boolean); procedure Setborder(value:boolean); procedure Settoolwindow(value:boolean); procedure Setbordericons(value:Tbordericons); procedure SetIcon(Value : TIcon); procedure IconChanged(Sender: TObject); procedure WMClose(var Message: TWMClose); message WM_CLOSE; procedure WMIconEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ICONERASEBKGND; protected { Protected declarations } procedure CreateParams(var Params: TCreateParams); override; public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; published { Published declarations } property sizable:boolean read fsizable write Setsizable; property border:boolean read fborder write Setborder; property toolwindow:boolean read ftoolwindow write Settoolwindow; property Bordericons: Tbordericons read Fbordericons write Setbordericons; property Icon : TIcon read fIcon write SetIcon; property onclosequery : TNotifyEvent read Fonclosequery write Fonclosequery; property ShowHint; property OnMouseMove; property OnDragDrop; property OnDragOver; property OnEndDock; property OnEndDrag; property OnExit; property OnEnter; property OnKeyDown; property OnKeyPress; property OnKeyUp; property TabOrder; property TabStop; property OnstartDock; property OnstartDrag; property Visible; property Popupmenu; property helpcontext; property cursor; property dragkind; property dragmode; property dragcursor;
end;
procedure Register;
implementation
// WM_ERASEBKGND: // WM_ICONERASEBKGND;
procedure TDelfi_Panel.WMIconEraseBkgnd(var Message: TWMEraseBkgnd); begin SendMessage(Handle, WM_SETICON, 1, ficon.Handle); end;
{procedure TCustomForm.WMIconEraseBkgnd(var Message: TWMIconEraseBkgnd); begin FillRect(Message.DC, ClientRect, Application.MainForm.Brush.Handle) end; }
procedure TDelfi_Panel.IconChanged(Sender: TObject); begin SendMessage(Handle, WM_SETICON, 1, ficon.Handle); end;
procedure TDelfi_Panel.SetIcon(Value : Ticon); begin if Value <> fIcon then begin fIcon.Assign(value); end; end;
procedure TDelfi_Panel.WMClose(var Message: TWMClose); begin if assigned(Fonclosequery)then Fonclosequery(self); visible:=false; end;
procedure TDelfi_Panel.CreateParams(var Params: TCreateParams); begin inherited;
if fsizable = true then Params.Style:=Params.Style or WS_THICKFRAME; if fsizable = false then Params.Style:=Params.Style AND NOT WS_THICKFRAME;
if fborder = true then Params.Style:=Params.Style or WS_CAPTION; if fborder = false then Params.Style:=Params.Style and not WS_CAPTION;
if (smsystem_menu in Fbordericons) then Params.Style:=Params.Style or WS_SYSMENU else begin Params.Style:=Params.Style AND NOT WS_SYSMENU; end;
if (smMaximize in Fbordericons) then Params.Style:=Params.Style or WS_MAXIMIZEBOX else Params.Style:=Params.Style AND NOT WS_MAXIMIZEBOX;
if (smMinimize in Fbordericons) then Params.Style:=Params.Style or WS_GROUP else Params.Style:=Params.Style AND NOT WS_GROUP;
if ftoolwindow = true then Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW; if ftoolwindow = false then Params.ExStyle := Params.ExStyle and not WS_EX_TOOLWINDOW;
SendMessage(Handle, WM_SETICON, 1, ficon.Handle); end;
|