mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-20 19:39:23 +02:00
win32: another trial to solve vista menu bar repainting problem (issue #0014894)
git-svn-id: trunk@22595 -
This commit is contained in:
parent
2a09af0079
commit
98a2219391
@ -1607,6 +1607,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
DrawMenuItem(TMenuItem(menuItem), PDrawItemStruct(LParam)^._hDC,
|
DrawMenuItem(TMenuItem(menuItem), PDrawItemStruct(LParam)^._hDC,
|
||||||
PDrawItemStruct(LParam)^.rcItem,
|
PDrawItemStruct(LParam)^.rcItem,
|
||||||
|
PDrawItemStruct(LParam)^.itemAction,
|
||||||
PDrawItemStruct(LParam)^.itemState);
|
PDrawItemStruct(LParam)^.itemState);
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@ -2384,16 +2385,6 @@ begin
|
|||||||
ThemeServices.IntfDoOnThemeChange;
|
ThemeServices.IntfDoOnThemeChange;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
WM_NCPAINT:
|
|
||||||
begin
|
|
||||||
if (lWinControl is TCustomForm) and
|
|
||||||
(TCustomForm(lWinControl).Menu <> nil) and
|
|
||||||
(GetMenu(TCustomForm(lWinControl).Handle) <> 0) then
|
|
||||||
begin
|
|
||||||
// request menu bar repaint
|
|
||||||
Windows.SetProp(TCustomForm(lWinControl).Handle, 'LCLMenuBarRedraw', 0);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ >= WM_USER }
|
{ >= WM_USER }
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function MenuItemSize(AMenuItem: TMenuItem; AHDC: HDC): TSize;
|
function MenuItemSize(AMenuItem: TMenuItem; AHDC: HDC): TSize;
|
||||||
procedure DrawMenuItem(const AMenuItem: TMenuItem; const AHDC: HDC; const ARect: Windows.RECT; const ItemState: UINT);
|
procedure DrawMenuItem(const AMenuItem: TMenuItem; const AHDC: HDC; const ARect: Windows.RECT; const ItemAction, ItemState: UINT);
|
||||||
function FindMenuItemAccelerator(const ACharCode: char; const AMenuHandle: HMENU): integer;
|
function FindMenuItemAccelerator(const ACharCode: char; const AMenuHandle: HMENU): integer;
|
||||||
procedure DrawMenuItemIcon(const AMenuItem: TMenuItem; const AHDC: HDC;
|
procedure DrawMenuItemIcon(const AMenuItem: TMenuItem; const AHDC: HDC;
|
||||||
const ImageRect: TRect; const ASelected: Boolean);
|
const ImageRect: TRect; const ASelected: Boolean);
|
||||||
@ -503,7 +503,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure DrawVistaMenuBar(const AMenuItem: TMenuItem; const AHDC: HDC; const ARect: TRect; const ASelected, ANoAccel: Boolean; const ItemState: UINT);
|
procedure DrawVistaMenuBar(const AMenuItem: TMenuItem; const AHDC: HDC; const ARect: TRect; const ASelected, ANoAccel: Boolean; const ItemAction, ItemState: UINT);
|
||||||
const
|
const
|
||||||
BarState: array[Boolean] of TThemedMenu =
|
BarState: array[Boolean] of TThemedMenu =
|
||||||
(
|
(
|
||||||
@ -551,8 +551,17 @@ begin
|
|||||||
// draw backgound
|
// draw backgound
|
||||||
// This is a hackish way to draw. Seems windows itself draws this in WM_PAINT or another paint handler?
|
// This is a hackish way to draw. Seems windows itself draws this in WM_PAINT or another paint handler?
|
||||||
AWnd := TCustomForm(AMenuItem.GetParentMenu.Parent).Handle;
|
AWnd := TCustomForm(AMenuItem.GetParentMenu.Parent).Handle;
|
||||||
if Windows.GetProp(AWnd, 'LCLMenuBarRedraw') = 0 then
|
if (AMenuItem.Parent.VisibleIndexOf(AMenuItem) = 0) then
|
||||||
begin
|
begin
|
||||||
|
/// if we are painting the first item then request full repaint to draw the bg correctly
|
||||||
|
if (GetProp(AWnd, 'LCL_MENUREDRAW') = 0) then
|
||||||
|
begin
|
||||||
|
SetProp(AWnd, 'LCL_MENUREDRAW', 1);
|
||||||
|
DrawMenuBar(AWnd);
|
||||||
|
Exit;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
SetProp(AWnd, 'LCL_MENUREDRAW', 0);
|
||||||
// repainting menu bar bg
|
// repainting menu bar bg
|
||||||
FillChar(Info, SizeOf(Info), 0);
|
FillChar(Info, SizeOf(Info), 0);
|
||||||
Info.cbSize := SizeOf(Info);
|
Info.cbSize := SizeOf(Info);
|
||||||
@ -561,7 +570,6 @@ begin
|
|||||||
OffsetRect(Info.rcBar, -WndRect.Left, -WndRect.Top);
|
OffsetRect(Info.rcBar, -WndRect.Left, -WndRect.Top);
|
||||||
Tmp := ThemeServices.GetElementDetails(BarState[(ItemState and ODS_INACTIVE) = 0]);
|
Tmp := ThemeServices.GetElementDetails(BarState[(ItemState and ODS_INACTIVE) = 0]);
|
||||||
ThemeDrawElement(AHDC, Tmp, Info.rcBar, nil);
|
ThemeDrawElement(AHDC, Tmp, Info.rcBar, nil);
|
||||||
Windows.SetProp(AWnd, 'LCLMenuBarRedraw', 1);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
BGRect := ARect;
|
BGRect := ARect;
|
||||||
@ -1069,7 +1077,7 @@ begin
|
|||||||
DrawMenuItemIcon(AMenuItem, AHDC, ImageRect, ASelected);
|
DrawMenuItemIcon(AMenuItem, AHDC, ImageRect, ASelected);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DrawMenuItem(const AMenuItem: TMenuItem; const AHDC: HDC; const ARect: Windows.RECT; const ItemState: UINT);
|
procedure DrawMenuItem(const AMenuItem: TMenuItem; const AHDC: HDC; const ARect: Windows.RECT; const ItemAction, ItemState: UINT);
|
||||||
var
|
var
|
||||||
ASelected, ANoAccel: Boolean;
|
ASelected, ANoAccel: Boolean;
|
||||||
B: Bool;
|
B: Bool;
|
||||||
@ -1085,7 +1093,7 @@ begin
|
|||||||
if IsVistaMenu then
|
if IsVistaMenu then
|
||||||
begin
|
begin
|
||||||
if AMenuItem.IsInMenuBar then
|
if AMenuItem.IsInMenuBar then
|
||||||
DrawVistaMenuBar(AMenuItem, AHDC, ARect, ASelected, ANoAccel, ItemState)
|
DrawVistaMenuBar(AMenuItem, AHDC, ARect, ASelected, ANoAccel, ItemAction, ItemState)
|
||||||
else
|
else
|
||||||
DrawVistaPopupMenu(AMenuItem, AHDC, ARect, ASelected, ANoAccel);
|
DrawVistaPopupMenu(AMenuItem, AHDC, ARect, ASelected, ANoAccel);
|
||||||
Exit;
|
Exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user