一个对话框的问题,高手请解!!!,为什么弹不出对话框????
#include "windows.h"#include "stdio.h"
#include "string.h"
#include "menu.h"
HINSTANCE hin;
HDC hdc;
HDC hmem;
HBITMAP hbm;
BITMAP bm;
LRESULT CALLBACK WinProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK DlgProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
HWND hWnd;
HMENU hMenu;
HMENU hMenu1;
MSG Message;
WNDCLASS WndClass;
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WinProc;
WndClass.lpszClassName="whyan";
WndClass.lpszMenuName="NULL";
WndClass.style=CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
RegisterClass(&WndClass);
hMenu=LoadMenu(hInstance,"IDR_MENU1");
hbm=LoadBitmap(hInstance,"IDB_BITMAP1");
GetObject(hbm,sizeof(BITMAP),&bm);
hWnd=CreateWindow("whyan","whyan",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,hMenu,hInstance,NULL);
hMenu1=LoadMenu(hInstance,"IDR_MENU2");
//SetMenu(hWnd,hMenu1);
hin=hInstance;
ShowWindow(hWnd,SW_SHOWNORMAL);
UpdateWindow(hWnd);
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WinProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)
{
HBRUSH hbrush;
HPEN pen;
PAINTSTRUCT pstr;
switch (Message)
{
case WM_CREATE:
hdc=GetDC(hWnd);
hmem=CreateCompatibleDC(hdc);
ReleaseDC(hWnd,hdc);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_NEW:
MessageBox(hWnd,"open file","information",MB_OK);
break;
case IDM_OPEN:
DialogBox(hin,"IDD_DIALOG1",hWnd,DlgProc);
MessageBox(hWnd,"open file","information",MB_OK);
break;
}
break;
case WM_PAINT:
hdc=BeginPaint(hWnd,&pstr);
SetMapMode(hdc,MM_ANISOTROPIC);
pen=(HPEN)GetStockObject(BLACK_PEN);
hbrush=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
SelectObject(hdc,hbrush);
SelectObject(hdc,pen);
RoundRect(hdc,50,120,100,200,15,15);
SelectObject(hmem,hbm);
BitBlt(hdc,0,0,bm.bmWidth,bm.bmHeight,hmem,0,0,SRCCOPY);
EndPaint(hWnd,&pstr);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd,Message,wParam,lParam));
}
return 0;
}
BOOL CALLBACK DlgProc(HWND hdlg,UINT Message,WPARAM wParam,LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
return 1;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
EndDialog(hdlg,0);
return 1;
break;
}
break;
case WM_CLOSE:
EndDialog(hdlg,0);
return 1;
}
return 0;
}