lcl,win32,wince: move edit control flags to createparams

git-svn-id: trunk@25476 -
This commit is contained in:
paul 2010-05-17 07:34:07 +00:00
parent b4c23c4585
commit ce91a6a9f0
6 changed files with 49 additions and 58 deletions

View File

@ -40,6 +40,22 @@ begin
TWSCustomEditClass(WidgetSetClass).SetSelLength(Self, FSelLength);
end;
procedure TCustomEdit.CreateParams(var Params: TCreateParams);
const
AlignmentStyle: array[TAlignment] of DWord = (
{ taLeftJustify } ES_LEFT,
{ taRightJustify } ES_RIGHT,
{ taCenter } ES_CENTER
);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or ES_AUTOHSCROLL or AlignmentStyle[Alignment];
if ReadOnly then
Params.Style := Params.Style or ES_READONLY;
if not HideSelection then
Params.Style := Params.Style or ES_NOHIDESEL;
end;
{------------------------------------------------------------------------------
Method: TCustomEdit.Create
Params: none

View File

@ -109,6 +109,25 @@ begin
RegisterCustomMemo;
end;
procedure TCustomMemo.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.Style := (Params.Style and not ES_AUTOHSCROLL) or ES_AUTOVSCROLL or
ES_MULTILINE or ES_WANTRETURN;
case ScrollBars of
ssHorizontal, ssAutoHorizontal:
Params.Style := Params.Style or WS_HSCROLL;
ssVertical, ssAutoVertical:
Params.Style := Params.Style or WS_VSCROLL;
ssBoth, ssAutoBoth:
Params.Style := Params.Style or WS_HSCROLL or WS_VSCROLL;
end;
if WordWrap then
Params.Style := Params.Style and not WS_HSCROLL
else
Params.Style := Params.Style or ES_AUTOHSCROLL;
end;
procedure TCustomMemo.InitializeWnd;
var
NewStrings : TStrings;

View File

@ -1048,15 +1048,8 @@ begin
// customization of Params
with Params do
begin
if (AWinControl is TCustomEdit) then
begin
Flags := Flags or AlignmentToEditFlags[TCustomEdit(AWinControl).Alignment];
if not TCustomEdit(AWinControl).HideSelection then
Flags := Flags or ES_NOHIDESEL;
end;
pClassName := @EditClsName[0];
WindowTitle := StrCaption;
Flags := Flags or ES_AUTOHSCROLL;
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
@ -1065,8 +1058,7 @@ begin
Result := Params.Window;
end;
class function TWin32WSCustomEdit.GetCanUndo(const ACustomEdit: TCustomEdit
): Boolean;
class function TWin32WSCustomEdit.GetCanUndo(const ACustomEdit: TCustomEdit): Boolean;
begin
Result := False;
if not WSCheckHandleAllocated(ACustomEdit, 'GetCanUndo') then
@ -1210,32 +1202,12 @@ class function TWin32WSCustomMemo.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
Params: TCreateWindowExParams;
ACustomMemo: TCustomMemo;
begin
// general initialization of Params
PrepareCreateWindow(AWinControl, AParams, Params);
// customization of Params
ACustomMemo := TCustomMemo(AWinControl);
with Params do
begin
Flags := Flags or ES_AUTOVSCROLL or ES_MULTILINE or ES_WANTRETURN;
if ACustomMemo.ReadOnly then
Flags := Flags or ES_READONLY;
Flags := Flags or AlignmentToEditFlags[ACustomMemo.Alignment];
case ACustomMemo.ScrollBars of
ssHorizontal, ssAutoHorizontal:
Flags := Flags or WS_HSCROLL;
ssVertical, ssAutoVertical:
Flags := Flags or WS_VSCROLL;
ssBoth, ssAutoBoth:
Flags := Flags or WS_HSCROLL or WS_VSCROLL;
end;
if ACustomMemo.WordWrap then
Flags := Flags and not WS_HSCROLL
else
Flags := Flags or ES_AUTOHSCROLL;
if not ACustomMemo.HideSelection then
Flags := Flags or ES_NOHIDESEL;
pClassName := @EditClsName[0];
WindowTitle := StrCaption;
end;

View File

@ -868,17 +868,8 @@ begin
// customization of Params
with Params do
begin
if (AWinControl is TCustomEdit) then
begin
if TCustomEdit(AWinControl).BorderStyle=bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
Flags := Flags or AlignmentToEditFlags[TCustomEdit(AWinControl).Alignment];
if not TCustomEdit(AWinControl).HideSelection then
Flags := Flags or ES_NOHIDESEL;
end;
pClassName := @EditClsName;
WindowTitle := StrCaption;
Flags := Flags or ES_AUTOHSCROLL;
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
@ -1010,32 +1001,12 @@ class function TWinCEWSCustomMemo.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
Params: TCreateWindowExParams;
ACustomMemo: TCustomMemo;
begin
// general initialization of Params
PrepareCreateWindow(AWinControl, AParams, Params);
// customization of Params
ACustomMemo := TCustomMemo(AWinControl);
with Params do
begin
Flags := Flags or ES_AUTOVSCROLL or ES_MULTILINE or ES_WANTRETURN;
if TCustomMemo(AWinControl).ReadOnly then
Flags := Flags or ES_READONLY;
Flags := Flags or AlignmentToEditFlags[ACustomMemo.Alignment];
case TCustomMemo(AWinControl).ScrollBars of
ssHorizontal, ssAutoHorizontal:
Flags := Flags or WS_HSCROLL;
ssVertical, ssAutoVertical:
Flags := Flags or WS_VSCROLL;
ssBoth, ssAutoBoth:
Flags := Flags or WS_HSCROLL or WS_VSCROLL;
end;
if TCustomMemo(AWinControl).WordWrap then
Flags := Flags and not WS_HSCROLL
else
Flags := Flags or ES_AUTOHSCROLL;
if ACustomMemo.BorderStyle=bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
pClassName := @EditClsName;
WindowTitle := StrCaption;
end;

View File

@ -913,6 +913,17 @@ const
BS_OWNERDRAW = $0000000B;
BS_PUSHLIKE = $00001000;
{ Edit styles }
ES_LEFT = $0000;
ES_CENTER = $0001;
ES_RIGHT = $0002;
ES_MULTILINE = $0004;
ES_AUTOVSCROLL = $0040;
ES_AUTOHSCROLL = $0080;
ES_NOHIDESEL = $0100;
ES_READONLY = $0800;
ES_WANTRETURN = $1000;
const
//==============================================
// SetWindowPos Flags

View File

@ -707,6 +707,7 @@ type
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean); override;
procedure CreateWnd; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure TextChanged; override;
procedure Change; virtual;
procedure DoEnter; override;
@ -795,6 +796,7 @@ type
procedure SetVertScrollBar(const AValue: TMemoScrollBar);
protected
class procedure WSRegisterClass; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure InitializeWnd; override;
procedure FinalizeWnd; override;
function RealGetText: TCaption; override;