Fixes menu handler deleting

git-svn-id: trunk@26990 -
This commit is contained in:
sekelsenmat 2010-08-03 10:10:17 +00:00
parent 015175889d
commit 0af3b0c7d5
2 changed files with 30 additions and 2 deletions

View File

@ -278,8 +278,11 @@ Var
end;
{$endif}
// DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
// 'MenuClickResponse: ' + IntToStr(PtrInt(Result)));
{$ifdef VerboseWinCEMenu}
if Result <> nil then
DebugLn(Format('[wincecallback] GetMenuItemObject found menu item %s caption %s',
[TMenuItem(Result).Name, TMenuItem(Result).Caption]));
{$endif}
end;
function GetIsNativeControl(AWindow: HWND): Boolean;
@ -1122,6 +1125,9 @@ begin
if Hi(WParam) < 2 then //1 for accelerator 0 for menu
begin
{$ifdef VerboseWinCEMenu}
DebugLn('[wincecallback] Hi(WParam) < 2');
{$endif}
TargetObject := GetMenuItemObject();
end
else // menuitem or shortcut
@ -1131,6 +1137,10 @@ begin
if TargetObject is TMenuItem then
begin
{$ifdef VerboseWinCEMenu}
DebugLn('[wincecallback] Sending menuitem Click');
{$endif}
LMessage.Msg := LM_ACTIVATE;
TargetObject.Dispatch(LMessage);
lWinControl := nil;

View File

@ -166,11 +166,25 @@ begin
mbi.hwndMB := 0;
end;}
{$ifdef VerboseWinCEMenu}
DebugLn('[CeSetMenu] MenuItemsList.Text ' + MenuItemsList.Text);
{$endif}
// Remove previously installed top-level menu click handlers
MenuItemsList.Sort;
while MenuItemsList.Find('1001', lIndex) do
begin
MenuItemsList.Delete(lIndex);
{$ifdef VerboseWinCEMenu}
DebugLn(Format('[CeSetMenu] MenuItemsList.Delete 1001 Index %d', [lIndex]));
{$endif}
end;
while MenuItemsList.Find('1002', lIndex) do
begin
MenuItemsList.Delete(lIndex);
{$ifdef VerboseWinCEMenu}
DebugLn(Format('[CeSetMenu] MenuItemsList.Delete 1002 Index %d', [lIndex]));
{$endif}
end;
GetWindowRect(Wnd, BR);
@ -315,6 +329,10 @@ begin
;
// Add to the list to receive click events though WM_COMMAND
{$ifdef VerboseWinCEMenu}
DebugLn(Format('[CeSetMenu] MenuItemsList.AddObject %d Name %s',
[tbbi.idCommand, LCLMenu.Items.Items[j].Name]));
{$endif}
MenuItemsList.AddObject(IntToStr(tbbi.idCommand), LCLMenu.Items.Items[j]);
// Adds subitems to a top-level item