* Made TWSMenu.SetBidiMode the same as TWSWinControl

git-svn-id: trunk@14840 -
This commit is contained in:
marc 2008-04-15 22:06:01 +00:00
parent d6163d5518
commit bc64373e6d
3 changed files with 35 additions and 17 deletions

View File

@ -36,7 +36,7 @@ uses
////////////////////////////////////////////////////
Graphics, GraphType, ImgList, Menus, Forms,
////////////////////////////////////////////////////
WSMenus, WSLCLClasses,
WSMenus, WSLCLClasses, WSProc,
Windows, Controls, Classes, SysUtils, Win32Int, Win32Proc, Win32WSImgList,
InterfaceBase, LCLProc;
@ -66,7 +66,7 @@ type
protected
public
class function CreateHandle(const AMenu: TMenu): HMENU; override;
class procedure BiDiModeChanged(const AMenu: TMenu); override;
class procedure SetBiDiMode(const AMenu: TMenu; const ABiDiMode: TBiDiMode); override;
end;
{ TWin32WSMainMenu }
@ -782,18 +782,19 @@ begin
Result := CreateMenu;
end;
class procedure TWin32WSMenu.BiDiModeChanged(const AMenu: TMenu);
class procedure TWin32WSMenu.SetBiDiMode(const AMenu: TMenu; const ABiDiMode: TBiDiMode);
begin
if AMenu.HandleAllocated then
begin
SetMenuFlag(AMenu.Handle, MFT_RIGHTORDER or MFT_RIGHTJUSTIFY, AMenu.IsRightToLeft);
//TriggerFormUpdate not take TMenu, we repeate the code
if (AMenu<>nil) and (AMenu.Parent<>nil)
and (AMenu.Parent is TCustomForm)
and TCustomForm(AMenu.Parent).HandleAllocated
and not (csDestroying in AMenu.Parent.ComponentState) then
AddToChangedMenus(TCustomForm(AMenu.Parent).Handle);
end;
if not WSCheckHandleAllocated(AMenu, 'SetBiDiMode')
then Exit;
SetMenuFlag(AMenu.Handle, MFT_RIGHTORDER or MFT_RIGHTJUSTIFY, AMenu.IsRightToLeft);
//TriggerFormUpdate not take TMenu, we repeate the code
if not (AMenu.Parent is TCustomForm) then Exit;
if not TCustomForm(AMenu.Parent).HandleAllocated then Exit;
if csDestroying in AMenu.Parent.ComponentState then Exit;
AddToChangedMenus(TCustomForm(AMenu.Parent).Handle);
end;
{ TWin32WSPopupMenu }

View File

@ -72,7 +72,8 @@ type
TWSMenuClass = class of TWSMenu;
TWSMenu = class(TWSLCLComponent)
class function CreateHandle(const AMenu: TMenu): HMENU; virtual;
class procedure BiDiModeChanged(const AMenu: TMenu); virtual;
class procedure SetBiDiMode(const AMenu: TMenu; const ABiDiMode: TBiDiMode); virtual;
end;
{ TWSMainMenu }
@ -157,7 +158,7 @@ begin
Result := 0;
end;
class procedure TWSMenu.BiDiModeChanged(const AMenu: TMenu);
class procedure TWSMenu.SetBiDiMode(const AMenu: TMenu; const ABiDiMode: TBiDiMode);
begin
end;

View File

@ -29,7 +29,7 @@ unit WSProc;
interface
uses
LCLClasses, LCLProc, Controls;
LCLClasses, LCLProc, Controls, Menus;
function WSCheckReferenceAllocated(const AComponent: TLCLReferenceComponent;
@ -37,7 +37,10 @@ function WSCheckReferenceAllocated(const AComponent: TLCLReferenceComponent;
function WSCheckHandleAllocated(const AWincontrol: TWinControl;
const AProcName: String): Boolean;
function WSCheckHandleAllocated(const AMenu: TMenu;
const AProcName: String): Boolean;
implementation
function WSCheckReferenceAllocated(const AComponent: TLCLReferenceComponent;
@ -66,5 +69,18 @@ begin
Warn;
end;
function WSCheckHandleAllocated(const AMenu: TMenu;
const AProcName: String): Boolean;
procedure Warn;
begin
DebugLn('[WARNING] %s called without handle for %s(%s)', [AProcName, AMenu.Name, AMenu.ClassName]);
end;
begin
Result := AMenu.HandleAllocated;
if Result then Exit;
Warn;
end;
end.