private string GetCategoryFromObject(object obj, int dispid) { if ((obj != null) && (obj is NativeMethods.ICategorizeProperties)) { NativeMethods.ICategorizeProperties properties = (NativeMethods.ICategorizeProperties)obj; try { int categoryID = 0; if (properties.MapPropertyToCategory(dispid, ref categoryID) == 0) { string categoryName = null; switch (categoryID) { case -11: return(System.Windows.Forms.SR.GetString("PropertyCategoryDDE")); case -10: return(System.Windows.Forms.SR.GetString("PropertyCategoryScale")); case -9: return(System.Windows.Forms.SR.GetString("PropertyCategoryText")); case -8: return(System.Windows.Forms.SR.GetString("PropertyCategoryList")); case -7: return(System.Windows.Forms.SR.GetString("PropertyCategoryData")); case -6: return(System.Windows.Forms.SR.GetString("PropertyCategoryBehavior")); case -5: return(System.Windows.Forms.SR.GetString("PropertyCategoryAppearance")); case -4: return(System.Windows.Forms.SR.GetString("PropertyCategoryPosition")); case -3: return(System.Windows.Forms.SR.GetString("PropertyCategoryFont")); case -2: return(System.Windows.Forms.SR.GetString("PropertyCategoryMisc")); case -1: return(""); } if (properties.GetCategoryName(categoryID, CultureInfo.CurrentCulture.LCID, out categoryName) == 0) { return(categoryName); } } } catch { } } return(null); }
private NativeMethods.ICategorizeProperties GetCategorizeProperties() { if (iCategorizeProperties == null && !axState[checkedCP] && instance != null) { axState[checkedCP] = true; if (instance is NativeMethods.ICategorizeProperties) { iCategorizeProperties = (NativeMethods.ICategorizeProperties) instance; } } return iCategorizeProperties; }
private void ReleaseAxControl() { // This line is like a bit of magic... // sometimes, we crash with it on, // sometimes, with it off... // Lately, I have decided to leave it on... // (oh, yes, and the crashes seemed to disappear...) //cpr: ComLib.Release(instance); this.NoComponentChangeEvents++; ContainerControl f = ContainingControl; if (f != null) { f.VisibleChanged -= this.onContainerVisibleChanged; } try { if (instance != null) { Marshal.FinalReleaseComObject(instance); instance = null; iOleInPlaceObject = null; iOleObject = null; iOleControl = null; iOleInPlaceActiveObject = null; iOleInPlaceActiveObjectExternal = null; iPerPropertyBrowsing = null; iCategorizeProperties = null; iPersistStream = null; iPersistStreamInit = null; iPersistStorage = null; } axState[checkedIppb] = false; axState[checkedCP] = false; axState[disposed] = true; freezeCount = 0; axState[sinkAttached] = false; wndprocAddr = IntPtr.Zero; SetOcState(OC_PASSIVE); } finally { this.NoComponentChangeEvents--; } }
private string GetCategoryFromObject(object obj, int dispid) { if (obj == null) { return(null); } if (obj is NativeMethods.ICategorizeProperties) { NativeMethods.ICategorizeProperties catObj = (NativeMethods.ICategorizeProperties)obj; try { int categoryID = 0; if (NativeMethods.S_OK == catObj.MapPropertyToCategory(dispid, ref categoryID)) { string categoryName = null; switch (categoryID) { case NativeMethods.ActiveX.PROPCAT_Nil: return(""); case NativeMethods.ActiveX.PROPCAT_Misc: return(SR.GetString(SR.PropertyCategoryMisc)); case NativeMethods.ActiveX.PROPCAT_Font: return(SR.GetString(SR.PropertyCategoryFont)); case NativeMethods.ActiveX.PROPCAT_Position: return(SR.GetString(SR.PropertyCategoryPosition)); case NativeMethods.ActiveX.PROPCAT_Appearance: return(SR.GetString(SR.PropertyCategoryAppearance)); case NativeMethods.ActiveX.PROPCAT_Behavior: return(SR.GetString(SR.PropertyCategoryBehavior)); case NativeMethods.ActiveX.PROPCAT_Data: return(SR.GetString(SR.PropertyCategoryData)); case NativeMethods.ActiveX.PROPCAT_List: return(SR.GetString(SR.PropertyCategoryList)); case NativeMethods.ActiveX.PROPCAT_Text: return(SR.GetString(SR.PropertyCategoryText)); case NativeMethods.ActiveX.PROPCAT_Scale: return(SR.GetString(SR.PropertyCategoryScale)); case NativeMethods.ActiveX.PROPCAT_DDE: return(SR.GetString(SR.PropertyCategoryDDE)); } if (NativeMethods.S_OK == catObj.GetCategoryName(categoryID, SafeNativeMethods.GetUserDefaultLCID(), out categoryName)) { return(categoryName); } } } catch (Exception) { } } return(null); }