DispatchMessage函数

DipatchMessage函数的功能是将消息派送给窗口过程。通常情况下被用来派送GetMessage函数获得的消息。

函数原型:

LRESULT DispatchMessage(      

    const MSG *lpmsg

);

参数说明:

lpmsg:指向含有消息的MSG结构的指针。

返回值:

返回值是指定窗口过程的返回值。虽然这意味着返回值依赖于消息的分派,但通常该返回值会被忽略。

注意事项:

MSG结构必须包含有效的消息值。如果参数lpmsg指向一个WM_TIMER消息,并且WM_TIMER消息的参数lParam不为NULL,则调用lParam指向的函数,而不是调用窗口过程函数。

注意,应用程序负责检索和调度输入消息到该对话框,大多数程序使用主循环来完成这一工作。然而,要让用户可以通过键盘来进行控制操作,那么该程序必须调用IsDialogMessage函数。

//原文如下:

The DispatchMessage functiondispatches a message to a window procedure. It is typically used to dispatch amessage retrieved by the GetMessage function.

Syntax

LRESULT DispatchMessage(      

    const MSG *lpmsg

);

Parameters

lpmsg

[in] Pointer to an MSGstructure that contains the message.

Return Value

Thereturn value specifies the value returned by the window procedure. Although itsmeaning depends on the message being dispatched, the return value generally isignored.

Remarks

The MSG structuremust contain valid message values. If the lpmsg parameter points to aWM_TIMER message and the lParam parameter of the WM_TIMER messageis not NULL, lParam points to a function that is called instead of thewindow procedure.

Note that the applicationis responsible for retrieving and dispatching input messages to the dialog box.Most applications use the main message loop for this. However, to permit theuser to move to and to select controls by using the keyboard, the applicationmust call IsDialogMessage. For more information, see Dialog Box KeyboardInterface.

Windows 95/98/Me: DispatchMessageWis supported by the Microsoft Layer for Unicode (MSLU). To use this, you mustadd certain files to your application, as outlined in Microsoft Layer forUnicode on Windows 95/98/Me Systems.

 

 

你可能感兴趣的:(DispatchMessage函数)