//------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        // Retreive the dimension of of UI element
        internal NativeMethods.SIZE Size (int iPartId, int iStateId)
        {
            bool fSuccess = false;
            // Default is (0, 0)
            NativeMethods.SIZE size = new NativeMethods.SIZE(0, 0);

            if (!_hTheme.IsInvalid)
            {
                unsafe
                {
                    fSuccess = GetThemePartSize(_hTheme, IntPtr.Zero, iPartId, iStateId, IntPtr.Zero, (int)THEMESIZE.TS_TRUE, &size) == IntPtr.Zero;
                }

            }

            // Falls back uses GetSystemMetrics
            if (!fSuccess)
            {
                // dangerous construct, the iPartId might collide. 
                // When entering an entry, make sure that the ID is not previously used.
                // If it is the case, then an extra parameter needs to be added to this method
                switch (iPartId)
                {
                    case (int) STATUSPARTS.SP_GRIPPER:
                        size.cx = UnsafeNativeMethods.GetSystemMetrics (NativeMethods.SM_CXSIZE);
                        size.cy = UnsafeNativeMethods.GetSystemMetrics (NativeMethods.SM_CXSIZE);
                        break;

                    case (int)SCROLLBARPARTS.SBP_SIZEBOX:
                        size.cx = UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXVSCROLL);
                        size.cy = UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYHSCROLL);
                        break;

                    case (int)SCROLLBARPARTS.SBP_ARROWBTN:
                        size.cx = UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXHSCROLL);
                        size.cy = UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYVSCROLL);
                        break;

                    case (int) WINDOWPARTS.WP_MINBUTTON :
                    case (int) WINDOWPARTS.WP_MAXBUTTON :
                    case (int) WINDOWPARTS.WP_CLOSEBUTTON :
                    case (int) WINDOWPARTS.WP_HELPBUTTON :
                        size.cx = UnsafeNativeMethods.GetSystemMetrics (NativeMethods.SM_CXSIZE);
                        size.cy = UnsafeNativeMethods.GetSystemMetrics (NativeMethods.SM_CXSIZE);
                        break;

                    default:
                        System.Diagnostics.Debug.Assert (false, "Unsupport Type");
                        break;
                }
            }

            return size;
        }
Exemple #2
0
 private NativeMethods.SIZE GetExtent()
 { 
     NativeMethods.SIZE sz = new NativeMethods.SIZE();
     _axOleObject.GetExtent(NativeMethods.DVASPECT_CONTENT, sz);
     return sz;
 } 
Exemple #3
0
        private NativeMethods.SIZE SetExtent(int width, int height) 
        {
            NativeMethods.SIZE sz = new NativeMethods.SIZE();
            sz.cx = width;
            sz.cy = height; 

            bool resetExtents = false; 
            try 
            {
                _axOleObject.SetExtent(NativeMethods.DVASPECT_CONTENT, sz); 
            }
            catch (COMException)
            {
                resetExtents = true; 
            }
            if (resetExtents) 
            { 
                _axOleObject.GetExtent(NativeMethods.DVASPECT_CONTENT, sz);
                try 
                {
                    _axOleObject.SetExtent(NativeMethods.DVASPECT_CONTENT, sz);
                }
                catch (COMException e) 
                {
                    Debug.Fail(e.ToString()); 
                } 
            }
            return GetExtent(); 
        }