win32: removing usage of ComCtrls from win32int. Refactored internal processing of WM_DRAWITEM message for ListView adding a new parameter to TWin32WindowInfo structure.

Moved ProgressBar constraint from TWin32WidgetSet to TWin32WSProgressBar.

git-svn-id: trunk@51190 -
This commit is contained in:
dmitry 2016-01-04 17:16:19 +00:00
parent b9393a2055
commit 5913d5f2b1
6 changed files with 54 additions and 18 deletions

View File

@ -1341,6 +1341,8 @@ procedure TWindowProcHelper.DoMsgDrawItem;
var
menuItem: TObject;
PDrawIS: PDrawItemStruct;
isDrawListItem: Boolean;
DrawItemMsg: Integer;
begin
PDrawIS := PDrawItemStruct(LParam);
if (WParam = 0) and (PDrawIS^.ctlType = ODT_MENU) then
@ -1369,14 +1371,16 @@ begin
(TCustomCombobox(lWinControl).Style = csOwnerDrawVariable))))
then
UpdateDrawListItem(LM_DRAWLISTITEM)
else
if (lWinControl <> nil) and (lWinControl is TListView) and
(TListView(lWinControl).ViewStyle = vsReport) and
(PDrawIS^.ctlType = ODT_LISTVIEW) and
(TListView(lWinControl).OwnerDraw)
then
UpdateDrawListItem(CN_DRAWITEM)
else
else if Assigned(WindowInfo^.DrawItemHandler) then begin
DrawItemMsg := 0;
isDrawListItem := False;
WindowInfo^.DrawItemHandler(lWinControl, Window, Msg, WParam, PDrawIS^,
DrawItemMsg, isDrawListItem);
if isDrawListItem and (DrawItemMsg<>0) then
UpdateDrawListItem(DrawItemMsg)
else
UpdateDrawItems;
end else
UpdateDrawItems;
end;
end;

View File

@ -30,7 +30,7 @@ interface
uses
Windows, // keep as first
ActiveX, Classes,
Translations, ComCtrls, Controls, Buttons,
Translations, Controls, Buttons,
LCLIntf, LclProc, LazUTF8, LCLType, LMessages,
Forms, Dialogs, GraphMath, GraphType, InterfaceBase,
StdCtrls, SysUtils, Win32Def, Graphics, Menus, CommCtrl,

View File

@ -584,15 +584,6 @@ begin
begin
// win32 combo (but not csSimple) has fixed height
FixedHeight := TCustomComboBox(SizeConstraints.Control).Style <> csSimple;
end
// The ProgressBar needs a minimum Height of 10 when themed,
// as required by Windows, otherwise it's image is corrupted
else if ThemeServices.ThemesEnabled and (SizeConstraints.Control is TCustomProgressBar) then
begin
MinHeight := 10;
SizeConstraints.SetInterfaceConstraints(
MinWidth, MinHeight, MaxWidth, MaxHeight);
end;
if (FixedHeight or FixedWidth)

View File

@ -36,6 +36,10 @@ Type
Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam;
var MsgResult: Windows.LResult; var WinProcess: Boolean): Boolean;
TDrawItemHandlerProc = procedure (const AWinControl: TWinControl; Window: HWnd;
Msg: UInt; WParam: Windows.WParam; const DrawIS: TDrawItemStruct;
var ItemMsg: Integer; var DrawListItem: Boolean);
PWin32WindowInfo = ^TWin32WindowInfo;
TWin32WindowInfo = record
Overlay: HWND; // overlay, transparent window on top, used by designer
@ -62,6 +66,7 @@ Type
isChildEdit: boolean; // is buddy edit of a control
ThemedCustomDraw: boolean;// controls needs themed drawing in wm_notify/nm_customdraw
IMEComposed: Boolean;
DrawItemHandler: TDrawItemHandlerProc;
case integer of
0: (spinValue: Double);
1: (

View File

@ -205,6 +205,7 @@ type
class procedure ApplyChanges(const AProgressBar: TCustomProgressBar); override;
class procedure SetPosition(const AProgressBar: TCustomProgressBar; const NewPosition: integer); override;
class procedure SetStyle(const AProgressBar: TCustomProgressBar; const NewStyle: TProgressBarStyle); override;
class function GetConstraints(const AControl: TControl; const AConstraints: TObject): Boolean; override;
end;
{ TWin32WSCustomUpDown }
@ -709,6 +710,30 @@ begin
end;
end;
class function TWin32WSProgressBar.GetConstraints(const AControl: TControl;
const AConstraints: TObject): Boolean;
var
SizeConstraints: TSizeConstraints absolute AConstraints;
MinWidth, MinHeight, MaxWidth, MaxHeight: Integer;
begin
Result := True;
if (AConstraints is TSizeConstraints) then
begin
MinWidth := 0;
MinHeight := 0;
MaxWidth := 0;
MaxHeight := 0;
// The ProgressBar needs a minimum Height of 10 when themed,
// as required by Windows, otherwise it's image is corrupted
if ThemeServices.ThemesEnabled then
MinHeight := 10;
SizeConstraints.SetInterfaceConstraints(MinWidth, MinHeight, MaxWidth, MaxHeight);
end;
end;
{ TWin32WSToolbar}
{$ifdef OldToolbar}

View File

@ -708,6 +708,16 @@ end;
// LV code
////////////////////////////////////////////////////////////////////////////////
procedure ListViewDrawItem(const AWinControl: TWinControl; Window: HWnd;
Msg: UInt; WParam: Windows.WParam; const DrawIS: TDrawItemStruct;
var ItemMsg: Integer; var DrawListItem: Boolean);
begin
DrawListItem := (AWinControl <> nil) and (AWinControl is TListView) and
(TListView(AWinControl).ViewStyle = vsReport) and
(DrawIS.ctlType = ODT_LISTVIEW) and
(TListView(AWinControl).OwnerDraw);
ItemMsg := CN_DRAWITEM;
end;
class function TWin32WSCustomListView.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
@ -738,6 +748,7 @@ begin
FinishCreateWindow(AWinControl, Params, false);
Params.WindowInfo^.ParentMsgHandler := @ListViewParentMsgHandler;
Params.WindowInfo^.needParentPaint := false;
Params.WindowInfo^.DrawItemHandler := @ListViewDrawItem;
Result := Params.Window;
if TCustomListView(AWinControl).checkboxes
then UpdateExStyle(result,lvs_ex_SubitemImages or lvs_Ex_Checkboxes,lvs_ex_SubitemImages or lvs_Ex_Checkboxes) else