typedef unsigned int UINT;
typedef long LONG;
typedef UINT WPARAM;
typedef LONG LPARAM;
在PostMessage或SendMessage中通过WPARAM或者LPARAM将数组传递给消息处理函数
DWORD或其小于等于DWORD(一般为4字节)长度的变量直接传再强转:
unsigned int a =12345;
unsigned int* b = &a;
SendMessage(DWORD(a), DWORD(b));
OnMessage(DWORD wParam, DWORD lParam)
{
unsigned int a =(unsigned int)wParam;
unsigned int* b = (unsigned int*)lParam;
...
}
复杂数据传指针再强转(或提升):
struct a_t
{
int aa;
char ab;
};
a_t a;
SendMessage(DWORD(&a), DWORD(0));
OnMessage(DWORD wParam, DWORD lParam)
{
a_t* pa =(a_t*)wParam;
...
}
///
char *aa;
aa = new char[20];
strcpy(aa, "hello");
SendMessage(WM_USER_MSG, 0, (LPARAM)aa);
===============================
char *aa, bb[20];
aa = (char *)lParam;
strcpy(bb, aa);
delete aa;
.....