有没有大神能直接不创建MFC工程,而直接用一个main.cpp创建一个CWnd窗口?

xingguyuwang 2013-03-19 01:43:15
求解。。。
感觉创建MFC工程,太繁琐了。
...全文
158 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eleven 2013-05-30
  • 打赏
  • 举报
回复
新建一个Win32 Console Application,勾上支持MFC选项。
#include "stdafx.h"
#include "EXXX.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	else
	{
		// TODO: code your application's behavior here.
		CFrameWnd* pFrame = new CFrameWnd;
		pFrame->Create(NULL, _T("Frame"));
		pFrame->ShowWindow(SW_SHOW);
		pFrame->UpdateWindow();

		MSG msg;
		while(GetMessage(&msg, NULL, NULL, NULL))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return nRetCode;
}
向立天 2013-05-30
  • 打赏
  • 举报
回复
您好 我是本版版主 此帖已多日无人关注 请您及时结帖 如您认为问题没有解决可按无满意结帖处理 另外本版设置了疑难问题汇总帖 并已在版面置顶 相关规定其帖子中有说明 您可以根据规定提交您帖子的链接 如您目前不想结帖只需回帖说明 我们会删除此结帖通知 见此回复三日内无回应 我们将强制结帖 相关规定详见界面界面版关于版主结帖工作的具体办法
xingguyuwang 2013-03-26
  • 打赏
  • 举报
回复
再顶一下。。。
xingguyuwang 2013-03-20
  • 打赏
  • 举报
回复
真的没有大神试过这样做吗?我只需要在main.cpp中创建一个简单的CWnd窗口啊。 不要HWND的方式。
Ginie 2013-03-19
  • 打赏
  • 举报
回复
WIN32,WTL啊
xingguyuwang 2013-03-19
  • 打赏
  • 举报
回复
win32可以创建,但CWnd以前没有创建过,不知道怎么弄。。
引用 3 楼 shen_wei 的回复:
你直接创建一个win32 不就得了。。。
辰岡墨竹 2013-03-19
  • 打赏
  • 举报
回复
呵呵,这都觉得繁琐?MFC可是为你做了很多工作的。当然你可以直接用Win32创建窗口,反正你只要一个CWnd的话,根本没什么用,毕竟MFC中有用的是CFrameWnd和CToolbar、CDocument、CView之类的互动。 但是你很快就会发现,其实这样下去自己写一个功能稍微多点的程序也会很难。毕竟光一个什么都不干不了的有菜单的空白窗口Win32的Demo就有100多行。
shen_wei 2013-03-19
  • 打赏
  • 举报
回复
你直接创建一个win32 不就得了。。。
xingguyuwang 2013-03-19
  • 打赏
  • 举报
回复
能不能写一个具体的例子出来啊?最好能编译通过的。可否?
引用 1 楼 smilenot 的回复:
那跟win32没啥区别了 CWnd wnd; wnd.Create(....); while(wnd.GetMessage()) { Tran... Dispa.... }
smilenot 2013-03-19
  • 打赏
  • 举报
回复
那跟win32没啥区别了 CWnd wnd; wnd.Create(....); while(wnd.GetMessage()) { Tran... Dispa.... }

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧