Applies patch from bug #17519 to fix regression in WinCE menus

git-svn-id: trunk@42069 -
This commit is contained in:
sekelsenmat 2013-07-13 05:12:09 +00:00
parent f8dbff1216
commit a29c6d9dec
4 changed files with 46 additions and 20 deletions

View File

@ -111,7 +111,7 @@ begin
FChecked := False;
FVisible := True;
FEnabled := True;
FCommand := UniqueCommand;
FCommand := TWSMenuItemClass(WidgetSetClass).OpenCommand;
FImageIndex := -1;
FBitmapIsValid := True;
FRightJustify := False;
@ -210,7 +210,7 @@ begin
FreeAndNil(FMenuItemHandlers[HandlerType]);
if FParent <> nil then
FParent.FItems.Remove(Self);
if FCommand <> 0 then CommandPool[FCommand] := False;
if FCommand <> 0 then TWSMenuItemClass(WidgetSetClass).CloseCommand(FCommand);
//debugln('TMenuItem.Destroy B ',dbgsName(Self));
inherited Destroy;
end;

View File

@ -45,6 +45,8 @@ type
var AForm: TForm): Boolean;
{$endif}
published
class function OpenCommand: LongInt; override;
class procedure CloseCommand(ACommand: LongInt); override;
class procedure AttachMenu(const AMenuItem: TMenuItem); override;
class function CreateHandle(const AMenuItem: TMenuItem): HMENU; override;
class procedure DestroyHandle(const AMenuItem: TMenuItem); override;
@ -80,7 +82,7 @@ type
end;
const
// IDs corresponding to the file winceres.rc
// IDs corresponding to the file wincemenures.rc
MenuBarID_Items = 20000;
MenuBarID_PopUp_Item = 20001;
MenuBarID_Item_Popup = 20002;
@ -90,6 +92,7 @@ const
MenuBarID_Empty = 20006;
MenuBarID_L = 1001;
MenuBarID_R = 1002;
MenuBarID_BASE = 1003;
var
MenuItemsList: TStringList;
MenuHandleList, MenuLCLObjectList: TFPList;
@ -573,7 +576,6 @@ begin
begin
GetWindowRect(mbi.hwndMB, R);
Windows.SystemParametersInfo(SPI_GETWORKAREA, 0, @WR, 0);
if WR.Bottom > R.Top then
SetWindowPos(wnd, 0, 0, 0, WR.Right - WR.Left, R.Top - WR.Top, SWP_NOZORDER or SWP_NOREPOSITION or SWP_NOMOVE);
end;
@ -887,6 +889,19 @@ begin
Break;
end;
end;
class function TWinCEWSMenuItem.OpenCommand: LongInt;
begin
Result := inherited OpenCommand;
Result := Result + MenuBarID_BASE;
end;
class procedure TWinCEWSMenuItem.CloseCommand(ACommand: LongInt);
begin
ACommand := ACommand - MenuBarID_BASE;
inherited CloseCommand(ACommand);
end;
{$endif}
class procedure TWinCEWSMenuItem.AttachMenu(const AMenuItem: TMenuItem);

View File

@ -450,19 +450,6 @@ uses
WSMenus,
Forms {KeyDataToShiftState};
{ Menu command management }
var
CommandPool: TBits = nil;
function UniqueCommand: LongInt;
begin
if CommandPool = nil then
CommandPool := TBits.Create(16);
Result := CommandPool.OpenBit;
CommandPool[Result] := True;
end;
{ Easy Menu building }
procedure AddMenuItems(AMenu: TMenu; const Items: array of TMenuItem);
@ -589,7 +576,4 @@ begin
Result := FPosition < FMenuItem.Count;
end;
finalization
FreeThenNil(CommandPool);
end.

View File

@ -49,6 +49,8 @@ type
TWSMenuItem = class(TWSLCLComponent)
published
class function OpenCommand: LongInt; virtual;
class procedure CloseCommand(ACommand: LongInt); virtual;
class procedure AttachMenu(const AMenuItem: TMenuItem); virtual;
class function CreateHandle(const AMenuItem: TMenuItem): HMENU; virtual;
class procedure DestroyHandle(const AMenuItem: TMenuItem); virtual;
@ -99,8 +101,31 @@ function WSCheckMenuItem(const AMenuItem: TMenuItem;
implementation
{ Menu command management }
var
CommandPool: TBits = nil;
function UniqueCommand: LongInt;
begin
if CommandPool = nil then
CommandPool := TBits.Create(16);
Result := CommandPool.OpenBit;
CommandPool[Result] := True;
end;
{ TWSMenuItem }
class function TWSMenuItem.OpenCommand: LongInt;
begin
Result := UniqueCommand;
end;
class procedure TWSMenuItem.CloseCommand(ACommand: LongInt);
begin
CommandPool[ACommand] := False;
end;
class procedure TWSMenuItem.AttachMenu(const AMenuItem: TMenuItem);
begin
end;
@ -232,4 +257,6 @@ begin
Done := True;
end;
finalization
FreeThenNil(CommandPool);
end.