void TestDialog() { int hr; hr = m_ivcd.ShowDialog(VfwCompressDialogs.QueryAbout, IntPtr.Zero); Debug.Assert(hr == 0); hr = m_ivcd.ShowDialog(VfwCompressDialogs.QueryConfig, IntPtr.Zero); Debug.Assert(hr == 0); hr = m_ivcd.ShowDialog(VfwCompressDialogs.About, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); hr = m_ivcd.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); }
/// <summary> /// Displays a property page for a filter /// </summary> /// <param name="dev">The filter for which to display a property page</param> public static void DisplayPropertyPage(IBaseFilter dev, IntPtr hwndOwner) { Trace.WriteLine("Tangra.DirectShowVideoBase: Showing properties page on managed thread " + Thread.CurrentThread.ManagedThreadId); //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = dev as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { try { compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } } return; } //Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); // Create and display the OlePropertyFrame object oDevice = (object)dev; hr = OleCreatePropertyFrame(hwndOwner, 0, 0, filterInfo.achName, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.ReleaseComObject(pProp); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } }
public static void ShowDevicePropertyPages(IBaseFilter filter, IntPtr hWndOwner) { int hResult = 0; ISpecifyPropertyPages propPages = filter as ISpecifyPropertyPages; if (propPages != null) { try { // get the name of the filter from the FilterInfo struct hResult = filter.QueryFilterInfo(out var filterInfo); DsError.ThrowExceptionForHR(hResult); // get the propertypages from the property bag hResult = propPages.GetPages(out var caGUID); DsError.ThrowExceptionForHR(hResult); // create and display the OlePropertyFrame object[] oDevice = new[] { (object)filter }; hResult = Ole.OleAut32.OleCreatePropertyFrame(hWndOwner, 0, 0, filterInfo.achName, 1, oDevice, caGUID.cElems, caGUID.ToGuidArray(), 0, 0, 0); DsError.ThrowExceptionForHR(hResult); // release COM objects if (caGUID.pElems != IntPtr.Zero) { Marshal.FreeCoTaskMem(caGUID.pElems); } if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } } finally { Marshal.ReleaseComObject(propPages); } } else { // if the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead IAMVfwCompressDialogs compressDialog = filter as IAMVfwCompressDialogs; if (compressDialog != null) { hResult = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hResult); } return; } }
/// <summary> /// Displays a property page for a filter /// </summary> /// <param name="dev">The filter for which to display a property page</param> private void DisplayPropertyPage(IBaseFilter dev) { //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = dev as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } else { MessageBox.Show("Item has no property page", "No Property Page", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } //Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); //Create and display the OlePropertyFrame object oDevice = (object)dev; hr = OleCreatePropertyFrame(this.Handle, 0, 0, filterInfo.achName, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); Marshal.ReleaseComObject(oDevice); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); }
/// <summary> /// Displays a property page for a filter /// </summary> /// <param name="parentHandle">An <see cref="IntPtr"/> with the handle for the parent window of the dialog.</param> /// <param name="dev">The <see cref="IBaseFilter"/> for which to display a property page.</param> public static void DisplayPropertyPage(IntPtr parentHandle, IBaseFilter dev) { // Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages properties = dev as ISpecifyPropertyPages; int hr = 0; if (properties == null) { // If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } return; } // Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID captureGUID; hr = properties.GetPages(out captureGUID); DsError.ThrowExceptionForHR(hr); // Check for property pages on the output pin IPin pin = DsFindPin.ByDirection(dev, PinDirection.Output, 0); ISpecifyPropertyPages properties2 = pin as ISpecifyPropertyPages; if (properties2 != null) { DsCAUUID captureGUID2; hr = properties2.GetPages(out captureGUID2); DsError.ThrowExceptionForHR(hr); if (captureGUID2.cElems > 0) { int guidSize = Marshal.SizeOf(typeof(Guid)); // Create a new buffer to hold all the GUIDs IntPtr p1 = Marshal.AllocCoTaskMem((captureGUID.cElems + captureGUID2.cElems) * guidSize); // Copy over the pages from the Filter for (int x = 0; x < captureGUID.cElems * guidSize; x++) { Marshal.WriteByte(p1, x, Marshal.ReadByte(captureGUID.pElems, x)); } // Add the pages from the pin for (int x = 0; x < captureGUID2.cElems * guidSize; x++) { Marshal.WriteByte(p1, x + (captureGUID.cElems * guidSize), Marshal.ReadByte(captureGUID2.pElems, x)); } // Release the old memory Marshal.FreeCoTaskMem(captureGUID.pElems); Marshal.FreeCoTaskMem(captureGUID2.pElems); // Reset caGUID to include both captureGUID.pElems = p1; captureGUID.cElems += captureGUID2.cElems; } } // Create and display the OlePropertyFrame object device = (object)dev; hr = Oleaut32.OleCreatePropertyFrame(parentHandle, 0, 0, filterInfo.achName, 1, ref device, captureGUID.cElems, captureGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // Release COM objects Marshal.FreeCoTaskMem(captureGUID.pElems); Marshal.ReleaseComObject(properties); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } }
/// <summary> /// Show the property page. Some property pages cannot be displayed /// while previewing and/or capturing. /// </summary> public override void Show(Control owner) { vfwCompressDialogs.ShowDialog(VfwCompressDialogs.Config, owner.Handle); }
public void DisplayPropertyPage() { if (theDevice != null) { Marshal.ReleaseComObject(theDevice); theDevice = null; } //Create the filter for the selected video input device string devicepath = _filter.Name; // cd.VideoSource; //comboBox1.SelectedItem.ToString(); theDevice = CreateFilter(FilterCategory.VideoInputDevice, devicepath); IBaseFilter dev = theDevice; //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = dev as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } return; } //Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); // Check for property pages on the output pin IPin pPin = DsFindPin.ByDirection(dev, PinDirection.Output, 0); ISpecifyPropertyPages pProp2 = pPin as ISpecifyPropertyPages; if (pProp2 != null) { DsCAUUID caGUID2; hr = pProp2.GetPages(out caGUID2); DsError.ThrowExceptionForHR(hr); if (caGUID2.cElems > 0) { int soGuid = Marshal.SizeOf(typeof(Guid)); // Create a new buffer to hold all the GUIDs IntPtr p1 = Marshal.AllocCoTaskMem((caGUID.cElems + caGUID2.cElems) * soGuid); // Copy over the pages from the Filter for (int x = 0; x < caGUID.cElems * soGuid; x++) { Marshal.WriteByte(p1, x, Marshal.ReadByte(caGUID.pElems, x)); } // Add the pages from the pin for (int x = 0; x < caGUID2.cElems * soGuid; x++) { Marshal.WriteByte(p1, x + (caGUID.cElems * soGuid), Marshal.ReadByte(caGUID2.pElems, x)); } // Release the old memory Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.FreeCoTaskMem(caGUID2.pElems); // Reset caGUID to include both caGUID.pElems = p1; caGUID.cElems += caGUID2.cElems; } } // Create and display the OlePropertyFrame try { object oDevice = (object)dev; hr = OleCreatePropertyFrame(_parent.Handle, 10, 10, filterInfo.achName, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); } catch (Exception E) { // DsError.ThrowExceptionForHR(hr); } // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.ReleaseComObject(pProp); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } }
internal static void _DisplayPropertyPage(object filter_or_pin, IntPtr hwndOwner) { if (filter_or_pin == null) { return; } //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = filter_or_pin as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = filter_or_pin as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } return; } string caption = string.Empty; if (filter_or_pin is IBaseFilter) { //Get the name of the filter from the FilterInfo struct IBaseFilter as_filter = filter_or_pin as IBaseFilter; FilterInfo filterInfo; hr = as_filter.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); caption = filterInfo.achName; if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } } else if (filter_or_pin is IPin) { //Get the name of the filter from the FilterInfo struct IPin as_pin = filter_or_pin as IPin; PinInfo pinInfo; hr = as_pin.QueryPinInfo(out pinInfo); DsError.ThrowExceptionForHR(hr); caption = pinInfo.name; } // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); // Create and display the OlePropertyFrame object oDevice = (object)filter_or_pin; hr = NativeMethodes.OleCreatePropertyFrame(hwndOwner, 0, 0, caption, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.ReleaseComObject(pProp); }
private void OnRButtonDown(Point eLocation) { Filter filter = graph.FilterInPoint(mousepos); if (filter != null) { Pin pin = filter.PinInPoint(mousepos); if (pin != null) { movingStart = mousepos; connectingPin = pin; } else //filter right click { rightClickedFilter = filter; ContextMenu menu = new ContextMenu(); if (FilterGraphTools.HasPropertyPages(filter.BaseFilter)) menu.MenuItems.Add("Property page", ShowPropertyPage); IAMVfwCompressDialogs vfw = filter.BaseFilter as IAMVfwCompressDialogs; if (vfw != null) { if (vfw.ShowDialog(VfwCompressDialogs.QueryConfig, Handle) == 0) menu.MenuItems.Add("VfW compressor: Config", VfWConfig); if (vfw.ShowDialog(VfwCompressDialogs.QueryAbout, Handle) == 0) menu.MenuItems.Add("VfW compressor: About", VfWAbout); } if ((filter.BaseFilter as ISampleGrabber) != null) { menu.MenuItems.Add("Set media type", SetSGMediaType); menu.MenuItems.Add("Watch grabbed samples", WatchSampleGrabber); } menu.MenuItems.Add("Scan interfaces", ScanInterfaces); if (filter.filterProps.DisplayName.Length > 0) { menu.MenuItems.Add("Add to favorites", AddToFavorites); menu.MenuItems.Add("Find this filter in the list", FindFilterInList); } if ((filter.BaseFilter as IPersistStream) != null) { menu.MenuItems.Add("Save state to C++ code", SaveFilterStateToCode); menu.MenuItems.Add("Save state to C# code", SaveFilterStateToCodeCS); } menu.Show(this, eLocation); } } else //out of filter right click { ContextMenu menu = new ContextMenu(); menu.MenuItems.Add("Render file...", RenderFile); menu.MenuItems.Add("Add source filter...", AddSourceFilter); menu.MenuItems.Add("Load graph...", LoadGraph); if (savedFileName != null) menu.MenuItems.Add("Save graph", SaveGraph); menu.MenuItems.Add("Save graph as...", SaveGraphAs); menu.MenuItems.Add("See event log...", ShowEventLog); menu.MenuItems.Add("Arrange filters", delegate { graph.LayoutFilters(); graph.RecalcPaths(); Invalidate(); }); menu.MenuItems.Add("Refresh graph", delegate { graph.ReloadGraph(); Invalidate(); }); menu.Show(this, eLocation); } }