Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WM_APP or WM_USER

285 views
Skip to first unread message

JD

unread,
May 28, 2000, 3:00:00 AM5/28/00
to
When defining a new message should I use WM_APP + 400 or WM_USER + 400?

And should I use + 400 like I see in other examples or can I also use + 1?

Thanks,
Jan Derk

Claude

unread,
May 28, 2000, 3:00:00 AM5/28/00
to
I use WM_USER in my projects and never got any problems with that.
If you take a look at the Win32 Help you'll see that you can start to
enumerate your own messages with WM_USER+0

Regards,
Claude-

JD schrieb:

Jan Derk

unread,
May 29, 2000, 3:00:00 AM5/29/00
to
So the conclusion is that both WM_USER and WM_APP work fine. I just do not
understand the difference between the two.

JD

> I use WM_USER in my projects and never got any problems with that.
> If you take a look at the Win32 Help you'll see that you can start to
> enumerate your own messages with WM_USER+0
>

Urhixidur

unread,
May 29, 2000, 3:00:00 AM5/29/00
to
In article <393239f6@dnews>,

"Jan Derk" <nos...@nospamland.com> wrote:
> > > When defining a new message should I use WM_APP + 400 or WM_USER + 400?
> > > And should I use + 400 like I see in other examples or can I also use +
> > > 1?
> >
> > I use WM_USER in my projects and never got any problems with that.
> > If you take a look at the Win32 Help you'll see that you can start to
> > enumerate your own messages with WM_USER+0
>
> So the conclusion is that both WM_USER and WM_APP work fine. I just do not
> understand the difference between the two.

Message numbers in the range (0 through WM_USER - 1) are reserved for use
by Windows.

Message numbers in the range (WM_USER through WM_APP - 1) can be defined
and used by an application to send messages within a private window class.
These values cannot be used to define messages that are meaningful throughout
an application, because some predefined window classes already define values
in this range. For example, predefined control classes such as BUTTON, EDIT,
LISTBOX, and COMBOBOX may use these values. Messages in this range should
not be sent to other applications unless the applications have been designed
to exchange messages and to attach the same meaning to the message numbers.

Message numbers in the range (WM_APP through 0xBFFF) are reserved for
future use by Windows.

Message numbers in the range (0xC000 through 0xFFFF) are defined at run
time when an application calls the RegisterWindowMessage function to retrieve
a message number for a string. All applications that register the same
string can use the associated message number for exchanging messages. The
actual message number, however, is not a constant and cannot be assumed to be
the same between different Windows sessions.

Message numbers in the range (greater than 0xFFFF) are reserved for future
use by Windows.


Conclusion : DO NOT USE WM_APP ! ! ! Depending on the need, use the
[WM_USER..WM_APP[ range (messages internal to a component) or use
RegisterWindowMessage (system-wide private messaging).

Daniel U. Thibault
a.k.a. Urhixidur
a.k.a. Sire Bohémond de Nicée


Sent via Deja.com http://www.deja.com/
Before you buy.

Pieter Zijlstra

unread,
May 29, 2000, 3:00:00 AM5/29/00
to
Jan Derk wrote...

> So the conclusion is that both WM_USER and WM_APP work fine.

No

> I just do not understand the difference between the two.


From messages.pas
WM_APP = $8000;
WM_USER = $0400;

From win32.hlp
<<
0 through WM_USER-1
- Messages reserved for use by Windows.

WM_USER through 0x7FFF
- Integer messages for use by private window classes.

0x8000 through 0xBFFF
- Messages reserved for future use by Windows.

0xC000 through 0xFFFF
- String messages for use by applications.

Greater than 0xFFFF
- Reserved by Windows for future use.
>>

So you can use WM_USER+0 to WM_USER+31743
You could also say that WM_USER+x must be
smaller then WM_APP

- Pieter


Jan Derk

unread,
May 30, 2000, 3:00:00 AM5/30/00
to
Thanks for letting me know that I should use WM_USER. However, it means that
the Delphi 5 help file contains erronious information.

Delphi 5 help file:
"A message identifier is an integer-sized constant. Windows reserves the
messages below 1,024 for its own use, so when you declare your own messages
you should start above that level.
The constant WM_APP represents the starting number for user-defined
messages. When defining message identifiers, you should base them on WM_APP.

Be aware that some standard Windows controls use messages in the
user-defined range. These include list boxes, combo boxes, edit boxes, and
command buttons. If you derive a component from one of these and want to
define a new message for it, be sure to check the Messages unit to see which
messages Windows already defines for that control."

Win32.hlp:
"Windows reserves message-identifier values in the range 0x0000 through
0x03FF (the value of WM_USER - 1) and 0x8000 through 0xBFFF for
system-defined messages. Applications cannot use these values for private
messages.
Values in the range 0x0400 (the value of WM_USER) through 0x7FFF are
available for message identifiers defined by an application for its own use.
Values in the range 0xC000 through 0xFFFF are available for message
identifiers defined by an application for use in communicating with windows
in other applications. "

So Borland should update it's help file and their messages example????

Jan Derk

0 new messages