api函数 LRESULT SendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); ParametershWnd [in] Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows. Msg [in] Specifies the message to be sent. wParam [in] Specifies additional message-specific information. lParam [in] Specifies additional message-specific information. Return ValueThe return value specifies the result of the message processing; it depends on the message sent.
函数啊,只是那些参数和返回值类型是mfc中使用的数据类型而已,本质跟基本的C++数据类型一样
呵呵,支持1楼underwing,说的很清楚明白了。
函数申明. 其中的RESULE,HWND,UINT,WPARAM,LPARAM都是数据类型. typedef LONG LRESULT; typedef unsigned int UINT; typedef UINT WPARAM; typedef LONG LPARAM; 通过typedef把基本数据类型重命名了.
恩 初学VC 我只知道使用API必需对其声明
为什么要重命名呢,好象重命名的还真不少,并且是一个LONG就重命名了好多,有必要吗,并且让人头大。
它是属于Windows API函数,SendMessage就是发送消息。 LPCRECT A 32-bit pointer to a constant (nonmodifiable) RECT structure. 是一个指向常量结构体的32位的指针类型!剩下的都是他的一些参数
LRESULT SendMessage( HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
ParametershWnd
[in] Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
Msg
[in] Specifies the message to be sent.
wParam
[in] Specifies additional message-specific information.
lParam
[in] Specifies additional message-specific information.
Return ValueThe return value specifies the result of the message processing; it depends on the message sent.
其中的RESULE,HWND,UINT,WPARAM,LPARAM都是数据类型.
typedef LONG LRESULT;
typedef unsigned int UINT;
typedef UINT WPARAM;
typedef LONG LPARAM;
通过typedef把基本数据类型重命名了.
为什么要重命名呢,好象重命名的还真不少,并且是一个LONG就重命名了好多,有必要吗,并且让人头大。
LPCRECT A 32-bit pointer to a constant (nonmodifiable) RECT structure.
是一个指向常量结构体的32位的指针类型!剩下的都是他的一些参数
LRESULT//返回值类型
SendMessage(//函数名
HWND hwnd, //以下都是参数
UINT uMsg,
WPARAM wParam,
LPARAM lParam); LZ好人啊, 散分拉, 哈哈~~~~~~~
LRESULT SendMessage(
HWND hwnd, //handle to window
UINT uMsg, //message identifier
WPARAM wParam, //first message parameter
LPARAM lParam); //second message parameter
HWND hwnd,//HWND句柄
UINT uMsg,//UINT表示32位无符号字符串
WPARAM wParam,//WPARAM作为参数传递给窗口函数或者回调函数的值,相当于32位整形
LPARAM lParam
); //LPARAM,32位值,作为参数传递给一个窗口过程或回调函数//LRESULT是一种数据类型,是窗口过程或回调函数的32位值;
/*SendMessage()
函数功能:该函数将指定的消息发送到一个或多个窗口。此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回。
函数原型:LRESULT SendMessage(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM IParam);
参数:
hWnd:其窗口程序将接收消息的窗口的句柄。如果此参数为HWND_BROADCAST,则消息将被发送到系统中所有顶层窗口,包括无效或不可见的非自身拥有的窗口、被覆盖的窗口和弹出式窗口,但消息不被发送到子窗口。
Msg:指定被发送的消息。
wParam:指定附加的消息指定信息。
LParam:指定附加的消息指定信息。
返回值:返回值指定消息处理的结果,依赖于所发送的消息。
备注:需要用HWND_BROADCAST通信的应用程序应当使用函数RegisterWindowMessage来为应用程序间的通信取得一个唯一的消息。
*/
这个函数的主要作用是向一个窗体发送一个消息.
LRESULT 是函数的返回类型
uMsg 消息的ID
HWND 表明向哪一个窗体发送,这是窗体的句柄
WPARAM 发送时所带的参数1
LPARAM 发送进所带的参数2
这两个参数都是整型,一般响应消息的函数都都这样定义afx_msg OnMyMessage(WPARAM wParam,LPARAM lParam);
看出来了吧,传消息时,正好将SendMessage的两个参数传进去了,这时候这两个参数就可以用了.
下面计一下typedef 即类型定义
比如你在VC里面这样写,(当然VC里不支持中文)
typedef int 整型
那么你可以这样写代码int a = 10; 整型 b = 0; b = a;关于LRESULT WPARAM LPARAM 类型定义如下:
typedef LONG LRESULT;
typedef unsigned int UINT;
typedef UINT WPARAM;
typedef LONG LPARAM;
其实这个函数这样写就可以
LONG SendMessage(HWND hwnd,UINT uMsg,UINT wParam,LONG lParam);
我想再给你补充一点,不要以为wParam,与lParam只能传整数,你完全可以传个指针过去,然后在消息处理中将这个参数再转成指针,因为在WINDOW中指针就是一个32位的整数而己.
其中的RESULE,HWND,UINT,WPARAM,LPARAM都是数据类型. 然后返回一个值啊。
api如其名,发送消息用的
msg就是消息的ID号
后面的两个参数, 就是要看MSDN进行组建的, 它只是一个32位的内存, 根据不同的消息, 要求传入可能是某个结构的指针, 也可能是某个基本数据类型, 总而言之, 一切按MSDN的要求来做, 这两个参数要什么就传什么, 然后就Send就是了, 不过要弄明白基本的消息, 得花几个月时间
也有这样写的
LRESULT SendMessage( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);