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 gpetrou commented Feb 9, 2020

Proposed changes

  • Move DrawEdge to Interop User32.
Microsoft Reviewers: Open in CodeFlow

@gpetrou gpetrou requested a review from a team as a code owner February 9, 2020 16:18
@ghost ghost assigned gpetrou Feb 9, 2020
@codecov
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@ghost ghost added the 📭 waiting-author-feedback The team requires more information from the author label Feb 10, 2020
@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Feb 13, 2020
@RussKie RussKie merged commit 19f4a35 into dotnet:master Feb 13, 2020
@ghost ghost added this to the 5.0 milestone Feb 13, 2020
@RussKie RussKie added the enhancement Product code improvement that does NOT require public API changes/additions label Feb 13, 2020
@RussKie
Copy link
Member

RussKie commented Feb 13, 2020

Thank you

@gpetrou gpetrou deleted the DrawEdge branch February 13, 2020 07:36
@dotnet dotnet locked as resolved and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants