Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move DrawEdge to Interop User32 #2835

Merged
merged 1 commit into from Feb 13, 2020
Merged

Move DrawEdge to Interop User32 #2835

merged 1 commit into from Feb 13, 2020

Conversation

@gpetrou
Copy link
Contributor

gpetrou commented Feb 9, 2020

Proposed changes

  • Move DrawEdge to Interop User32.
Microsoft Reviewers: Open in CodeFlow
@gpetrou gpetrou requested a review from dotnet/dotnet-winforms as a code owner Feb 9, 2020
@msftbot msftbot bot assigned gpetrou Feb 9, 2020
@codecov

This comment has been minimized.

Copy link

codecov bot commented Feb 9, 2020

Codecov Report

Merging #2835 into master will increase coverage by 0.01256%.
The diff coverage is n/a.

@@                 Coverage Diff                 @@
##              master       #2835         +/-   ##
===================================================
+ Coverage   59.52976%   59.54232%   +0.01255%     
===================================================
  Files           1237        1237                 
  Lines         429911      429911                 
  Branches       38783       38783                 
===================================================
+ Hits          255925      255979         +54     
+ Misses        168606      168552         -54     
  Partials        5380        5380                 
Flag Coverage Δ
#Debug 59.54232% <100.00000%> (+0.01255%) ⬆️
#production 32.22593% <100.00000%> (+0.02127%) ⬆️
#test 98.96848% <ø> (ø) ⬆️
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
private static extern BOOL DrawEdge(IntPtr hDC, ref RECT rect, uint edge, uint flags);

This comment has been minimized.

Copy link
@RussKie

RussKie Feb 10, 2020

Member

We need to import the enums as well: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-drawedge
We already have EDGE and BDR enums:

[Flags]
public enum EDGE : uint
{
RAISEDOUTER = BDR.RAISEDOUTER,
SUNKENOUTER = BDR.SUNKENOUTER,
RAISEDINNER = BDR.RAISEDINNER,
SUNKENINNER = BDR.SUNKENINNER,
RAISED = RAISEDOUTER | RAISEDINNER,
SUNKEN = SUNKENOUTER | SUNKENINNER,
ETCHED = SUNKENOUTER | RAISEDINNER,
BUMP = RAISEDOUTER | SUNKENINNER,
}

[Flags]
public enum BDR : uint
{
RAISEDOUTER = 0x0001,
SUNKENOUTER = 0x0002,
RAISEDINNER = 0x0004,
SUNKENINNER = 0x0008,
OUTER = RAISEDOUTER | SUNKENOUTER,
INNER = RAISEDINNER | SUNKENINNER,
RAISED = RAISEDOUTER | RAISEDINNER,
SUNKEN = SUNKENOUTER | SUNKENINNER,
}

This comment has been minimized.

Copy link
@RussKie

RussKie Feb 10, 2020

Member

Thinking further about it, we probably should have 2 different definitions, e.g.:

        [DllImport(Libraries.User32, ExactSpelling = true)]
        private static extern BOOL DrawEdge(IntPtr hDC, ref RECT rect, BDR edge, BF flags);

        [DllImport(Libraries.User32, ExactSpelling = true)]
        private static extern BOOL DrawEdge(IntPtr hDC, ref RECT rect, EDGE edge, BF flags);

image

But in #2033 we have extended the EDGE enum beyond the Win32 definition (@hughbe any recollection as to why it was done?).
So I think the interop should look like:

        [DllImport(Libraries.User32, ExactSpelling = true)]
        private static extern BOOL DrawEdge(IntPtr hDC, ref RECT rect, EDGE edge, BF flags);

As well as Border3DStyle needs to be fixed, see #2033 (comment)

@gpetrou gpetrou force-pushed the gpetrou:DrawEdge branch from 5c97a04 to bbf170b Feb 13, 2020
@RussKie RussKie merged commit 19f4a35 into dotnet:master Feb 13, 2020
5 checks passed
5 checks passed
WIP Ready for review
Details
dotnet-winforms CI Build #20200212.13 succeeded
Details
dotnet-winforms CI (Build Windows Debug) Build Windows Debug succeeded
Details
dotnet-winforms CI (Build Windows Release) Build Windows Release succeeded
Details
license/cla All CLA requirements met.
Details
@msftbot msftbot bot added this to the 5.0 milestone Feb 13, 2020
@RussKie RussKie added the enhancement label Feb 13, 2020
@RussKie

This comment has been minimized.

Copy link
Member

RussKie commented Feb 13, 2020

Thank you

@gpetrou gpetrou deleted the gpetrou:DrawEdge branch Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.