예제 #1
0
        private static bool LoadAppendMenu(HMENU hMenuParent, Stream stream)
        {
            // Read flags
            ushort flags = stream.ReadUInt16();

            if ((flags & MF_POPUP) == 0)
            {
                // Regular menu item
                ushort id   = stream.ReadUInt16();
                string text = stream.ReadNullTerminatedString();
                if (string.IsNullOrEmpty(text))
                {
                    text = null;
                }
                User.AppendMenu(hMenuParent, (uint)(flags & ~MF_END), (IntPtr)id, text);
            }
            else
            {
                // Popup menu item
                string text = stream.ReadNullTerminatedString();

                // Load all items
                var popup = User.CreatePopupMenu();
                while (LoadAppendMenu(popup, stream))
                {
                    ;
                }

                // Add it
                User.AppendMenu(hMenuParent, (uint)(flags & ~MF_END), popup.value, text);
            }

            return((flags & MF_END) == 0);
        }
예제 #2
0
 public Win16.MDINEXTMENU Convert()
 {
     return(new Win16.MDINEXTMENU()
     {
         hmenuIn = HMENU.To16(hmenuIn),
         hmenuNext = HMENU.To16(hmenuNext),
         hwndNext = HWND.To16(hwndNext),
     });
 }
예제 #3
0
        public static void Trim()
        {
            // Trim invalid window handles
            foreach (var w in Map.GetAll32().Where(x => !User.IsWindow(x)).ToList())
            {
                Map.Destroy32(w);
            }

            // Also trim menu map
            HMENU.Trim();

            // Clear trim flag
            if (_destroyDepth == 0)
            {
                _needsTrim = false;
            }
        }
예제 #4
0
        private static bool LoadAppendMenu_old(HMENU hMenuParent, Stream stream)
        {
            // Read flags
            ushort flags = (ushort)stream.ReadByte();

            if ((flags & MF_POPUP) == 0)
            {
                // Regular menu item
                ushort id   = stream.ReadUInt16();
                string text = stream.ReadNullTerminatedString();
                if (text.StartsWith("\u0008"))
                {
                    flags |= MF_HELP;
                    text   = text.Substring(1);
                }
                if (string.IsNullOrEmpty(text))
                {
                    text = null;
                }
                User.AppendMenu(hMenuParent, (uint)(flags & ~(MF_END | MF_BITMAP)), (IntPtr)id, text);
            }
            else
            {
                // Popup menu item
                string text = stream.ReadNullTerminatedString();

                // Load all items
                var popup = User.CreatePopupMenu();
                while (LoadAppendMenu_old(popup, stream))
                {
                    ;
                }

                // Add it
                User.AppendMenu(hMenuParent, (uint)(flags & ~MF_END), popup.value, text);
            }

            return((flags & MF_END) == 0);
        }
예제 #5
0
 public static ushort To16(HMENU hMenu)
 {
     return(Map.To16(hMenu.value));
 }