mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 16:29:38 +02:00
add TCustomForm.BorderIcons (delphi compat)
tweak win32 window dialog flags, to create better dialog look git-svn-id: trunk@6159 -
This commit is contained in:
parent
eb5698fec0
commit
3c81935809
@ -310,6 +310,9 @@ type
|
|||||||
|
|
||||||
TIDesigner = class;
|
TIDesigner = class;
|
||||||
|
|
||||||
|
TBorderIcon = (biSystemMenu, biMinimize, biMaximize, biHelp);
|
||||||
|
TBorderIcons = set of TBorderIcon;
|
||||||
|
|
||||||
TCloseEvent = procedure(Sender: TObject; var CloseAction: TCloseAction) of object;
|
TCloseEvent = procedure(Sender: TObject; var CloseAction: TCloseAction) of object;
|
||||||
TCloseQueryEvent = procedure(Sender : TObject;
|
TCloseQueryEvent = procedure(Sender : TObject;
|
||||||
var CanClose : boolean) of object;
|
var CanClose : boolean) of object;
|
||||||
@ -339,6 +342,7 @@ type
|
|||||||
private
|
private
|
||||||
FActive: Boolean;
|
FActive: Boolean;
|
||||||
FActiveControl: TWinControl;
|
FActiveControl: TWinControl;
|
||||||
|
FBorderIcons: TBorderIcons;
|
||||||
FDefaultControl: TControl;
|
FDefaultControl: TControl;
|
||||||
FCancelControl: TControl;
|
FCancelControl: TControl;
|
||||||
FDesigner: TIDesigner;
|
FDesigner: TIDesigner;
|
||||||
@ -376,6 +380,7 @@ type
|
|||||||
function IsKeyPreviewStored: boolean;
|
function IsKeyPreviewStored: boolean;
|
||||||
procedure SetActive(AValue: Boolean);
|
procedure SetActive(AValue: Boolean);
|
||||||
procedure SetActiveControl(AWinControl: TWinControl);
|
procedure SetActiveControl(AWinControl: TWinControl);
|
||||||
|
procedure SetBorderIcons(NewIcons: TBorderIcons);
|
||||||
procedure SetFormBorderStyle(NewStyle: TFormBorderStyle);
|
procedure SetFormBorderStyle(NewStyle: TFormBorderStyle);
|
||||||
procedure SetCancelControl(NewControl: TControl);
|
procedure SetCancelControl(NewControl: TControl);
|
||||||
procedure SetDefaultControl(NewControl: TControl);
|
procedure SetDefaultControl(NewControl: TControl);
|
||||||
@ -472,6 +477,8 @@ type
|
|||||||
public
|
public
|
||||||
property Active: Boolean read FActive;
|
property Active: Boolean read FActive;
|
||||||
property ActiveControl: TWinControl read FActiveControl write SetActiveControl;
|
property ActiveControl: TWinControl read FActiveControl write SetActiveControl;
|
||||||
|
property BorderIcons: TBorderIcons read FBorderIcons write SetBorderIcons
|
||||||
|
default [biSystemMenu, biMinimize, biMaximize];
|
||||||
property BorderStyle: TFormBorderStyle
|
property BorderStyle: TFormBorderStyle
|
||||||
read FFormBorderStyle write SetFormBorderStyle default bsSizeable;
|
read FFormBorderStyle write SetFormBorderStyle default bsSizeable;
|
||||||
property CancelControl: TControl read FCancelControl write SetCancelControl;
|
property CancelControl: TControl read FCancelControl write SetCancelControl;
|
||||||
@ -525,6 +532,7 @@ type
|
|||||||
property ActiveControl;
|
property ActiveControl;
|
||||||
property Align;
|
property Align;
|
||||||
property AutoSize;
|
property AutoSize;
|
||||||
|
property BorderIcons;
|
||||||
property BorderStyle;
|
property BorderStyle;
|
||||||
property Caption;
|
property Caption;
|
||||||
property ClientHeight;
|
property ClientHeight;
|
||||||
|
@ -1044,6 +1044,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------}
|
||||||
|
{ TCustomForm SetBorderIcons }
|
||||||
|
{------------------------------------------------------------------------------}
|
||||||
|
procedure TCustomForm.SetBorderIcons(NewIcons: TBorderIcons);
|
||||||
|
begin
|
||||||
|
if FBorderIcons = NewIcons then exit;
|
||||||
|
if HandleAllocated then
|
||||||
|
TWSCustomFormClass(WidgetSetClass).SetBorderIcons(Self, NewIcons);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
{ TCustomForm SetFormBorderStyle }
|
{ TCustomForm SetFormBorderStyle }
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
@ -1808,6 +1818,10 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.160 2004/10/24 18:54:57 micha
|
||||||
|
add TCustomForm.BorderIcons (delphi compat)
|
||||||
|
tweak win32 window dialog flags, to create better dialog look
|
||||||
|
|
||||||
Revision 1.159 2004/09/23 09:00:42 vincents
|
Revision 1.159 2004/09/23 09:00:42 vincents
|
||||||
fix type cast of WidgetSetClass
|
fix type cast of WidgetSetClass
|
||||||
|
|
||||||
|
@ -812,17 +812,16 @@ end;
|
|||||||
|
|
||||||
function BorderStyleToWin32Flags(Style: TFormBorderStyle): DWORD;
|
function BorderStyleToWin32Flags(Style: TFormBorderStyle): DWORD;
|
||||||
begin
|
begin
|
||||||
Result := WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
|
Result := WS_CLIPCHILDREN or WS_CLIPSIBLINGS;
|
||||||
case Style of
|
case Style of
|
||||||
//bsSizeable:; -> Default
|
bsSizeable, bsSizeToolWin:
|
||||||
bsSingle:
|
Result := Result or (WS_POPUP or WS_THICKFRAME or WS_CAPTION);
|
||||||
Result := Result and DWORD(not WS_THICKFRAME);
|
bsSingle, bsToolWindow:
|
||||||
|
Result := Result or (WS_OVERLAPPED or WS_BORDER or WS_CAPTION);
|
||||||
bsDialog:
|
bsDialog:
|
||||||
Result := Result and DWORD(not (WS_THICKFRAME or WS_MINIMIZEBOX or WS_MAXIMIZEBOX));
|
Result := Result or (WS_POPUP or WS_BORDER or WS_CAPTION);
|
||||||
bsNone:
|
bsNone:
|
||||||
Result := WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
|
Result := Result or WS_POPUP;
|
||||||
bsToolWindow:
|
|
||||||
Result := Result and DWORD(not WS_THICKFRAME);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -830,6 +829,8 @@ function BorderStyleToWin32FlagsEx(Style: TFormBorderStyle): DWORD;
|
|||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
case Style of
|
case Style of
|
||||||
|
bsDialog:
|
||||||
|
Result := WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
|
||||||
bsToolWindow, bsSizeToolWin:
|
bsToolWindow, bsSizeToolWin:
|
||||||
Result := WS_EX_TOOLWINDOW;
|
Result := WS_EX_TOOLWINDOW;
|
||||||
end;
|
end;
|
||||||
|
@ -80,6 +80,8 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
|
class procedure SetBorderIcons(const AForm: TCustomForm;
|
||||||
|
const ABorderIcons: TBorderIcons); override;
|
||||||
class function CreateHandle(const AWinControl: TWinControl;
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): HWND; override;
|
const AParams: TCreateParams): HWND; override;
|
||||||
class procedure SetIcon(const AForm: TCustomForm; const AIcon: HICON); override;
|
class procedure SetIcon(const AForm: TCustomForm; const AIcon: HICON); override;
|
||||||
@ -174,21 +176,45 @@ end;
|
|||||||
|
|
||||||
{ TWin32WSCustomForm }
|
{ TWin32WSCustomForm }
|
||||||
|
|
||||||
|
function CalcBorderIconsFlags(const AForm: TCustomForm): dword;
|
||||||
|
var
|
||||||
|
BorderIcons: TBorderIcons;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
if not (AForm.BorderStyle in [bsNone, bsDialog, bsToolWindow]) then
|
||||||
|
begin
|
||||||
|
BorderIcons := AForm.BorderIcons;
|
||||||
|
if biSystemMenu in BorderIcons then
|
||||||
|
begin
|
||||||
|
Result := Result or WS_SYSMENU;
|
||||||
|
if biMinimize in BorderIcons then
|
||||||
|
Result := Result or WS_MINIMIZEBOX;
|
||||||
|
if biMaximize in BorderIcons then
|
||||||
|
Result := Result or WS_MAXIMIZEBOX;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TWin32WSCustomForm.CreateHandle(const AWinControl: TWinControl;
|
function TWin32WSCustomForm.CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): HWND;
|
const AParams: TCreateParams): HWND;
|
||||||
var
|
var
|
||||||
Params: TCreateWindowExParams;
|
Params: TCreateWindowExParams;
|
||||||
|
lForm: TCustomForm;
|
||||||
|
BorderStyle: TFormBorderStyle;
|
||||||
begin
|
begin
|
||||||
// general initialization of Params
|
// general initialization of Params
|
||||||
PrepareCreateWindow(AWinControl, Params);
|
PrepareCreateWindow(AWinControl, Params);
|
||||||
// customization of Params
|
// customization of Params
|
||||||
with Params do
|
with Params do
|
||||||
begin
|
begin
|
||||||
Flags := BorderStyleToWin32Flags(TCustomForm(AWinControl).BorderStyle);
|
lForm := TCustomForm(AWinControl);
|
||||||
FlagsEx := BorderStyleToWin32FlagsEx(TCustomForm(AWinControl).BorderStyle);
|
BorderStyle := lForm.BorderStyle;
|
||||||
if (TCustomForm(AWinControl).FormStyle in fsAllStayOnTop)
|
Flags := BorderStyleToWin32Flags(BorderStyle);
|
||||||
and (not (csDesigning in TCustomForm(AWinControl).ComponentState)) then
|
FlagsEx := BorderStyleToWin32FlagsEx(BorderStyle);
|
||||||
|
if (lForm.FormStyle in fsAllStayOnTop) and
|
||||||
|
(not (csDesigning in lForm.ComponentState)) then
|
||||||
FlagsEx := FlagsEx or WS_EX_TOPMOST;
|
FlagsEx := FlagsEx or WS_EX_TOPMOST;
|
||||||
|
Flags := Flags or CalcBorderIconsFlags(lForm);
|
||||||
pClassName := @ClsName;
|
pClassName := @ClsName;
|
||||||
WindowTitle := StrCaption;
|
WindowTitle := StrCaption;
|
||||||
Left := LongInt(CW_USEDEFAULT);
|
Left := LongInt(CW_USEDEFAULT);
|
||||||
@ -202,6 +228,13 @@ begin
|
|||||||
Result := Params.Window;
|
Result := Params.Window;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TWin32WSCustomForm.SetBorderIcons(const AForm: TCustomForm;
|
||||||
|
const ABorderIcons: TBorderIcons);
|
||||||
|
begin
|
||||||
|
UpdateWindowStyle(AForm.Handle, CalcBorderIconsFlags(AForm),
|
||||||
|
WS_SYSMENU or WS_MINIMIZEBOX or WS_MAXIMIZEBOX);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TWin32WSCustomForm.SetIcon(const AForm: TCustomForm; const AIcon: HICON);
|
procedure TWin32WSCustomForm.SetIcon(const AForm: TCustomForm; const AIcon: HICON);
|
||||||
begin
|
begin
|
||||||
SendMessage(AForm.Handle, WM_SETICON, ICON_BIG, AIcon);
|
SendMessage(AForm.Handle, WM_SETICON, ICON_BIG, AIcon);
|
||||||
|
@ -72,6 +72,8 @@ type
|
|||||||
{ TWSCustomForm }
|
{ TWSCustomForm }
|
||||||
|
|
||||||
TWSCustomForm = class(TWSScrollingWinControl)
|
TWSCustomForm = class(TWSScrollingWinControl)
|
||||||
|
class procedure SetBorderIcons(const AForm: TCustomForm;
|
||||||
|
const ABorderIcons: TBorderIcons); virtual;
|
||||||
class procedure SetFormBorderStyle(const AForm: TCustomForm;
|
class procedure SetFormBorderStyle(const AForm: TCustomForm;
|
||||||
const AFormBorderStyle: TFormBorderStyle); virtual;
|
const AFormBorderStyle: TFormBorderStyle); virtual;
|
||||||
class procedure SetIcon(const AForm: TCustomForm; const AIcon: HICON); virtual;
|
class procedure SetIcon(const AForm: TCustomForm; const AIcon: HICON); virtual;
|
||||||
@ -104,6 +106,11 @@ implementation
|
|||||||
|
|
||||||
{ TWSCustomForm }
|
{ TWSCustomForm }
|
||||||
|
|
||||||
|
procedure TWSCustomForm.SetBorderIcons(const AForm: TCustomForm;
|
||||||
|
const ABorderIcons: TBorderIcons);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TWSCustomForm.SetFormBorderStyle(const AForm: TCustomForm;
|
procedure TWSCustomForm.SetFormBorderStyle(const AForm: TCustomForm;
|
||||||
const AFormBorderStyle: TFormBorderStyle);
|
const AFormBorderStyle: TFormBorderStyle);
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user