diff --git a/Source/Core/Controls/FieldsEditorControl.cs b/Source/Core/Controls/FieldsEditorControl.cs index 4d59361a..458192db 100755 --- a/Source/Core/Controls/FieldsEditorControl.cs +++ b/Source/Core/Controls/FieldsEditorControl.cs @@ -598,7 +598,7 @@ namespace CodeImp.DoomBuilder.Controls enumscombo.Location = new Point(cellrect.Left, cellrect.Top); enumscombo.Width = cellrect.Width; int internalheight = cellrect.Height - (enumscombo.Height - enumscombo.ClientRectangle.Height) - 6; - General.SendMessage(enumscombo.Handle, General.CB_SETITEMHEIGHT, new IntPtr(-1), new IntPtr(internalheight)); + General.SetComboBoxItemHeight(enumscombo, internalheight); // Select the value of this field (for DropDownList style combo) foreach(EnumItem i in enumscombo.Items) diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs index a9332316..23ed3f0b 100755 --- a/Source/Core/General/General.cs +++ b/Source/Core/General/General.cs @@ -51,10 +51,24 @@ namespace CodeImp.DoomBuilder #if NO_WIN32 - internal static bool LockWindowUpdate(IntPtr hwnd) { return true; } - internal static bool MessageBeep(MessageBeepType type) { return true; } - internal static int SendMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam) { return 0; } - internal static int PostMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam) { return 0; } + internal static void InvokeUIActions(MainForm mainform) + { + // This implementation really should work universally, but it seemed to hang sometimes on Windows. + // Let's hope the mono implementation of Winforms works better. + mainform.Invoke(new System.Action(() => { mainform.ProcessQueuedUIActions(); })); + } + + internal static bool MessageBeep(MessageBeepType type) + { + System.Media.SystemSounds.Beep.Play(); + return true; + } + + internal static bool LockWindowUpdate(IntPtr hwnd) + { + // This can be safely ignored. It is a performance/flicker optimization. It might not even be needed on Windows anymore. + return true; + } internal unsafe static void ZeroPixels(PixelColor* pixels, int size) { @@ -63,6 +77,11 @@ namespace CodeImp.DoomBuilder pixels[i] = transparent; } + internal static void SetComboBoxItemHeight(ComboBox combobox, int height) + { + // Only used by FieldsEditorControl. Not sure what its purpose is, might only be visual adjustment that isn't strictly needed? + } + #else [DllImport("user32.dll")] internal static extern bool LockWindowUpdate(IntPtr hwnd); @@ -73,12 +92,22 @@ namespace CodeImp.DoomBuilder internal unsafe static void ZeroPixels(PixelColor* pixels, int size) { ZeroMemory(new IntPtr(pixels), size * sizeof(PixelColor)); } [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CallingConvention = CallingConvention.StdCall)] - internal static extern int SendMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam); + static extern int SendMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam); - [DllImport("user32.dll", EntryPoint = "PostMessage", SetLastError = true, CallingConvention = CallingConvention.StdCall)] - internal static extern int PostMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam); + internal static void SetComboBoxItemHeight(ComboBox combobox, int height) + { + SendMessage(combobox.Handle, General.CB_SETITEMHEIGHT, new IntPtr(-1), new IntPtr(height)); + } - [DllImport("user32.dll", SetLastError = true)] + [DllImport("user32.dll", EntryPoint = "PostMessage", SetLastError = true, CallingConvention = CallingConvention.StdCall)] + static extern int PostMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam); + + internal static void InvokeUIActions(MainForm mainform) + { + PostMessage(mainform.Handle, General.WM_UIACTION, IntPtr.Zero, IntPtr.Zero); + } + + [DllImport("user32.dll", SetLastError = true)] internal static extern bool MessageBeep(MessageBeepType type); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index 21fedaeb..d42d54ad 100755 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -4144,7 +4144,7 @@ namespace CodeImp.DoomBuilder.Windows object syncobject = new object(); List queuedActions = new List(); - void ProcessQueuedUIActions() + internal void ProcessQueuedUIActions() { List queue; lock (syncobject) @@ -4175,7 +4175,7 @@ namespace CodeImp.DoomBuilder.Windows } if (notify) - General.PostMessage(Handle, General.WM_UIACTION, IntPtr.Zero, IntPtr.Zero); + General.InvokeUIActions(this); } }