初始mfc 需要使用Edit控件 下面是代码 运行的结果只有一个窗体 看不到文本输入框 大家帮忙看看~(CEdit的Create函数中IDC_EDIT是哪来的 我运行时是用1代替的) 我是用vs2005生成的win32application项目
hello.h内容如下
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};class CMainWindow : public CFrameWnd
{
public:
CMainWindow();protected:
DECLARE_MESSAGE_MAP()
};hello.cpp内容如下:
#include<afxwin.h>
#include"hello.h"CMyApp myApp;BOOL CMyApp :: InitInstance()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd -> ShowWindow(m_nCmdShow);
m_pMainWnd -> UpdateWindow();
return TRUE;
}BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd)END_MESSAGE_MAP()CMainWindow::CMainWindow()
{
Create (NULL, _T("我的标题"));CEdit m_wndEdit;
CRect rect(5, 5, 120, 120);
m_wndEdit.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
rect, this, 1);
// m_wndEdit.SetWindowText(_T("ddd"));}
void CMainWindow::OnLButtonDown(UINT nFlag, CPoint point)
{CButton *my_button = new CButton();
my_button -> Create(_T("内容"), WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON, CRect(10, 10, 20, 20), this, IDC_EDIT);}
hello.h内容如下
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};class CMainWindow : public CFrameWnd
{
public:
CMainWindow();protected:
DECLARE_MESSAGE_MAP()
};hello.cpp内容如下:
#include<afxwin.h>
#include"hello.h"CMyApp myApp;BOOL CMyApp :: InitInstance()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd -> ShowWindow(m_nCmdShow);
m_pMainWnd -> UpdateWindow();
return TRUE;
}BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd)END_MESSAGE_MAP()CMainWindow::CMainWindow()
{
Create (NULL, _T("我的标题"));CEdit m_wndEdit;
CRect rect(5, 5, 120, 120);
m_wndEdit.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
rect, this, 1);
// m_wndEdit.SetWindowText(_T("ddd"));}
void CMainWindow::OnLButtonDown(UINT nFlag, CPoint point)
{CButton *my_button = new CButton();
my_button -> Create(_T("内容"), WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON, CRect(10, 10, 20, 20), this, IDC_EDIT);}
解决方案 »
- === 只 谈 Windows 的 ,不 谈 Linux ===
- MFC Activex Controlwrard 点击对话框中的按钮不响应
- 强烈感谢能帮我解决VC预处理编码问题
- 诚招有意在广东汕头工作的软件开发人员,有意者详谈
- 已有XXX虚拟地址``请问可以不通过ReadProcessMemory()来判断这个地址的值是否为0吗?
- 怎样将一段内存中的HTML在CHtmlView中显示出来?
- 谁知道哪里有好看的有个性的桌面浮动工具条软件?
- 请问怎么在启动时将listcontrol里的第一行数据加亮显示(即选中状态)!
- 每天都看到大家在这里提各种各样的问题,我想知道大家这些问题是哪来的?
- 关于图形缩放问题(MFC)
- MeanShift算法的数学解释,还望各位可以介绍一二
- 请推荐一款工具测量代码中各函数执行时间?
{
Create (NULL, _T("我的标题"));CEdit m_wndEdit;
CRect rect(5, 5, 120, 120);
m_wndEdit.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
rect, this, 1);
// m_wndEdit.SetWindowText(_T("ddd"));
}
----------------
你定义的是个局部变量,出了作用域就销毁了,定义为类的成员变量,你要用局部变量也可以,只要后面加上m_wndEdit.UnsubclassWindow();就可以了