Example #1
0
        /// <include file='doc\AxHost.uex' path='docs/doc[@for="AxHost.ShowPropertyPages1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void ShowPropertyPages(Control control) {
            try {
                if (!CanShowPropertyPages()) return;
                NativeMethods.ISpecifyPropertyPages ispp = (NativeMethods.ISpecifyPropertyPages) GetOcx();
                NativeMethods.tagCAUUID uuids = new NativeMethods.tagCAUUID();
                try {
                    ispp.GetPages(uuids);
                    if (uuids.cElems <= 0) return;
                }
                catch {
                    return;
                }

                // State oldOcxState = OcxState;

                IDesignerHost host = null;
                if (Site != null)
                    host = (IDesignerHost)Site.GetService(typeof(IDesignerHost));
                
                DesignerTransaction trans = null;
                try {
                    if (host != null)
                        trans = host.CreateTransaction(SR.GetString(SR.AXEditProperties));

                    string name = null;
                    object o = GetOcx();
                    IntPtr handle = (ContainingControl == null) ? IntPtr.Zero : ContainingControl.Handle;
                    SafeNativeMethods.OleCreatePropertyFrame(new HandleRef(this, handle), 0, 0, name, 1, ref o, uuids.cElems, new HandleRef(null, uuids.pElems), Application.CurrentCulture.LCID, 0, IntPtr.Zero);
                }
                finally {
                    if (oleSite != null)
                        ((UnsafeNativeMethods.IPropertyNotifySink)oleSite).OnChanged(NativeMethods.MEMBERID_NIL);

                    if (trans != null)
                        trans.Commit();

                    if (uuids.pElems != IntPtr.Zero)
                        Marshal.FreeCoTaskMem(uuids.pElems);
                }
            }
            catch (Exception t) {
                Debug.Fail(t.ToString());
                throw t;
            }
        }
Example #2
0
 /// <include file='doc\AxHost.uex' path='docs/doc[@for="AxHost.HasPropertyPages"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public bool HasPropertyPages() {
     if (!CanShowPropertyPages()) return false;
     NativeMethods.ISpecifyPropertyPages ispp = (NativeMethods.ISpecifyPropertyPages) GetOcx();
     try {
         NativeMethods.tagCAUUID uuids = new NativeMethods.tagCAUUID();
         try {
             ispp.GetPages(uuids);
             if (uuids.cElems > 0) return true;
         }
         finally {
             if (uuids.pElems != IntPtr.Zero) {
                 Marshal.FreeCoTaskMem(uuids.pElems);
             }
         }
     }
     catch {
     }
     return false;
 }