vc不用mfc函数库怎么生成图形界面
2个回答
展开全部
创建窗口类
实例化窗口类
显示窗口
消息循环
在窗口上创建控件
增加控件消息响应
更多追问追答
追问
怎么在窗口上创建控件和增加控件消息响应 求过程
追答
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CLOSE:
return 1;
break;
case WM_COMMAND:
if(lParam==(LPARAM)hmybutton)
{
SendMessage(hmyedit,WM_GETTEXT,256,(LPARAM)ch);
ShowWindow(hmywnd,SW_HIDE);
}
default:
break;
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
WNDCLASS wnd;
wnd.cbClsExtra=0;
wnd.cbWndExtra=0;
wnd.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wnd.hCursor=LoadCursor(NULL,IDC_CROSS);
wnd.hIcon=LoadIcon(NULL,IDI_ERROR);
wnd.hInstance=NULL;
wnd.lpfnWndProc=WindowProc;
wnd.lpszClassName="wlf";
wnd.lpszMenuName=0;
wnd.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wnd);
hmywnd=CreateWindow("wlf","wlf",WS_OVERLAPPEDWINDOW,0,0,400,100,NULL,NULL,NULL,NULL);
hmyedit=CreateWindow("edit",ch,WS_CHILD | WS_VISIBLE,10,10,370,20,hmywnd,NULL,NULL,NULL);
hmybutton=CreateWindow("button","OK",WS_CHILD | WS_VISIBLE,180,40,40,20,hmywnd,NULL,NULL,NULL);
MSG msg;
while(GetMessage(&msg,hmywnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询