Help! how to CreateWindow with userdata
HWND CreateWindow(
LPCTSTR lpClassName, // registered class name
LPCTSTR lpWindowName, // window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // menu handle or child identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // window-creation data
);中,
通过最后一个参数 lpParam设置userData,怎么设置不上?而通过SetWindowLong(hwnd,mydata)却可以?具体如下:
/*=====================
* WinMain()中
*/
//...
md=(MyData*)malloc(sizeof(MyData));
//hwnd = CreateDialog (hInstance, szUserLogin, 0, NULL) ;
hwnd = CreateWindow(szUserLogin,szAppName,WS_OVERLAPPEDWINDOW,
0,0,300,300,
NULL,NULL,hInstance,(LPVOID)md);
//...
/*=====================
* WinProc中
*/
//...
switch (message)
{
case WM_CREATE:
{
long i = ((CREATESTRUCT *)lParam)->lpCreateParams;//这里i是md的地址值。
user=GetWindowLong(hwnd,GWL_USERDATA);//??? 这里得到的user为什么总是0。
//...
/* thanx */