vc2008编写的一个对话框显示不出来 20
就一个对话框程序编译无报错,但是执行却不显示任何东西,代码应该都没问题,因为我移植到VC6.0中就能正确显示,我怀疑是对话框没初始化的问题,可是VC6.0的对话框初始化函...
就一个对话框程序编译无报错,但是执行却不显示任何东西,代码应该都没问题,因为我移植到VC6.0中就能正确显示,我怀疑是对话框没初始化的问题,可是VC6.0的对话框初始化函数在VC2008中已经被淘汰了,但我又找不到VC2008中的对话框初始化函数,请求朋友们指点,我写的是SDK程序,非MFC!
源码如下:
/*编译无错误,却不显示对话框!*/
#include "windows.h"
#include "resource.h"
#include "commdlg.h"
BOOL CALLBACK Main_Dialog(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
{
WCHAR MyDialogNAME[]=TEXT("DialogNAME");
DialogBox(hInstance,MyDialogNAME,NULL,Main_Dialog);
return 0;
}
BOOL CALLBACK Main_Dialog(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch (msg)
{
case WM_COMMAND:
{
switch (LOWORD(wparam))
{
case ID_OPEN:
OPENFILENAME ofn;
WCHAR szFile[MAX_PATH];
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = TEXT('\0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("ALL\0*.*\0Text\0*.TXT\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.hwndOwner = hwnd;
ofn.Flags = OFN_EXPLORER |OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn))
{
MessageBox(hwnd,szFile,TEXT(""),MB_OK);
}
break;
case ID_CLOSE:
EndDialog(hwnd,0);
break;
default:
break;
}
}
return 1;
case WM_CLOSE:
EndDialog(hwnd,0);
return 1;
}
return 0;
} 展开
源码如下:
/*编译无错误,却不显示对话框!*/
#include "windows.h"
#include "resource.h"
#include "commdlg.h"
BOOL CALLBACK Main_Dialog(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
{
WCHAR MyDialogNAME[]=TEXT("DialogNAME");
DialogBox(hInstance,MyDialogNAME,NULL,Main_Dialog);
return 0;
}
BOOL CALLBACK Main_Dialog(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch (msg)
{
case WM_COMMAND:
{
switch (LOWORD(wparam))
{
case ID_OPEN:
OPENFILENAME ofn;
WCHAR szFile[MAX_PATH];
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = TEXT('\0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("ALL\0*.*\0Text\0*.TXT\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.hwndOwner = hwnd;
ofn.Flags = OFN_EXPLORER |OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn))
{
MessageBox(hwnd,szFile,TEXT(""),MB_OK);
}
break;
case ID_CLOSE:
EndDialog(hwnd,0);
break;
default:
break;
}
}
return 1;
case WM_CLOSE:
EndDialog(hwnd,0);
return 1;
}
return 0;
} 展开
2个回答
展开全部
资源文件都没复制过去吧,,,,,
追问
汗 我是用VC2008写的,资源文件也都是用VC2008写的!然后编译 无错,但不显示对话框!
然后我再移植到VC6.0中编译就显示了! 不是从VC6.0移植到VC2008!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询