Martin,
1) Can one use Win32 API functions in VB.Net
Yes, However I would recommend you make sure you really need to & more
importantly want to. I've seen a number of people decide they need to use
API x, although API x is already part of the framework as feature y, they
use API x instead of feature y. In other words use the Framework if its part
of the Framework. Which means you need to learn the Framework ;-)
Normally I try to isolate any Win32 API functions to a single module/class,
think Encapsulation. And to a lesser extent Isolation.
3) are VB.Net windows, underneath the covers, Win32 windows? Yes,
and can be treated as such?
Most of the time, Yes! In fact System.Windows.Forms.Control has a Handle
property which is the Win32 HWND.
I want to use the Win32 API function : SendMessageToDescendants
The problem is SendMessageToDescendants is NOT a Win32 API!!
It is a MFC/ATL API (C++ function), you cannot directly call MFC or ATL
functions. The SendMessageToDescendants function uses the GetTopWindow Win32
API followed by the GetNextWindow Win32 API.
Rather then mess with attempting to call a MFC functions, I would find the
Framework method of doing it. The Control.Controls collection represents all
of the controls on the Form or contained Control. While Form.OwnedForms
represents all the owned forms and Form.MdiChildren represent all the owned
MDI Children.
I would enumerate (For Each) one of these collections and 'send the message'
to each of these, using recursion if needed. Where 'send the message' is
probably a member of an interface that each child implements or a member of
a base class that each child inherits from. Which means I am actually
calling a routine on the object! On rare exceptional cases it would be the
SendMessage Win32 API. Note in order to receive a message sent with
SendMessage you normally override the Control.WndProc sub routine.
Remember .NET is all about OOP. ;-)
Hope this helps
Jay