sdk编程中 hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;

来源:百度知道 编辑:UC知道 时间:2024/06/02 00:05:36
case WM_CREATE :
hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON)) ;
cxIcon = GetSystemMetrics (SM_CXICON) ;
cyIcon = GetSystemMetrics (SM_CYICON) ;
return 0 ;

// hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
1.lParam代表的是哪个的lParam?
2.->hInstance这样用表示什么?

操作系统会传递给winmain一个hinstance,int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
);
lParam是消息结构体中的成员,这里当然就是指WM_CREATE消息,Specifies additional information about the message

lParam是操作系统调用你的窗口过程传给你的参数 他根据处理消息的不同含义也会不同

当在处理WM_CREATE消息时 lParam里面保存的是一指针既LPCREATESTRUCT结构的地址 其中有一个域名为hInstance

((LPCREATESTRUCT) lParam)->hInstance 就是通过保存在lParam里面的地址取出LPCREATESTRUCT结构里面的hInstance 既
程序的实例句柄