mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 12:30:36 +02:00
Fixes all wince menu bugs, except setting caption of subitems in atKeyPadDevice mode
git-svn-id: trunk@26798 -
This commit is contained in:
parent
62be1c21cc
commit
714834cb9c
@ -1104,7 +1104,7 @@ begin
|
|||||||
|
|
||||||
if Hi(WParam) < 2 then //1 for accelerator 0 for menu
|
if Hi(WParam) < 2 then //1 for accelerator 0 for menu
|
||||||
begin
|
begin
|
||||||
TargetObject := GetMenuItemObject
|
TargetObject := GetMenuItemObject();
|
||||||
end
|
end
|
||||||
else // menuitem or shortcut
|
else // menuitem or shortcut
|
||||||
begin
|
begin
|
||||||
|
@ -1,19 +1,36 @@
|
|||||||
//*****************************************************
|
//*****************************************************
|
||||||
// Resource file necessary for menu support
|
// Resource file necessary for menu support
|
||||||
//*****************************************************
|
//*****************************************************
|
||||||
|
//
|
||||||
|
// The MENU resource data has the following format:
|
||||||
|
//
|
||||||
|
// TOOLBAR_ID MENU DISCARDABLE
|
||||||
|
// BEGIN
|
||||||
|
// MENUITEM Caption, MENU_ID
|
||||||
|
// END
|
||||||
|
//
|
||||||
|
// POPUP menus in this structure can't have a MENU_ID
|
||||||
|
//
|
||||||
|
// The RCDATA after that is the Toolbar information:
|
||||||
|
//
|
||||||
|
// TOOLBAR_ID, Number of menu items,
|
||||||
|
// Image, MENU_ID, Toolbar state, Toolbar Style, ?, 0, either NOMENU (popup) or 0 (menuitem)
|
||||||
|
//
|
||||||
|
// NOMENU = 0xFFFF
|
||||||
|
//
|
||||||
|
|
||||||
// 2 simple menu items
|
// 2 simple menu items
|
||||||
20000 MENU DISCARDABLE
|
20000 MENU DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM " ", 1
|
MENUITEM " ", 1001
|
||||||
MENUITEM " ", 2
|
MENUITEM " ", 1002
|
||||||
END
|
END
|
||||||
|
|
||||||
20000 RCDATA DISCARDABLE
|
20000 RCDATA DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
20000, 2,
|
20000, 2,
|
||||||
-2, 1, 8, 0x10, 0, 0, 0xFFFF,
|
-2, 1001, 8, 0x10, 0, 0, 0xFFFF,
|
||||||
-2, 2, 8, 0x10, 0, 0, 0xFFFF
|
-2, 1002, 8, 0x10, 0, 0, 0xFFFF
|
||||||
END
|
END
|
||||||
|
|
||||||
// popup and simple menu item
|
// popup and simple menu item
|
||||||
@ -21,33 +38,33 @@ END
|
|||||||
BEGIN
|
BEGIN
|
||||||
POPUP " "
|
POPUP " "
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM " ", 1
|
MENUITEM " ", 1001
|
||||||
END
|
END
|
||||||
MENUITEM " ", 2
|
MENUITEM " ", 1002
|
||||||
END
|
END
|
||||||
|
|
||||||
20001 RCDATA DISCARDABLE
|
20001 RCDATA DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
20001, 2,
|
20001, 2,
|
||||||
-2, 1, 4, 0x18, 0, 0, 0,
|
-2, 1001, 4, 0x18, 0, 0, 0,
|
||||||
-2, 2, 4, 0x10, 0, 0, 0xFFFF
|
-2, 1002, 4, 0x10, 0, 0, 0xFFFF
|
||||||
END
|
END
|
||||||
|
|
||||||
// simple item and popup menu
|
// simple item and popup menu
|
||||||
20002 MENU DISCARDABLE
|
20002 MENU DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM " ", 1
|
MENUITEM " ", 1001
|
||||||
POPUP " "
|
POPUP " "
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM " ", 2
|
MENUITEM " ", 1002
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
20002 RCDATA DISCARDABLE
|
20002 RCDATA DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
20002, 2,
|
20002, 2,
|
||||||
-2, 1, 4, 0x10, 0, 0, 0xFFFF,
|
-2, 1001, 4, 0x10, 0, 0, 0xFFFF,
|
||||||
-2, 2, 4, 0x18, 0, 0, 1
|
-2, 1002, 4, 0x18, 0, 0, 1
|
||||||
END
|
END
|
||||||
|
|
||||||
// 2 popup menus
|
// 2 popup menus
|
||||||
@ -55,31 +72,31 @@ END
|
|||||||
BEGIN
|
BEGIN
|
||||||
POPUP "POPUP1"
|
POPUP "POPUP1"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "SUB1", 1
|
MENUITEM "SUB1", 1001
|
||||||
END
|
END
|
||||||
POPUP "POPUP2"
|
POPUP "POPUP2"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "SUB2", 2
|
MENUITEM "SUB2", 1002
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
20003 RCDATA DISCARDABLE
|
20003 RCDATA DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
20003, 2,
|
20003, 2,
|
||||||
-2, 1, 4, 0x18, 0, 0, 0,
|
-2, 1001, 4, 0x18, 0, 0, 0,
|
||||||
-2, 2, 4, 0x18, 0, 0, 1
|
-2, 1002, 4, 0x18, 0, 0, 1
|
||||||
END
|
END
|
||||||
|
|
||||||
// only 1 top-level item
|
// only 1 top-level item
|
||||||
20004 MENU DISCARDABLE
|
20004 MENU DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM " ", 1
|
MENUITEM " ", 1001
|
||||||
END
|
END
|
||||||
|
|
||||||
20004 RCDATA DISCARDABLE
|
20004 RCDATA DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
20004, 2,
|
20004, 1,
|
||||||
-2, 1, 8, 0x10, 0, 0, 0xFFFF
|
-2, 1001, 8, 0x10, 0, 0, 0xFFFF
|
||||||
END
|
END
|
||||||
|
|
||||||
// only 1 popup
|
// only 1 popup
|
||||||
@ -87,14 +104,14 @@ END
|
|||||||
BEGIN
|
BEGIN
|
||||||
POPUP "POPUP1"
|
POPUP "POPUP1"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "SUB1", 1
|
MENUITEM "SUB1", 1001
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
20005 RCDATA DISCARDABLE
|
20005 RCDATA DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
20005, 2,
|
20005, 1,
|
||||||
-2, 1, 4, 0x18, 0, 0, 0
|
-2, 1001, 4, 0x18, 0, 0, 0
|
||||||
END
|
END
|
||||||
|
|
||||||
// no menu
|
// no menu
|
||||||
@ -104,7 +121,7 @@ END
|
|||||||
|
|
||||||
20006 RCDATA DISCARDABLE
|
20006 RCDATA DISCARDABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
20006, 2
|
20006, 0
|
||||||
END
|
END
|
||||||
|
|
||||||
//*****************************************************
|
//*****************************************************
|
||||||
|
@ -43,6 +43,7 @@ type
|
|||||||
|
|
||||||
TWinCEWSMenuItem = class(TWSMenuItem)
|
TWinCEWSMenuItem = class(TWSMenuItem)
|
||||||
public
|
public
|
||||||
|
class procedure UpdateCaption(const AMenuItem: TMenuItem; ACaption: String);
|
||||||
class procedure AttachMenuEx(const AMenuItem: TMenuItem; const AParentHandle: HMENU);
|
class procedure AttachMenuEx(const AMenuItem: TMenuItem; const AParentHandle: HMENU);
|
||||||
class procedure CopyMenuToHandle(const AMenuItem: TMenuItem; const ADest: HMENU);
|
class procedure CopyMenuToHandle(const AMenuItem: TMenuItem; const ADest: HMENU);
|
||||||
published
|
published
|
||||||
@ -89,8 +90,8 @@ const
|
|||||||
MenuBarID_1_Item = 20004;
|
MenuBarID_1_Item = 20004;
|
||||||
MenuBarID_1_Popup = 20005;
|
MenuBarID_1_Popup = 20005;
|
||||||
MenuBarID_Empty = 20006;
|
MenuBarID_Empty = 20006;
|
||||||
MenuBarID_L = 1;
|
MenuBarID_L = 1001;
|
||||||
MenuBarID_R = 2;
|
MenuBarID_R = 1002;
|
||||||
StartMenuItem = 200;
|
StartMenuItem = 200;
|
||||||
var
|
var
|
||||||
MenuItemsList: TStringList;
|
MenuItemsList: TStringList;
|
||||||
@ -281,16 +282,10 @@ begin
|
|||||||
tbbi.dwMask := TBIF_TEXT or TBIF_COMMAND or TBIF_STATE;
|
tbbi.dwMask := TBIF_TEXT or TBIF_COMMAND or TBIF_STATE;
|
||||||
|
|
||||||
// Without setting idCommand the top-level items don't respond to clicks
|
// Without setting idCommand the top-level items don't respond to clicks
|
||||||
case mbi.nToolBarId of
|
tbbi.idCommand := MenuBarRLID;
|
||||||
MenuBarID_Popups: tbbi.idCommand := MenuBarRLID;
|
|
||||||
MenuBarID_PopUp_Item: tbbi.idCommand := MenuBarRLID;
|
// And we also need to update the MenuItem Command
|
||||||
MenuBarID_Item_Popup: tbbi.idCommand := MenuBarRLID;
|
TMenuItemAccess(LCLMenu.Items.Items[j]).FCommand := tbbi.idCommand - StartMenuItem;
|
||||||
MenuBarID_Items: tbbi.idCommand := StartMenuItem + MenuBarRLID;
|
|
||||||
MenuBarID_1_Popup: tbbi.idCommand := MenuBarRLID;
|
|
||||||
MenuBarID_1_Item: tbbi.idCommand := StartMenuItem + MenuBarRLID;
|
|
||||||
end;
|
|
||||||
// Update the MenuItem Command to use latter
|
|
||||||
TMenuItemAccess(LCLMenu.Items.Items[j]).FCommand := MenuBarRLID;
|
|
||||||
|
|
||||||
{$ifdef VerboseWinCEMenu}
|
{$ifdef VerboseWinCEMenu}
|
||||||
DebugLn('[CeSetMenu] atKeyPadDevice Set FCommand from ', LCLMenu.Items.Items[j].Name, ' to: ',
|
DebugLn('[CeSetMenu] atKeyPadDevice Set FCommand from ', LCLMenu.Items.Items[j].Name, ' to: ',
|
||||||
@ -298,15 +293,17 @@ begin
|
|||||||
DebugLn('[CeSetMenu] atKeyPadDevice Message TB_SETBUTTONINFO with ButtonID: MenuBarRLID = ' + IntToStr(MenuBarRLID));
|
DebugLn('[CeSetMenu] atKeyPadDevice Message TB_SETBUTTONINFO with ButtonID: MenuBarRLID = ' + IntToStr(MenuBarRLID));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
if SendMessage(mbi.hwndMB, TB_SETBUTTONINFO, MenuBarRLID, LPARAM(@tbbi)) = 0 then
|
if SendMessage(mbi.hwndMB, TB_SETBUTTONINFO, tbbi.idCommand, LPARAM(@tbbi)) = 0 then
|
||||||
DebugLn('[CeSetMenu] TB_SETBUTTONINFO failed');
|
DebugLn('[CeSetMenu] TB_SETBUTTONINFO failed');
|
||||||
|
|
||||||
|
MenuItemsList.AddObject(IntToStr(tbbi.idCommand), LCLMenu.Items.Items[j]);
|
||||||
|
|
||||||
// Adds subitems to a top-level item
|
// Adds subitems to a top-level item
|
||||||
{$ifdef VerboseWinCEMenu}
|
{$ifdef VerboseWinCEMenu}
|
||||||
DebugLn('[CeSetMenu] atKeyPadDevice Message TB_GETBUTTONINFO with ButtonID: MenuBarRLID = ' + IntToStr(MenuBarRLID));
|
DebugLn('[CeSetMenu] atKeyPadDevice Message TB_GETBUTTONINFO with ButtonID: MenuBarRLID = ' + IntToStr(MenuBarRLID));
|
||||||
{$endif}
|
{$endif}
|
||||||
tbbi.dwMask := TBIF_LPARAM;
|
tbbi.dwMask := TBIF_LPARAM;
|
||||||
if SendMessage(mbi.hwndMB, TB_GETBUTTONINFO, MenuBarRLID, LPARAM(@tbbi)) = - 1 then
|
if SendMessage(mbi.hwndMB, TB_GETBUTTONINFO, tbbi.idCommand, LPARAM(@tbbi)) = - 1 then
|
||||||
DebugLn('[CeSetMenu] TB_GETBUTTONINFO failed');
|
DebugLn('[CeSetMenu] TB_GETBUTTONINFO failed');
|
||||||
|
|
||||||
// Remove any present buttons, for example the one from the .rc file
|
// Remove any present buttons, for example the one from the .rc file
|
||||||
@ -320,12 +317,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if i = 1 then
|
// if i = 1 then
|
||||||
begin
|
// begin
|
||||||
tbbi.dwMask := TBIF_STATE;
|
// tbbi.dwMask := TBIF_STATE;
|
||||||
tbbi.fsState:=0;
|
// tbbi.fsState:=0;
|
||||||
SendMessage(mbi.hwndMB, TB_SETBUTTONINFO, 2, LPARAM(@tbbi));
|
// SendMessage(mbi.hwndMB, TB_SETBUTTONINFO, 2, LPARAM(@tbbi));
|
||||||
end;
|
// end;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -496,7 +493,7 @@ end;
|
|||||||
|
|
||||||
{ TWinCEWSMenuItem }
|
{ TWinCEWSMenuItem }
|
||||||
|
|
||||||
procedure UpdateCaption(const AMenuItem: TMenuItem; ACaption: String);
|
class procedure TWinCEWSMenuItem.UpdateCaption(const AMenuItem: TMenuItem; ACaption: String);
|
||||||
var
|
var
|
||||||
MenuInfo: MENUITEMINFO;
|
MenuInfo: MENUITEMINFO;
|
||||||
wCaption: WideString;
|
wCaption: WideString;
|
||||||
@ -764,8 +761,9 @@ begin
|
|||||||
if AMenu.Items.Items[j].Visible then Inc(i);
|
if AMenu.Items.Items[j].Visible then Inc(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if i = 0 then MenuBarRLID := StartMenuItem + MenuBarID_L
|
MenuBarRLID := StartMenuItem + AMenu.Items.Items[j].Command;
|
||||||
else MenuBarRLID := StartMenuItem + MenuBarID_R;
|
// if i = 0 then MenuBarRLID := StartMenuItem + MenuBarID_L
|
||||||
|
// else MenuBarRLID := StartMenuItem + MenuBarID_R;
|
||||||
|
|
||||||
{$ifdef VerboseWinCEMenu}
|
{$ifdef VerboseWinCEMenu}
|
||||||
DebugLn('[TWinCEWSMenuItem.SetCaption] TB_SETBUTTONINFO with ButtonID: ' + IntToStr(MenuBarRLID));
|
DebugLn('[TWinCEWSMenuItem.SetCaption] TB_SETBUTTONINFO with ButtonID: ' + IntToStr(MenuBarRLID));
|
||||||
|
Loading…
Reference in New Issue
Block a user