mfc窗口中创建控件为什么要用static定义控件句柄
LRESULT CALLBACK WNDP(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
static HWND hButton=CreateWindow("button","my button",WS_CHILD|WS_VISIBLE|BS_CHECKBOX,
200,200,100,40,hWnd,(HMENU)"fe",((LPCREATESTRUCT)lParam)->hInstance,NULL);return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
在WM_CREATE中,如果hButton不定义为static,则编译报错,error C2360: initialization of 'Hbutton' is skipped by 'case' label,这是什么原因
me0079
12 years, 3 months ago