/// <summary> /// Show Format Choose Dialog /// </summary> /// <param name="ownerWindowHandle">Owner window handle, can be null</param> /// <param name="windowTitle">Window title</param> /// <param name="enumFlags">Enumeration flags. None to get everything</param> /// <param name="enumFormat">Enumeration format. Only needed with certain enumeration flags</param> /// <param name="selectedFormat">The selected format</param> /// <param name="selectedFormatDescription">Textual description of the selected format</param> /// <param name="selectedFormatTagDescription">Textual description of the selected format tag</param> /// <returns>True if a format was selected</returns> public static bool ShowFormatChooseDialog( IntPtr ownerWindowHandle, string windowTitle, AcmFormatEnumFlags enumFlags, WaveFormat enumFormat, out WaveFormat selectedFormat, out string selectedFormatDescription, out string selectedFormatTagDescription) { AcmFormatChoose formatChoose = new AcmFormatChoose(); formatChoose.structureSize = Marshal.SizeOf(formatChoose); formatChoose.styleFlags = AcmFormatChooseStyleFlags.None; formatChoose.ownerWindowHandle = ownerWindowHandle; int maxFormatSize = 200; // guess formatChoose.selectedWaveFormatPointer = Marshal.AllocHGlobal(maxFormatSize); formatChoose.selectedWaveFormatByteSize = maxFormatSize; formatChoose.title = windowTitle; formatChoose.name = null; formatChoose.formatEnumFlags = enumFlags;//AcmFormatEnumFlags.None; formatChoose.waveFormatEnumPointer = IntPtr.Zero; if (enumFormat != null) { IntPtr enumPointer = Marshal.AllocHGlobal(Marshal.SizeOf(enumFormat)); Marshal.StructureToPtr(enumFormat, enumPointer, false); formatChoose.waveFormatEnumPointer = enumPointer; } formatChoose.instanceHandle = IntPtr.Zero; formatChoose.templateName = null; MmResult result = AcmInterop.acmFormatChoose(ref formatChoose); selectedFormat = null; selectedFormatDescription = null; selectedFormatTagDescription = null; if (result == MmResult.NoError) { selectedFormat = WaveFormat.MarshalFromPtr(formatChoose.selectedWaveFormatPointer); selectedFormatDescription = formatChoose.formatDescription; selectedFormatTagDescription = formatChoose.formatTagDescription; } Marshal.FreeHGlobal(formatChoose.waveFormatEnumPointer); Marshal.FreeHGlobal(formatChoose.selectedWaveFormatPointer); if (result != MmResult.AcmCancelled && result != MmResult.NoError) { throw new MmException(result, "acmFormatChoose"); } return(result == MmResult.NoError); }
/// <summary> /// Show Format Choose Dialog /// </summary> /// <param name="ownerWindowHandle">Owner window handle, can be null</param> /// <param name="windowTitle">Window title</param> /// <param name="enumFlags">Enumeration flags. None to get everything</param> /// <param name="enumFormat">Enumeration format. Only needed with certain enumeration flags</param> /// <param name="selectedFormat">The selected format</param> /// <param name="selectedFormatDescription">Textual description of the selected format</param> /// <param name="selectedFormatTagDescription">Textual description of the selected format tag</param> /// <returns>True if a format was selected</returns> public static bool ShowFormatChooseDialog( IntPtr ownerWindowHandle, string windowTitle, AcmFormatEnumFlags enumFlags, WaveFormat enumFormat, out WaveFormat selectedFormat, out string selectedFormatDescription, out string selectedFormatTagDescription) { AcmFormatChoose formatChoose = new AcmFormatChoose(); formatChoose.structureSize = Marshal.SizeOf(formatChoose); formatChoose.styleFlags = AcmFormatChooseStyleFlags.None; formatChoose.ownerWindowHandle = ownerWindowHandle; int maxFormatSize = 200; // guess formatChoose.selectedWaveFormatPointer = Marshal.AllocHGlobal(maxFormatSize); formatChoose.selectedWaveFormatByteSize = maxFormatSize; formatChoose.title = windowTitle; formatChoose.name = null; formatChoose.formatEnumFlags = enumFlags;//AcmFormatEnumFlags.None; formatChoose.waveFormatEnumPointer = IntPtr.Zero; if (enumFormat != null) { IntPtr enumPointer = Marshal.AllocHGlobal(Marshal.SizeOf(enumFormat)); Marshal.StructureToPtr(enumFormat,enumPointer,false); formatChoose.waveFormatEnumPointer = enumPointer; } formatChoose.instanceHandle = IntPtr.Zero; formatChoose.templateName = null; MmResult result = AcmInterop.acmFormatChoose(ref formatChoose); selectedFormat = null; selectedFormatDescription = null; selectedFormatTagDescription = null; if (result == MmResult.NoError) { selectedFormat = WaveFormat.MarshalFromPtr(formatChoose.selectedWaveFormatPointer); selectedFormatDescription = formatChoose.formatDescription; selectedFormatTagDescription = formatChoose.formatTagDescription; } Marshal.FreeHGlobal(formatChoose.waveFormatEnumPointer); Marshal.FreeHGlobal(formatChoose.selectedWaveFormatPointer); if(result != MmResult.AcmCancelled && result != MmResult.NoError) { throw new MmException(result, "acmFormatChoose"); } return result == MmResult.NoError; }
public static extern MmResult acmFormatChoose(ref AcmFormatChoose formatChoose);