/// <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 acmFormatEnum(IntPtr hAcmDriver, ref AcmFormatDetails formatDetails, AcmFormatEnumCallback callback, IntPtr instance, AcmFormatEnumFlags flags);
public static bool ShowFormatChooseDialog(IntPtr ownerWindowHandle, string windowTitle, AcmFormatEnumFlags enumFlags, WaveFormat enumFormat, out WaveFormat selectedFormat, out string selectedFormatDescription, out string selectedFormatTagDescription) { AcmFormatChoose acmFormatChoose = default(AcmFormatChoose); acmFormatChoose.structureSize = Marshal.SizeOf(acmFormatChoose); acmFormatChoose.styleFlags = AcmFormatChooseStyleFlags.None; acmFormatChoose.ownerWindowHandle = ownerWindowHandle; int num = 200; acmFormatChoose.selectedWaveFormatPointer = Marshal.AllocHGlobal(num); acmFormatChoose.selectedWaveFormatByteSize = num; acmFormatChoose.title = windowTitle; acmFormatChoose.name = null; acmFormatChoose.formatEnumFlags = enumFlags; acmFormatChoose.waveFormatEnumPointer = IntPtr.Zero; if (enumFormat != null) { IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(enumFormat)); Marshal.StructureToPtr(enumFormat, intPtr, false); acmFormatChoose.waveFormatEnumPointer = intPtr; } acmFormatChoose.instanceHandle = IntPtr.Zero; acmFormatChoose.templateName = null; MmResult mmResult = AcmInterop.acmFormatChoose(ref acmFormatChoose); selectedFormat = null; selectedFormatDescription = null; selectedFormatTagDescription = null; if (mmResult == MmResult.NoError) { selectedFormat = WaveFormat.MarshalFromPtr(acmFormatChoose.selectedWaveFormatPointer); selectedFormatDescription = acmFormatChoose.formatDescription; selectedFormatTagDescription = acmFormatChoose.formatTagDescription; } Marshal.FreeHGlobal(acmFormatChoose.waveFormatEnumPointer); Marshal.FreeHGlobal(acmFormatChoose.selectedWaveFormatPointer); if (mmResult != MmResult.AcmCancelled && mmResult != MmResult.NoError) { throw new MmException(mmResult, "acmFormatChoose"); } return(mmResult == MmResult.NoError); }