哪位大神教下win32 api SendMessage函数用法啊
LRESULT WINAPI SendMessage(
_In_ HWND hWnd,
_In_ UINT Msg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
主要是WPARAM wParam 和 LPARAM lParam参数用法,求具体点分析。
比如我想实现WM_CREATE里生成2个ListView控件,因为牵扯到了Tab控件不能通过((LPNMHDR) lParam)->hwndFrom来判断是哪个ListView控件,怎么判断是哪个控件收到消息?
[解决办法]
CREATESTRUCT cs;
char *name = "create";
cs.hwndParent = m_hWnd;
cs.cx = 100;
cs.cy = 200;
cs.lpszClass = name ;
cs.x = 0;
cs.y = 0;
::SendMessage(m_hWnd,WM_CREATE,NULL,(LPARAM)&cs );
[解决办法]
通过第三个参数来判断。
[解决办法]
SendMessage本身很简单,第三个和第四个参数,要看WM_XXXX这个参数,你要去MSDN上找了。
举个例子:
http://baike.baidu.com/view/1514116.htm
LPARAM和WPARAM在不同的消息的时候,它们的含义是不一样的。
[解决办法]
比如在MSDN里面查WM_CREATE,可以得到:
WM_CREATE
The WM_CREATE message is sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. The window procedure of the new window receives this message after the window is created, but before the window becomes visible. The message is sent before the CreateWindowEx or CreateWindow function returns.
WM_CREATE
lpcs = (LPCREATESTRUCT) lParam; // structure with creation data
Parameters
lParam
Value of lParam. Pointer to a CREATESTRUCT structure that contains information about the window being created. The members of CREATESTRUCT are identical to the parameters of the CreateWindowEx function.
Return Values
If an application processes this message, it should return 0 to continue creation of the window. If the application returns –1, the window is destroyed and the CreateWindowEx or CreateWindow function returns a NULL handle.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Windows Overview, Window Messages, CreateWindow, CreateWindowEx, CREATESTRUCT, WM_NCCREATE