Message constant values or magic numbers? (C#)

L

LPeter

I didn't find any namespace for some Windows constants when I working in .NET
CF and C# (e.g. WM_PAINT or any other message constants).
I can use direct values of these message-constants but I don't like use any
"magic number" in my source codes.
It would be better if I used a namespace-constant (e.g.
System.Windows.Forms.MessageValue.WM_PAINT or somethink like this).
I can create this namespace but I think that it should exists in .NET
Compact Framework library.
Using values from standard windows.h (winuser.h) header file can make a
mistake because some constants in CE differ from constants in other
Windows versions (e.g. see WH_KEYBOARD_LL windows hook message).
The questions are:
1. Are there any namespaces to enumerate these constant values?
2. If not, how can I find a correct values for Windows messages instead of
using "magic numbers"?

LPeter
 
C

Chris Tacke, eMVP

1. Are there any namespaces to enumerate these constant values?

No, there aren't any.
2. If not, how can I find a correct values for Windows messages instead of
using "magic numbers"?

Look them up in the SDK headers. winuser.h is the most common. There's no
way to "query" them, you have to hard code them in.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top