Example #1
0
        public virtual void GetOleVerbs(DesignerVerbCollection rval)
        {
            NativeMethods.IEnumOLEVERB verbEnum = null;
            NativeMethods.IOleObject   obj      = axHost.GetOcx() as NativeMethods.IOleObject;
            if (obj == null || NativeMethods.Failed(obj.EnumVerbs(out verbEnum)))
            {
                return;
            }

            Debug.Assert(verbEnum != null, "must have return value");
            if (verbEnum == null)
            {
                return;
            }
            int[] fetched = new int[1];
            NativeMethods.tagOLEVERB oleVerb = new NativeMethods.tagOLEVERB();

            foundEdit       = false;
            foundAbout      = false;
            foundProperties = false;

            while (true)
            {
                fetched[0]           = 0;
                oleVerb.lpszVerbName = null;
                int hr = verbEnum.Next(1, oleVerb, fetched);
                if (hr == NativeMethods.S_FALSE)
                {
                    break;
                }
                else if (NativeMethods.Failed(hr))
                {
                    Debug.Fail("Failed to enumerate through enums: " + hr.ToString());
                    break;
                }

                // Believe it or not, some controls, notably the shdocview control, dont' return
                // S_FALSE and neither do they set fetched to 1.  So, we need to comment out what's
                // below to maintain compatibility with Visual Basic.
                //                 if (fetched[0] != 1) {
                //                     Debug.fail("gotta have our 1 verb...");
                //                     break;
                //                 }
                if ((oleVerb.grfAttribs & NativeMethods.ActiveX.OLEVERBATTRIB_ONCONTAINERMENU) != 0)
                {
                    foundEdit       = foundEdit || oleVerb.lVerb == OLEIVERB_UIACTIVATE;
                    foundAbout      = foundAbout || oleVerb.lVerb == HOSTVERB_ABOUT;
                    foundProperties = foundProperties || oleVerb.lVerb == HOSTVERB_PROPERTIES;

                    rval.Add(new HostVerb(new OleVerbData(oleVerb), handler));
                }
            }
        }
Example #2
0
 internal OleVerbData(NativeMethods.tagOLEVERB oleVerb)
     : base(SR.GetString(SR.AXVerbPrefix) + oleVerb.lpszVerbName, oleVerb.lVerb)
 {
     this.dirties = (oleVerb.grfAttribs & NativeMethods.ActiveX.OLEVERBATTRIB_NEVERDIRTIES) == 0;
 }