Coder's Guild Mailing List

Re: DOS Interrupts vs Windows Messages

Posted by Hal Bonnin on 2000-06-21

> PS Is there ANY reason why a Windows program might want to call interrupts
> anymore?

no. windows wont let you and if you did do it it would crash the computer.

> I want to write a program that will sit in the background, and respond to
> various Windows messages.

this is the function call. you cant do this from OWL or MFC easly(its build
into the framework). you should make a basic windows api program.

i dont have any samples of code here at home so will have to get it
tomorrow.

GetMessage will get the message so you can check it and then work on it or
pass it on.
PeekMessge will let you look at it but wont process it.

i have to look at my old code to be sure.

//  help file
PeekMessage
The PeekMessage function dispatches incoming sent messages, checks the
thread message queue for a posted message, and places the message (if any)
in the specified structure.

BOOL PeekMessage(
  LPMSG lpMsg,         // message information
  HWND hWnd,           // handle to window
  UINT wMsgFilterMin,  // first message
  UINT wMsgFilterMax,  // last message
  UINT wRemoveMsg      // removal options
);
Parameters
lpMsg
[out] Pointer to an MSG structure that receives message information.
hWnd
[in] Handle to the window whose messages are to be examined.
wMsgFilterMin
[in] Specifies the value of the first message in the range of messages to be
examined.
wMsgFilterMax
[in] Specifies the value of the last message in the range of messages to be
examined.
wRemoveMsg
[in] Specifies how messages are handled. This parameter can be one of the
following values. Value Meaning
PM_NOREMOVE Messages are not removed from the queue after processing by
PeekMessage.
PM_REMOVE Messages are removed from the queue after processing by
PeekMessage.


You can optionally combine the value PM_NOYIELD with either PM_NOREMOVE or
PM_REMOVE. This flag prevents the system from releasing any thread that is
waiting for the caller to go idle (see WaitForInputIdle).

By default, all message types are processed. To specify that only certain
message should be processed, specify one of more of the following values.
Value Meaning
PM_QS_INPUT Windows 98, Windows 2000: Process mouse and keyboard messages.
PM_QS_PAINT Windows 98, Windows 2000: Process paint messages.
PM_QS_POSTMESSAGE Windows 98, Windows 2000: Process all posted messages,
including timers and hotkeys.
PM_QS_SENDMESSAGE Windows 98, Windows 2000: Process all sent messages.



Return Values
If a message is available, the return value is nonzero.

If no messages are available, the return value is zero.

Remarks
PeekMessage retrieves only messages associated with the window identified by
the hWnd parameter or any of its children as specified by the IsChild
function, and within the range of message values given by the wMsgFilterMin
and wMsgFilterMax parameters. If hWnd is NULL, PeekMessage retrieves
messages for any window that belongs to the current thread making the call.
(PeekMessage does not retrieve messages for windows that belong to other
threads.) If hWnd is -1, PeekMessage only returns messages with a hWnd value
of NULL, as posted by the PostThreadMessage function. If wMsgFilterMin and
wMsgFilterMax are both zero, PeekMessage returns all available messages
(that is, no range filtering is performed). Note that GetMessage will always
retrieve WM_QUIT messages, no matter which values you specify for
wMsgFilterMin and wMsgFilterMax.

The WM_KEYFIRST and WM_KEYLAST constants can be used as filter values to
retrieve all keyboard messages; the WM_MOUSEFIRST and WM_MOUSELAST constants
can be used to retrieve all mouse messages.

During this call, the system delivers pending messages that were sent to
windows owned by the calling thread using the SendMessage,
SendMessageCallback, SendMessageTimeout, or SendNotifyMessage function. The
system may also process internal events. Messages are processed in the
following order:

Sent messages
Posted messages
Input (hardware) messages and system internal events
Sent messages (again)
WM_PAINT messages
WM_TIMER messages
To retrieve input messages before posted messages, use the wMsgFilterMin and
wMsgFilterMax parameters.

The PeekMessage function normally does not remove WM_PAINT messages from the
queue. WM_PAINT messages remain in the queue until they are processed.
However, if a WM_PAINT message has a null update region, PeekMessage does
remove it from the queue.

Requirements
  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winuser.h; include Windows.h.
  Library: Use User32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also
Messages and Message Queues Overview, Message and Message Queue Functions,
GetMessage, IsChild, MSG, WaitForInputIdle, WaitMessage