public static bool ShowCapPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd) { object ppint = null; ISpecifyPropertyPages pages = null; bool flag; DsCAUUID pPages = new DsCAUUID(); try { Guid capture = PinCategory.Capture; Guid interleaved = MediaType.Interleaved; Guid gUID = typeof(IAMStreamConfig).GUID; if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0) { interleaved = MediaType.Video; if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0) { return(false); } } pages = ppint as ISpecifyPropertyPages; if (pages == null) { return(false); } int num = pages.GetPages(out pPages); num = OleCreatePropertyFrame(hwnd, 30, 30, null, 1, ref ppint, pPages.cElems, pPages.pElems, 0, 0, IntPtr.Zero); flag = true; } catch (Exception exception) { Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + exception.Message); flag = false; } finally { if (pPages.pElems != IntPtr.Zero) { Marshal.FreeCoTaskMem(pPages.pElems); } pages = null; if (ppint != null) { Marshal.ReleaseComObject(ppint); } ppint = null; } return(flag); }
/// <summary> /// Show the property page. Some property pages cannot be displayed /// while previewing and/or capturing. /// </summary> public override void Show(Control owner) { DsCAUUID pPages = new DsCAUUID(); try { int pages = this.specifyPropertyPages.GetPages(out pPages); if (pages != 0) { Marshal.ThrowExceptionForHR(pages); } object specifyPropertyPages = this.specifyPropertyPages; pages = OleCreatePropertyFrame(owner.Handle, 30, 30, null, 1, ref specifyPropertyPages, pPages.cElems, pPages.pElems, 0, 0, IntPtr.Zero); } finally { if (pPages.pElems != IntPtr.Zero) { Marshal.FreeCoTaskMem(pPages.pElems); } } }
/// <summary> /// Returns the object as an ISpecificPropertyPage /// if the object supports the ISpecificPropertyPage /// interface and has at least one property page. /// </summary> protected bool AddIfSupported(object o, string name) { ISpecifyPropertyPages specifyPropertyPages = null; DsCAUUID pPages = new DsCAUUID(); bool wasAdded = false; // Determine if the object supports the interface // and has at least 1 property page try { specifyPropertyPages = o as ISpecifyPropertyPages; if (specifyPropertyPages != null) { int hr = specifyPropertyPages.GetPages(out pPages); if ((hr != 0) || (pPages.cElems <= 0)) { specifyPropertyPages = null; } } } finally { if (pPages.pElems != IntPtr.Zero) { Marshal.FreeCoTaskMem(pPages.pElems); } } // Add the page to the internal collection if (specifyPropertyPages != null) { DirectShowPropertyPage p = new DirectShowPropertyPage(name, specifyPropertyPages); base.InnerList.Add(p); wasAdded = true; } return wasAdded; }
public static bool ShowTunerPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd) { object ppint = null; ISpecifyPropertyPages pages = null; bool flag; DsCAUUID pPages = new DsCAUUID(); try { Guid capture = PinCategory.Capture; Guid interleaved = MediaType.Interleaved; Guid gUID = typeof(IAMTVTuner).GUID; if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0) { interleaved = MediaType.Video; if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0) { return false; } } pages = ppint as ISpecifyPropertyPages; if (pages == null) { return false; } int num = pages.GetPages(out pPages); num = OleCreatePropertyFrame(hwnd, 30, 30, null, 1, ref ppint, pPages.cElems, pPages.pElems, 0, 0, IntPtr.Zero); flag = true; } catch (Exception exception) { Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + exception.Message); flag = false; } finally { if (pPages.pElems != IntPtr.Zero) { Marshal.FreeCoTaskMem(pPages.pElems); } pages = null; if (ppint != null) { Marshal.ReleaseComObject(ppint); } ppint = null; } return flag; }