1

I am working on porting some interop code from the DWM Api in C++ to C#. The DWMWINDOWATTRIBUTE enum only explicitly defines, one value, and I want to know if the remaining values (commented) are correct?

typedef enum _DWMWINDOWATTRIBUTE { 
  DWMWA_NCRENDERING_ENABLED          =  1,
  DWMWA_NCRENDERING_POLICY,          // 2
  DWMWA_TRANSITIONS_FORCEDISABLED,   // 3
  DWMWA_ALLOW_NCPAINT,               // 4
  DWMWA_CAPTION_BUTTON_BOUNDS,       // 5
  DWMWA_NONCLIENT_RTL_LAYOUT,        // 6
  DWMWA_FORCE_ICONIC_REPRESENTATION, // 7
  DWMWA_FLIP3D_POLICY,               // 8
  DWMWA_EXTENDED_FRAME_BOUNDS,       // 9
  DWMWA_HAS_ICONIC_BITMAP,           // 10
  DWMWA_DISALLOW_PEEK,               // 11
  DWMWA_EXCLUDED_FROM_PEEK,          // 12
  DWMWA_CLOAK,                       // 13
  DWMWA_CLOAKED,                     // 14
  DWMWA_FREEZE_REPRESENTATION,       // 15
  DWMWA_LAST                         // 16
} DWMWINDOWATTRIBUTE;

3 Answers 3

5

Yes, in the C++03 and C++11 standards, 7.2 Enumeration declarations [dcl.enum]:

...An enumerator-definition without an initializer gives the enumerator the value obtained by increasing the value of the previous enumerator by one.

Also note that, in the absence of an initializer, the first enum value is 0. From the same section:

If the first enumerator has no initializer, the value of the corresponding constant is zero.

Sign up to request clarification or add additional context in comments.

Comments

1

Yes enum values are incremented automatically. In C# you can also use the same syntax

public enum _DWMWINDOWATTRIBUTE { DWMWA_NCRENDERING_ENABLED = 1,...}

Comments

1

Yes that is correct, if you provide a value for the first entry then all the next entries are obtained by increasing the value of the prev enum by 1.

In this case, since you gave the first enum entry a value the next entries are 2,3,4,... respectively.

If you don't provide it, then it starts with a 0 (by default)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.