lcl: correctly fill TCreateParams structure in CreateParams method

win32: use CreateParams styles, exstyle, parent, caption and geometry instead of own calculated (issue #0014288)

git-svn-id: trunk@25149 -
This commit is contained in:
paul 2010-05-03 09:39:52 +00:00
parent a9499f1de3
commit 0cc6be3008
5 changed files with 29 additions and 58 deletions

View File

@ -2516,7 +2516,6 @@ type
function IsInsertMarkVisible: boolean; virtual;
procedure Change(Node: TTreeNode); virtual;
procedure Collapse(Node: TTreeNode); virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure Delete(Node: TTreeNode); virtual;
procedure DestroyWnd; override;

View File

@ -47,8 +47,6 @@ const
begin
inherited CreateParams(Params);
Params.Style := Params.Style or Kinds[FKind];
if FKind = sbVertical then
Params.Style := Params.Style or SBS_LEFTALIGN;
FRTLFactor := 1
end;

View File

@ -2824,28 +2824,6 @@ begin
inherited Destroy;
end;
procedure TCustomTreeView.CreateParams(var Params: TCreateParams);
const
ScrollBar: array[TScrollStyle] of DWORD = (0, WS_HSCROLL, WS_VSCROLL,
WS_HSCROLL or WS_VSCROLL, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL or WS_VSCROLL);
BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);
ClassStylesOff = CS_VREDRAW or CS_HREDRAW;
begin
inherited CreateParams(Params);
with Params do begin
{$IFOPT R+}{$DEFINE RangeCheckOn}{$R-}{$ENDIF}
WindowClass.Style := WindowClass.Style and not Cardinal(ClassStylesOff);
Style := Style or ScrollBar[FScrollBars] or BorderStyles[BorderStyle]
or WS_CLIPCHILDREN;
{$IFDEF RangeCheckOn}{$R+}{$ENDIF}
if NewStyleControls and (BorderStyle = bsSingle) then
begin
Style := Style and not Cardinal(WS_BORDER);
ExStyle := ExStyle or WS_EX_CLIENTEDGE;
end;
end;
end;
procedure TCustomTreeView.CreateWnd;
begin
Exclude(FStates,tvsStateChanging);

View File

@ -5915,16 +5915,23 @@ end;
procedure TWinControl.CreateParams(var Params : TCreateParams);
begin
FillChar(Params, SizeOf(Params),0);
Params.Caption := PChar(FCaption);
Params.Style := WS_CHILD or WS_CLIPSIBLINGS;
Params.Caption := PChar(Caption);
Params.Style := WS_CHILD or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
Params.ExStyle := 0;
if csAcceptsControls in ControlStyle then
Params.ExStyle := Params.ExStyle or WS_EX_CONTROLPARENT;
if TabStop then
Params.Style := Params.Style or WS_TABSTOP;
if (Parent <> nil) then
Params.WndParent := Parent.Handle
else
Params.WndParent := ParentWindow;
Params.X := FLeft;
Params.Y := FTop;
Params.Width := FWidth;
Params.Height := FHeight;
Params.WndParent := ParentWindow;
Params.X := Left;
Params.Y := Top;
Params.Width := Width;
Params.Height := Height;
end;
{------------------------------------------------------------------------------

View File

@ -152,44 +152,33 @@ procedure PrepareCreateWindow(const AWinControl: TWinControl;
begin
with Params do
begin
Flags := WS_CHILD or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
FlagsEx := 0;
Assert(False, 'Trace:Setting flags');
Window := HWND(nil);
Buddy := HWND(nil);
Assert(False, 'Trace:Setting window');
Parent := CreateParams.WndParent;
if Parent = 0 then
Parent := TWin32WidgetSet(WidgetSet).AppHandle;
SubClassWndProc := @WindowProc;
StrCaption := AWinControl.Caption;
WindowTitle := '';
Height := AWinControl.Height;
Left := AWinControl.Left;
//Parent := AWinControl.Parent;
Top := AWinControl.Top;
Width := AWinControl.Width;
if (WS_VISIBLE and CreateParams.Style) <> 0 then
Flags := Flags or WS_VISIBLE;
if csAcceptsControls in AWinControl.ControlStyle then
FlagsEx := FlagsEx or WS_EX_CONTROLPARENT;
if AWinControl.TabStop then
Flags := Flags or WS_TABSTOP;
Assert(False, 'Trace:Setting dimentions');
SubClassWndProc := @WindowProc;
Flags := CreateParams.Style;
FlagsEx := CreateParams.ExStyle;
Parent := CreateParams.WndParent;
if (Parent = 0) then
Parent := Win32WidgetSet.AppHandle;
StrCaption := CreateParams.Caption;
Left := CreateParams.X;
Top := CreateParams.Y;
Width := CreateParams.Width;
Height := CreateParams.Height;
LCLBoundsToWin32Bounds(AWinControl, Left, Top, Width, Height);
if AWinControl is TCustomControl then
if TCustomControl(AWinControl).BorderStyle = bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
SetStdBiDiModeParams(AWinControl, Params);
{$IFDEF VerboseSizeMsg}
DebugLn('PrepareCreateWindow ' + dbgsName(AWinControl) + ' ' +
Format('%d, %d, %d, %d', [Left, Top, Width, Height]));
{$ENDIF}
Assert(False, Format('Trace:PrepareCreateWindow - Creating component %S with the caption of %S', [AWinControl.ClassName, AWinControl.Caption]));
Assert(False, Format('Trace:PrepareCreateWindow - Left: %D, Top: %D, Width: %D, Height: %D, Parent handle: 0x%X, instance handle: 0x%X', [Left, Top, Width, Height, Parent, HInstance]));
end;
end;