Fix message constants in Interop.ComCtl32.TB.#2372
Fix message constants in Interop.ComCtl32.TB.#2372madewokherd wants to merge 1 commit intodotnet:masterfrom
Conversation
There was a problem hiding this comment.
Thinking about it, I do not believe we should have introduced TB.FIRST in the first place.
Win32 have the following definitions:

Unlike, say LVM_* messages, which have LVM_FIRST message, and all messages are offset from that point, e.g.:

By adding a new member to the enum, we are creating a possibility (as unlikely as it may be) of calling interops with an incorrect value.
E.g. the following isn't jumping out and screaming "I'm incorrect":
User32.SendMessageW(this, (User32.WindowMessage)ComCtl32.TB.FIRST, (IntPtr)index, ref tbbi);So I think we should have defined the enum as follows:
public enum TB : int
{
GETBUTTONINFOW = User32.WM_USER + 63,
SETBUTTONINFOW = User32.WM_USER + 64,
INSERTBUTTONW = User32.WM_USER + 67,
}|
Thank you @madewokherd for spotting it! 👍 |
|
I see this was assigned to me but I'm confused as to what I should do to push this forward. Using the WM_USER constant as you describe makes sense to me. |
I assigned to you since it is your PR :)
To push it forward please make the changes as discussed above |
Codecov Report
@@ Coverage Diff @@
## master #2372 +/- ##
===================================================
+ Coverage 28.47446% 28.48255% +0.00809%
===================================================
Files 999 999
Lines 259573 259573
Branches 36836 36836
===================================================
+ Hits 73912 73933 +21
+ Misses 180838 180822 -16
+ Partials 4823 4818 -5
|
`ToolBar` implementation was removed in dotnet#2157. Closes dotnet#2372
|
I just realised that this enum is used for I wasn't aware Mono still builds WinForms (which is exciting) and depends on our master. If it is indeed so, Mono must also remove deprecated types. |
|
Mono has its own implementation of winforms and will not be affected. Wine Mono, a package used by Wine to provide an open-source replacement for .NET, uses winforms. Removing these controls is not an option for us as we must maintain compatibility with existing .NET applications. |
Toolbar message constants are based on WM_USER, not LVM_FIRST.
Fixes this test case from Mono: https://github.com/mono/mono/blob/8683fa6db798298d576c120dd9e1443cd3c5b6de/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/ToolBarTest.cs#L111
Proposed changes
Customer Impact
Regression?
Risk
Test methodology
Microsoft Reviewers: Open in CodeFlow