Message-Only Window using NativeWindow

  • Thread starter Thread starter Andreas Håkansson
  • Start date Start date
A

Andreas Håkansson

Is it possible to create a message-only window using the NativeWindow
and CreateParams classes? How can I set the parent property of the
CreateParams class to HWND_MESSAGE, it expects an IntPtr and
HWND_MESSAGE is defined as (HWND)-3 in WinUser.h

//Andreas
 
Hi,

Andreas Håkansson said:
Is it possible to create a message-only window using the NativeWindow
and CreateParams classes? How can I set the parent property of the
CreateParams class to HWND_MESSAGE, it expects an IntPtr and
HWND_MESSAGE is defined as (HWND)-3 in WinUser.h

HWND's are defined as pointers altough they aren't real pointers.
Probely they are values mapped in some system table.
There's no problem in using a pointer as a value as long as it doesn't get
dereferenced. It's confusing however and I don't know why they choose to do
it this way.

You can see in winuser.h that HWND_MESSAGE is -3 casted to HWND. Since HWND
is defined as a pointer, this means casting a value to a pointer.

This is easy in .NET. Just use the IntPtr constructor:
cp.Parent = IntPtr(-3)

HTH,
greetings
 
Andreas,
Is it possible to create a message-only window using the NativeWindow
and CreateParams classes?

I don't think so. But surely you can create it with CreateWindowEx and
then use NativeWindow.AssignHandle.



Mattias
 
Mattias,

Yep, thats what I thought. I converted the CreateWindowEx API and the
(Extended)WindowStyles (made them enums of uint type) and got the
following

[DllImport("User32.dll", SetLastError=true)]
public static extern IntPtr CreateWindowEx(
WindowStylesExtended dwExStyle,
string lpClassName,
string lpWindowName,
WindowStyles dwStyle,
int x,
int y,
int nWidth,
int nHeight,
int hWndParent,
IntPtr hMenu,
IntPtr hInstance,
IntPtr lpParam);

Then I found myself wondering what ClassName to use, or if I perhaps should
use the RegisterClassEx method to setup a class. In the PSDK I found a class
called "Message", but the PSDK states (for the table I found it in)

"The following table describes the system classes that are available
only for
use by the system. They are listed here for completeness sake."

I tried passing "Message" and it worked, but I'm not sure I should be using
this since it was intended to be used by the system, and might be subjected
to changes in the future?

I found it at PSDK (Feb.2003)

ms-help://MS.PSDK.1033/winui/winui/windowsuserinterface/windowing/
windowclasses/aboutwindow.htm

Cheers,

Andreas
 
Andreas,
Then I found myself wondering what ClassName to use, or if I perhaps should
use the RegisterClassEx method to setup a class.

You could do that, or you could use one of the common system window
classes (button, listbox etc).



Mattias
 
The common control classes would leave a heavier memory footprint,
be it small one in when put in perspective to the main applicatio, am
I correct? Just getting up to speed on what I'm doing ;)

//Andreas

--
ANDREAS HÅKANSSON
STUDENT OF SOFTWARE ENGINEERING
andreas (at) selfinflicted.org
Then I found myself wondering what ClassName to use, or if I perhaps should
use the RegisterClassEx method to setup a class.

You could do that, or you could use one of the common system window
classes (button, listbox etc).



Mattias
 
Back
Top