vc sdk编程 如何使用对话框资源创建主窗口

2024-11-20 12:45:32
推荐回答(2个)
回答1:

#include
#include
#include "resource.h"
HWND dhwnd;
BOOL CALLBACK dlgp(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
int WINAPI _tWinMain(HINSTANCE hinstance,HINSTANCE,LPTSTR lp,int cmd)
{

dhwnd=CreateDialog(0,LPTSTR(IDD_DIALOG1),0,dlgp);
ShowWindow(dhwnd,1);

MSG msg;
ZeroMemory(&msg,sizeof(MSG));
while(msg.message!=WM_QUIT)
{ Sleep(2);
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
}
}

return 0;
}

BOOL CALLBACK dlgp(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{

switch(msg)
{
case WM_INITDIALOG:

break;
case WM_CLOSE:
exit(0);
break;
/*case WM_COMMAND:
switch(LOWORD(wparam))
{case IDC_BUTTON1:
EndDialog(hwnd,0);
break;
}
break;*/

}
return FALSE;
}

//WinSDK的 IDD_DIALOG1 是你的对话框ID

回答2:

建立MFC时,在选项中有一个dialog选项,选那个就行了