Windows messages - dead, or just hiding?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've spent the last 3 years programming VC++, and learnt that Windows
programming is all about messages.

Now I'm doing C#, and there isn't a windows message to be seen! Now, I don't
miss those messages at all - in fact I'm very glad to see the end of them,
but I am puzzled as to where they've gone. Has .Net got rid of windows
messages, or are they just hidden inside the CLR, where windows windows (to
use the VC++ term for the real "window" which is actually on the screen) are
sending messages around they way they always did?

Cheers,

Javaman
 
Javaman59 said:
I've spent the last 3 years programming VC++, and learnt that Windows
programming is all about messages.

Now I'm doing C#, and there isn't a windows message to be seen! Now, I
don't
miss those messages at all - in fact I'm very glad to see the end of them,
but I am puzzled as to where they've gone. Has .Net got rid of windows
messages, or are they just hidden inside the CLR, where windows windows
(to
use the VC++ term for the real "window" which is actually on the screen)
are
sending messages around they way they always did?

They are still hiding, certainly. .NET's windowing system is a facade over
Win32 controls, for the most part. You can still access windows messages by
overriding the protected WndProc member on any control, atleast on the full
framework.
However, for the most part you'll never need to bother with them.
 
Thanks Daniel.

I tried out a simple WndProc override to catch messages. It was very easy.
The only hard part was finding the actual message constants (eg WM_PAINT =
0x000F), which aren't visible anywhere in C#. (the doco says they are in
windows.h, but I found them in WinUser.h)

I also followed the trail from WndProc, and found that each Control has an
HWND Handle associated with it (a "windows window" as in my first post). I am
guessing that window at the other end of the handle is an unmanaged part of
the application.

- Javaman
 
Javaman59 said:
Thanks Daniel.

I tried out a simple WndProc override to catch messages. It was very easy.
The only hard part was finding the actual message constants (eg WM_PAINT =
0x000F), which aren't visible anywhere in C#. (the doco says they are in
windows.h, but I found them in WinUser.h)

I believe windows.h includes WinUser.h, and thus windows.h is the proper
include(though I could be wrong). Unfortunatly the runtime doesn't offer
constants for those, I know.
I also followed the trail from WndProc, and found that each Control has an
HWND Handle associated with it (a "windows window" as in my first post). I
am
guessing that window at the other end of the handle is an unmanaged part
of
the application.
Effectivly it is. Its the same basic type of thing internally as any win32
application, HWND's and all.
 
Back
Top