mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-27 00:16:07 +02:00
Implements changing the menu caption of a top-level phone menu. Fixes bug #14973
git-svn-id: trunk@25810 -
This commit is contained in:
parent
5ef52a7806
commit
9682e60eea
@ -624,6 +624,9 @@ end;
|
|||||||
|
|
||||||
class function TWinCEWSMenuItem.CreateHandle(const AMenuItem: TMenuItem): HMENU;
|
class function TWinCEWSMenuItem.CreateHandle(const AMenuItem: TMenuItem): HMENU;
|
||||||
begin
|
begin
|
||||||
|
// DebugLn(Format('[TWinCEWSMenuItem.CreateHandle] Name:%s Parent:%d Parent:%s Items:%d',
|
||||||
|
// [AMenuItem.Name, Integer(AMenuItem.Parent), AMenuItem.Parent.Name,
|
||||||
|
// Integer(AMenuItem.GetParentMenu.Items)]));
|
||||||
Result := CreatePopupMenu;
|
Result := CreatePopupMenu;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -636,7 +639,50 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWinCEWSMenuItem.SetCaption(const AMenuItem: TMenuItem; const ACaption: string);
|
class procedure TWinCEWSMenuItem.SetCaption(const AMenuItem: TMenuItem; const ACaption: string);
|
||||||
|
{$ifndef Win32}
|
||||||
|
var
|
||||||
|
bi: TBBUTTONINFO;
|
||||||
|
w: WideString;
|
||||||
|
h: THandle;
|
||||||
|
i: Integer;
|
||||||
|
FormFound: Boolean;
|
||||||
|
AMenu: TMenu;
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
|
// The code to set top-level menus is different then ordinary items under WinCE
|
||||||
|
{$ifndef Win32}
|
||||||
|
AMenu := AMenuItem.GetParentMenu;
|
||||||
|
// DebugLn(Format('[TWinCEWSMenuItem.SetCaption] A AItem.Menu:%d',
|
||||||
|
// [PtrInt(AMenu)]));
|
||||||
|
if (Application.ApplicationType in [atPDA, atKeyPadDevice]) and
|
||||||
|
(AMenu <> nil) and (AMenu is TMainMenu) and
|
||||||
|
(AMenuItem.Parent = AMenu.Items) then
|
||||||
|
begin
|
||||||
|
// DebugLn('[TWinCEWSMenuItem.SetCaption] B');
|
||||||
|
|
||||||
|
// Iterate through all forms to find the parent
|
||||||
|
FormFound := False;
|
||||||
|
for i := 0 to Screen.FormCount - 1 do
|
||||||
|
if Screen.Forms[i].Menu = AMenu then
|
||||||
|
begin
|
||||||
|
h := SHFindMenuBar(Screen.Forms[i].Handle);
|
||||||
|
FormFound := True;
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// DebugLn('[TWinCEWSMenuItem.SetCaption] C');
|
||||||
|
if not FormFound then Exit;
|
||||||
|
// DebugLn('[TWinCEWSMenuItem.SetCaption] D');
|
||||||
|
|
||||||
|
FillChar(bi, SizeOf(TBBUTTONINFO), 0);
|
||||||
|
bi.cbSize := SizeOf(TBBUTTONINFO);
|
||||||
|
bi.dwMask := TBIF_TEXT;
|
||||||
|
w := UTF8Decode(ACaption);
|
||||||
|
bi.pszText := PWideChar(w);
|
||||||
|
SendMessageW(h, TB_SETBUTTONINFO, AMenuItem.Command + StartMenuItem, LPARAM(@bi));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
{$endif}
|
||||||
UpdateCaption(AMenuItem, aCaption);
|
UpdateCaption(AMenuItem, aCaption);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -655,7 +701,7 @@ end;
|
|||||||
class procedure TWinCEWSMenuItem.SetShortCut(const AMenuItem: TMenuItem;
|
class procedure TWinCEWSMenuItem.SetShortCut(const AMenuItem: TMenuItem;
|
||||||
const OldShortCut, NewShortCut: TShortCut);
|
const OldShortCut, NewShortCut: TShortCut);
|
||||||
begin
|
begin
|
||||||
UpdateCaption(AMenuItem, aMenuItem.Caption);
|
TWinCEWSMenuItem.SetCaption(AMenuItem, aMenuItem.Caption);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWinCEWSMenuItem.SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean;
|
class function TWinCEWSMenuItem.SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user