View Issue Details

IDProjectCategoryView StatusLast Update
0013192PatchesLCLpublic2011-08-05 13:34
Reporterhaword Assigned ToFelipe Monteiro de Carvalho  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionsuspended 
Product Version0.9.27 (SVN) 
Target Version0.99.0Fixed in Version0.9.27 (SVN) 
Summary0013192: WinCE any time show in main menu Windows CE NEW menu
DescriptionIn WinCE, params Comamnd MenuItems should be begin with 200
TagsNo tags attached.
Fixed in Revision18738
LazTarget0.99.0
WidgetsetWinCE
Attached Files

Relationships

has duplicate 0011457 closedFelipe Monteiro de Carvalho Lazarus MainMenu opens a strange submenu 
has duplicate 0017519 resolvedFelipe Monteiro de Carvalho Lazarus [WinCE] Regression: "New" sub menu is opened if MenuItem.Command=11 

Activities

2009-02-17 10:28

 

WinCEMenuPath.patch (10,733 bytes)   
Index: wincecallback.inc
===================================================================
--- wincecallback.inc	(revision 18702)
+++ wincecallback.inc	(working copy)
@@ -206,7 +206,7 @@
   WindowInfo: PWindowInfo;
   Flags: dword;
   ChildWindowInfo: PWindowInfo;
-  
+
   LMScroll: TLMScroll; // used by WM_HSCROLL
   LMKey: TLMKey; // used by WM_KEYDOWN WM_KEYUP
   LMChar: TLMChar; // used by WM_CHAR
@@ -220,7 +220,7 @@
 
   OrgCharCode: word; // used in WM_CHAR handling
 
-  
+
   NMHdr: PNMHdr absolute LParam; // used by WM_NOTIFY
   TmpSize: TSize; // used by WM_MEASUREITEM
   {$ifndef win32}
@@ -264,7 +264,7 @@
     if PopupMenu <> nil then //processing popup menu
     begin
       WindowInfo^.PopupMenu := nil;
-      Result := PopupMenu.FindItem(LOWORD(WParam), fkCommand);
+      Result := PopupMenu.FindItem(LOWORD(WParam) - StartMenuItem , fkCommand);
     end;
     {$ifndef win32}
     if Result = nil then //if Result is still nil, process main menu
@@ -277,7 +277,7 @@
     {
       This way returns False for GetMenuItemInfo(W) - extended error is so:
       This function is only valid in win32 mode
-      
+
       if GetMenuItemInfo(MainMenuHandle, LOWORD(WParam), false, @MenuInfo) then
         Result := TObject(MenuInfo.dwItemData)
       else
@@ -717,7 +717,7 @@
       if ACursor = crDefault then
       begin
         // statictext controls do not get WM_SETCURSOR messages...
-        lControl := lWinControl.ControlAtPos(P, [capfOnlyClientAreas, 
+        lControl := lWinControl.ControlAtPos(P, [capfOnlyClientAreas,
           capfAllowWinControls, capfHasScrollOffset, capfRecursive]);
         if lControl = nil then
           lControl := lWinControl;
@@ -767,7 +767,7 @@
             end;
           end;
         end;
-        
+
      //roozbeh : we dont have these in wince!
      { SC_MINIMIZE:
         begin
@@ -786,7 +786,7 @@
                 Application.MainForm.Width, 0, SWP_NOACTIVATE);
                 if Application.MainForm.HandleAllocated then
                  Windows.ShowWindow(Application.MainForm.Handle,SW_HIDE);
-                 
+
               Application.IntfAppMinimize;
           end;
         end;}
@@ -804,7 +804,7 @@
             if Windows.IsWindowEnabled(Application.MainForm.Handle)
              then Windows.SetActiveWindow(Application.MainForm.Handle);
             WinProcess := false;
-            
+
             Application.IntfAppRestore;
           end;
         end;}
@@ -877,7 +877,7 @@
       SetWin32SizePoint(MaxWidth, MaxHeight, MinMaxInfo.ptMaxTrackSize);
     end;
   end;
-  
+
   procedure HandleListViewCustomDraw(ALV: TCustomListViewAccess);
     function ConvState(const State: uint): TCustomDrawState;
     begin
@@ -892,8 +892,8 @@
       if state and CDIS_MARKED <> 0 then Include(Result, cdsMarked);
       if state and CDIS_SELECTED <> 0 then Include(Result, cdsSelected);
     end;
- 
-  const 
+
+  const
     CDRFRESULT: array[TCustomDrawResultFlag] of Integer = (
       CDRF_SKIPDEFAULT,
       CDRF_NOTIFYPOSTPAINT,
@@ -902,7 +902,7 @@
       CDRF_NOTIFYPOSTERASE,
       CDRF_NOTIFYITEMERASE
     );
-  var 
+  var
     DrawInfo: PNMLVCustomDraw absolute NMHdr;
     Stage: TCustomDrawStage;
     DrawResult: TCustomDrawResult;
@@ -913,12 +913,12 @@
     case DrawInfo^.dwDrawStage and $7 of //Get drawing state
       CDDS_PREPAINT:  Stage := cdPrePaint;
       CDDS_POSTPAINT: Stage := cdPostPaint;
-      CDDS_PREERASE:  Stage := cdPreErase; 
+      CDDS_PREERASE:  Stage := cdPreErase;
       CDDS_POSTERASE: Stage := cdPostErase;
     else
       Exit;
-    end;  
-    
+    end;
+
     case DrawInfo^.dwDrawStage and (CDDS_ITEM or CDDS_SUBITEM) of
       0: begin //Whole control
         DrawResult := ALV.IntfCustomDraw(dtControl, Stage, -1, -1, [], @DrawInfo^.rc);
@@ -931,7 +931,7 @@
         if DrawInfo^.iSubItem = 0 then Exit;
         DrawResult := ALV.IntfCustomDraw(dtItem, Stage, DrawInfo^.dwItemSpec, DrawInfo^.iSubItem, ConvState(DrawInfo^.uItemState), nil);
       end;
-    else 
+    else
       Exit;
     end;
 
@@ -941,7 +941,7 @@
       then lmNotify.result := lmNotify.result or CDRFRESULT[ResultFlag];
     end;
   end;
-  
+
   function HandleUnicodeChar(AChar: Word): boolean;
   var
     UTF8Char: TUTF8Char;
@@ -1130,15 +1130,23 @@
       else
       begin
         { Handles other reasons for WM_COMMAND }
+
         if Hi(WParam) < 2 then //1 for accelerator 0 for menu
-          TargetObject := GetMenuItemObject else // menuitem or shortcut
+        begin
+          TargetObject := GetMenuItemObject
+        end
+        else // menuitem or shortcut
+        begin
           TargetObject := nil;
+        end;
+
         if TargetObject is TMenuItem then
         begin
           LMessage.Msg := LM_ACTIVATE;
           TargetObject.Dispatch(LMessage);
           lWinControl := nil;
-        end else
+        end
+         else
         begin
           lWinControl := GetWindowInfo(LParam)^.WinControl;
           // buddy controls use 'awincontrol' to designate associated wincontrol
@@ -1235,7 +1243,7 @@
           WinProcess := false;
         end;
       end;
-        
+
       if WinProcess then
       begin
         if ChildWinControl <> nil then
@@ -1478,7 +1486,7 @@
       begin
         PostMessage(Window, WM_LBUTTONDBLCLK, WParam, LParam);
       end;
-      
+
       {$ifndef win32}
       // Gesture recognition process to enable popup menus.
       if (lWinControl.PopupMenu <> nil) then
@@ -1687,6 +1695,7 @@
     WM_NOTIFY:
     begin
       WindowInfo := GetWindowInfo(PNMHdr(LParam)^.hwndFrom);
+
 {$ifdef MSG_DEBUG}
       DebugLn([MessageStackDepth, 'Notify code: ', PNMHdr(LParam)^.code]);
 {$endif}
@@ -2106,7 +2115,7 @@
       if PLMsg^.Result = 0 then
         WinProcess := true;
     end;
-    
+
     CN_CHAR, CN_SYSCHAR:
     begin
       // if key not yet processed, let windows process it
@@ -2293,17 +2302,17 @@
   {$endif}
 
   Result := 0;
- 
+
   LMessage.Result := 0;
   LMessage.Msg := LM_NULL;
 
   case Msg of
-  
+
     WM_CLOSE:
     begin
       DestroyWindow(Window);
     end;
-    
+
     WM_DESTROY :
     begin
       PostQuitMessage(0);
@@ -2370,12 +2379,3 @@
     end;
   end;
 end;
-
-
-
-
-
-
-
-
-
Index: winceint.pp
===================================================================
--- winceint.pp	(revision 18702)
+++ winceint.pp	(working copy)
@@ -106,6 +106,9 @@
      
   WM_LCL_SOCK_ASYNC = WM_USER;
 
+  StartMenuItem = 200;
+
+
 type
 
   { Policy for using the "OK" close button in the title instead of
Index: wincewsmenus.pp
===================================================================
--- wincewsmenus.pp	(revision 18702)
+++ wincewsmenus.pp	(working copy)
@@ -85,7 +85,7 @@
   );
   MenuBarID_L = 40052;
   MenuBarID_R = 40053;
-
+  StartMenuItem = 200;
 var
   MenuItemsList : TStringList;
 
@@ -175,7 +175,7 @@
       fState:=fState or MF_GRAYED;
     if mi.fState and MFS_CHECKED <> 0 then
       fState:=fState or MF_CHECKED;
-    uIDNewItem := mi.wID;
+    uIDNewItem := mi.wID + StartMenuItem;
     if mi.hSubMenu <>  0 then
     begin
       uIDNewItem  := mi.hSubMenu;
@@ -390,7 +390,7 @@
   MenuInfo.cbSize := menuiteminfosize;
   MenuInfo.fMask := MIIM_TYPE;
   MenuInfo.dwTypeData := nil;  // don't retrieve caption
-  GetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, false, @MenuInfo);
+  GetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command + StartMenuItem, false, @MenuInfo);
   if Value then
     MenuInfo.fType := MenuInfo.fType or Flag
   else
@@ -401,7 +401,7 @@
   {$else}
   MenuInfo.dwTypeData := PWideChar(wCaption);
   {$endif}
-  Result := SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, false, @MenuInfo);
+  Result := SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command + StartMenuItem, false, @MenuInfo);
   TriggerFormUpdate(AMenuItem);
 end;
 
@@ -435,7 +435,7 @@
       fState := MFS_DISABLED;
    end;
   end;
-  if not SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, false, @MenuInfo) then
+  if not SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command + StartMenuItem, false, @MenuInfo) then
     DebugLn('SetMenuItemInfo failed: ', GetLastErrorText(GetLastError));
   TriggerFormUpdate(AMenuItem);
 end;
@@ -462,7 +462,7 @@
       cbSize := menuiteminfosize;
       fMask := MIIM_SUBMENU;
     end;
-    GetMenuItemInfo(ParentOfParent, AMenuItem.Parent.Command,
+    GetMenuItemInfo(ParentOfParent, AMenuItem.Parent.Command + StartMenuItem,
                     False, @MenuInfo);
     if MenuInfo.hSubmenu = 0 then // the parent menu item is not yet defined with submenu flag
     begin
@@ -478,7 +478,7 @@
   if AMenuItem.Checked then
     fState := fState or MF_CHECKED;
 
-  cmd := AMenuItem.Command; {value may only be 16 bit wide!}
+  cmd := AMenuItem.Command + StartMenuItem; {value may only be 16 bit wide!}
   if (AMenuItem.Count > 0) then
   begin
     fState := fState or MF_POPUP;
@@ -500,12 +500,11 @@
   MenuInfo.fMask := MIIM_DATA;
   //GetMenuItemInfo(ParentMenuHandle, Index, True, @MenuInfo);
   MenuInfo.dwItemData := PtrInt(AMenuItem);
-  //MenuInfo.wID := AMenuItem.Command;
-  
+  MenuInfo.wID := AMenuItem.Command + StartMenuItem;
   if not SetMenuItemInfoW(ParentMenuHandle, Index, True, @MenuInfo) then
     DebugLn(['SetMenuItemInfoW failed for ', dbgsName(AMenuItem), ' : ', GetLastErrorText(GetLastError)]);
 
-  MenuItemsList.AddObject(IntToStr(AMenuItem.Command), AMenuItem);
+  MenuItemsList.AddObject(IntToStr(AMenuItem.Command + StartMenuItem), AMenuItem);
   TriggerFormUpdate(AMenuItem);
 end;
 
@@ -517,7 +516,7 @@
 class procedure TWinCEWSMenuItem.DestroyHandle(const AMenuItem: TMenuItem);
 begin
   if Assigned(AMenuItem.Parent) then
-    DeleteMenu(AMenuItem.Parent.Handle, AMenuItem.Command, MF_BYCOMMAND);
+    DeleteMenu(AMenuItem.Parent.Handle, AMenuItem.Command + StartMenuItem, MF_BYCOMMAND);
   DestroyMenu(AMenuItem.Handle);
   TriggerFormUpdate(AMenuItem);
 end;
@@ -536,7 +535,7 @@
     uCheck := MF_CHECKED
   else
     uCheck := MF_UNCHECKED;
-  Result := Boolean(Windows.CheckMenuItem(AMenuItem.Parent.Handle, AMenuItem.Command, uCheck));
+  Result := Boolean(Windows.CheckMenuItem(AMenuItem.Parent.Handle, AMenuItem.Command + StartMenuItem, uCheck));
 end;
 
 class procedure TWinCEWSMenuItem.SetShortCut(const AMenuItem: TMenuItem;
@@ -550,7 +549,7 @@
   EnableFlag: Integer;
 begin
   EnableFlag := MF_BYCOMMAND or EnabledToStateFlag[Enabled];
-  Result := Boolean(Windows.EnableMenuItem(AMenuItem.Parent.Handle, AMenuItem.Command, EnableFlag));
+  Result := Boolean(Windows.EnableMenuItem(AMenuItem.Parent.Handle, AMenuItem.Command + StartMenuItem, EnableFlag));
   TriggerFormUpdate(AMenuItem);
 end;
 
WinCEMenuPath.patch (10,733 bytes)   

Paul Ishenin

2009-02-18 02:41

manager   ~0025513

Thanks, patch is applied except one line. Please test and close if ok.

haword

2009-02-18 08:08

reporter   ~0025533

Ok

haword

2011-02-07 12:34

reporter   ~0045864

after 26804 revision this bug is reproducible

Vincent Snijders

2011-02-07 16:53

manager   ~0045875

I set target to 0.9.30 to see if this can be fixed before the 0.9.30 release.

Felipe Monteiro de Carvalho

2011-02-07 17:09

developer   ~0045876

I'd rather not fix this now, because it can break other things in the menu handling.

Vincent Snijders

2011-02-07 17:54

manager   ~0045878

OK. Maybe add it to the release notes at http://wiki.lazarus.freepascal.org/Lazarus_0.9.30_release_notes ?

Felipe Monteiro de Carvalho

2011-02-08 17:10

developer   ~0045902

haword, could you create a new patch? It should be similar, because in my menu code rework I removed the 200 factor. thanks

Felipe Monteiro de Carvalho

2011-08-05 13:33

developer   ~0050466

no feedback

Issue History

Date Modified Username Field Change
2009-02-17 10:28 haword New Issue
2009-02-17 10:28 haword File Added: WinCEMenuPath.patch
2009-02-17 10:28 haword Widgetset => WinCE
2009-02-18 02:41 Paul Ishenin Fixed in Revision => 18738
2009-02-18 02:41 Paul Ishenin LazTarget => post 1.2
2009-02-18 02:41 Paul Ishenin Status new => resolved
2009-02-18 02:41 Paul Ishenin Fixed in Version => 0.9.27 (SVN)
2009-02-18 02:41 Paul Ishenin Resolution open => fixed
2009-02-18 02:41 Paul Ishenin Assigned To => Paul Ishenin
2009-02-18 02:41 Paul Ishenin Note Added: 0025513
2009-02-18 08:08 haword Status resolved => closed
2009-02-18 08:08 haword Note Added: 0025533
2009-02-18 08:31 Paul Ishenin Relationship added has duplicate 0011457
2011-02-07 12:34 haword Status closed => assigned
2011-02-07 12:34 haword Resolution fixed => reopened
2011-02-07 12:34 haword Note Added: 0045864
2011-02-07 12:42 Paul Ishenin Assigned To Paul Ishenin => Felipe Monteiro de Carvalho
2011-02-07 16:53 Vincent Snijders LazTarget post 1.2 => 0.9.30
2011-02-07 16:53 Vincent Snijders Note Added: 0045875
2011-02-07 16:53 Vincent Snijders Target Version => 0.9.30
2011-02-07 17:09 Felipe Monteiro de Carvalho LazTarget 0.9.30 => 0.99.0
2011-02-07 17:09 Felipe Monteiro de Carvalho Note Added: 0045876
2011-02-07 17:10 Felipe Monteiro de Carvalho Relationship added has duplicate 0017519
2011-02-07 17:54 Vincent Snijders Note Added: 0045878
2011-02-07 17:54 Vincent Snijders Target Version 0.9.30 => 0.99.0
2011-02-08 17:10 Felipe Monteiro de Carvalho Note Added: 0045902
2011-08-05 13:33 Felipe Monteiro de Carvalho Status assigned => resolved
2011-08-05 13:33 Felipe Monteiro de Carvalho Resolution reopened => suspended
2011-08-05 13:33 Felipe Monteiro de Carvalho Note Added: 0050466