瀏覽代碼

MenuBarCalcSize returns the height

svn path=/trunk/mcs/; revision=35148
Jordi Mas i Hernandez 21 年之前
父節點
當前提交
6715f99d72
共有 1 個文件被更改,包括 7 次插入15 次删除
  1. 7 15
      mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs

+ 7 - 15
mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs

@@ -514,37 +514,29 @@ namespace System.Windows.Forms
 			}
 		}
 
-		// Updats the menu rect
-		static public void MenuBarCalcSize (Graphics dc, IntPtr hMenu, Rectangle rect)
+		// Updates the menu rect and returns the height
+		static public int MenuBarCalcSize (Graphics dc, IntPtr hMenu, int width)
 		{
-			int x = 3;
-			int i, y;
-
+			int x = 0;
+			int i = 0;
 			MENU menu = GetMenuFromID (hMenu);
 			MENUITEM item;
 
-			x = rect.X;
-			y = rect.Height + 1;
 			menu.Width = 0;
-
-			i = 0;
 			while (i < menu.items.Count) {
 
 				item = (MENUITEM) menu.items[i];
-				CalcItemSize (dc, item, y, x, true);
+				CalcItemSize (dc, item, 0, x, true);
 				i = i + 1;
 				x += item.rect.Width;
 				item.fState |= MF.MF_MENUBAR;
 
 				if (item.rect.Height > menu.Height)
 					menu.Height = item.rect.Height;
-
-				//Console.WriteLine ("MenuBarCalcSize {0} {1}", item.item.Text, item.rect.X);
 			}
 
 			menu.Width = x;
-
-			//Console.WriteLine ("CalcPopupMenuSize {0} {1}", menu.Width, menu.Height);
+			return menu.Height;
 		}
 
 		// Draws a menu bar in a Window
@@ -554,7 +546,7 @@ namespace System.Windows.Forms
 			Rectangle rect_menu = new Rectangle ();
 
 			if (menu.Height == 0)
-				MenuBarCalcSize (dc, hMenu, rect_menu);
+				MenuBarCalcSize (dc, hMenu, rect_menu.Width);
 
 			rect.Height = menu.Height;
 			rect.Width = menu.Width;