我把vc6SDK向导创建的最简单的对话框程序修改了一下,想修改成一个对话框程序,仅仅修改了一点东西就显示不出来对话框,请高手们帮忙看看,多谢了
(主要的修改的地方我都注释出来了)
#include "stdafx.h"
#include "resource.h"#define MAX_LOADSTRING 100
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szWindowClass[MAX_LOADSTRING]; ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
MSG msg;
// HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WIN32APP, szWindowClass, MAX_LOADSTRING); if(!MyRegisterClass(hInstance))
{
::MessageBox(NULL,"Register Class failed...","Prompt",MB_OK);
}
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow)) 
{
return FALSE;
} while (GetMessage(&msg, NULL, 0, 0)) 
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return msg.wParam;
}ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX);  wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = DLGWINDOWEXTRA;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_WIN32APP);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH) (COLOR_BTNFACE+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex);
}BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;
   HMENU hMenu = LoadMenu(hInstance,(LPCSTR)IDC_MENU_TEST);
   hInst = hInstance; // Store instance handle in our global variable   //hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
    //  CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, hMenu, hInstance, NULL);
   hWnd=CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG_MAIN),0,(DLGPROC)WndProc);
   //上边就把建立窗口的函数注释掉,添加了创建对话框的程序,结果就在这里返回失败了
if (!hWnd)
   {
::MessageBox(NULL,"after","Prompt",MB_OK);
return FALSE;
   }
// CheckMenuItem(hMenu,level,MF_CHECKED);
   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);   return TRUE;
}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); HMENU hMenu = LoadMenu(hInst,(LPCSTR)IDC_MENU_TEST);//
GetSubMenu(hMenu,0);
switch (message) 
{ case WM_COMMAND:
wmId    = LOWORD(wParam); 
wmEvent = HIWORD(wParam); 
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
   break;
case IDM_EXIT:
   DestroyWindow(hWnd);
   break;
default:
   return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
HPEN hPen;
hPen=CreatePen(PS_DASH,1,RGB(200,0,0));
SelectObject(hdc,hPen);   //将hPen作为当前画笔
Ellipse(hdc,0,20,40,100);
SetTextAlign(hdc,TA_CENTER);TextOut(hdc,5,100,"Times Roman_Underlined and Itatics",34);
DeleteObject(hPen);                 //删除hPen画笔,释放空间
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE; case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
    return FALSE;
}