我从CEditView基类派生了一个CMyEditView类,然后在CMainFrame中定义了一个CMyEditView的成员变量m_wndEdit,在用m_wndEdit成员变量调用Create成员函数时将用到7个参数,参照msdn上,如下:
virtual BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);请问lpszClassName和lpszWindowName参数应该如何填写,我试过都用NULL,编译后可以通过,但运行程序后出错.请高手指教一二.
virtual BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);请问lpszClassName和lpszWindowName参数应该如何填写,我试过都用NULL,编译后可以通过,但运行程序后出错.请高手指教一二.
解决方案 »
- 直接tcp连接,能够使用家里的计算机连接公网的带ip的服务器吗?
- 关于文件分割传输的问题,请高手多多指教!急
- DoModal()无法显示对话框
- 关于记事本的设计
- Activex中添加CComboBox为何不能下拉
- VB调用VC写的ocx时,怎样才能传递一个int类型指针,令变量的值在ocx函数中改变
- 高分求救:在程序中实现给定进程ID,将该进程应用激活到最前,该应用不一定有可见窗口
- 用了ActiveSkin换了皮肤的程序,怎样才能在没有安装过该软件的系统上运行?
- 散分,小问题,在线等待
- 讨论并请教处理高手-获取图片中白框的数目的疑问
- 关于edit box和listbox的问题(在线等待。急于高手指教)
- 如何进行程序界面的自动操作
CRect Rect;
Rect.top = ...;
...
const CRect& CellRect = Rect;
m_wndEdit->Create( NULL, Text, WS_VISIBLE, CellRect, this, NULL, NULL);
////////编辑控件///////////
if(!m_wndEdit.Create(NULL,"1212",WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_MULTILINE|ES_WANTRETURN,CRect(0,0,0,0),&m_wndMyBar2,101))
return -1;
问题是当我进入程序对这个创建好的视图进行字符输入的时候抱错,内存不能为"read";
当我将该视图设为只读后,写法如下
if(!m_wndEdit.Create(NULL,"12121",ES_READONLY|WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_MULTILINE|ES_WANTRETURN,CRect(0,0,0,0),&m_wndMyBar2,101))
return -1;
虽然这样程序运行时没问题,当然也不能对视图进行字符输入了,但是程序退出以后抱错.
-----------------------------------------------------------------------------
我用CEdit类,而不用CEditView类就完全没有什么问题.CEdit类的成员变量调用Create函数的写法如下:
if(!m_wndEdit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_MULTILINE|ES_WANTRETURN,CRect(0,0,0,0),&m_wndMyBar2,101))
return -1;
-------------------------------------------------------------------------------
有人用相同的方法做过类似vc++界面,遇到过这种问题嘛?
CWnd* CreateView( CCreateContext* pContext, UINT nID = AFX_IDW_PANE_FIRST );Return ValuePointer to a CWnd object if successful; otherwise NULL.ParameterspContextSpecifies the type of view and document.nIDThe ID number of a view.ResCall CreateView to create a view within a frame. Use this member function to create “views” that are not CView-derived within a frame. After calling CreateView, you must manually set the view to active and set it to be visible; these tasks are not automatically performed by CreateView.创建成功后,注意:you must manually set the view to active and set it to be visible!!
显示每项的图标。你不必管理图标资源。项排序首先通过文件夹,然后通过文件名(如果选择了)。你可以获得每项的全路径名;你可以设置它的其始路径;你可以选择一个子路径。在对话框里使用该控制:1、在对话框资源加入树控制2、在对话框头文件定义成员变量CDirTreeCtrl m_DirTree;
3、在InitDialog中加入下列代码:BOOL CTreeDialog::OnInitDialog()
{
CDialog::OnInitDialog();
TCHAR szWorkDir[MAX_PATH];// TODO: Add extra initialization here
// Here we subclass our CDirTreeCtrl
if ( !m_TreeCtrl.m_hWnd )
{
if ( m_TreeCtrl.SubclassDlgItem( IDC_TREE1, this ) )
{
m_TreeCtrl.DisplayTree( NULL /*Display all*/,
TRUE /* TRUE = Display Files*/ );_getcwd( szWorkDir, 256 );
// set the Path to the current Work-Directory
m_TreeCtrl.SetSelPath( szWorkDir );
}
}return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}在视图类里使用该控制:在视图的头文件中定义该控制的成员变量和标识符ID_TREECTRL;修改视图类的Create函数;修改视图类的OnSize函数。BOOL CLeftView::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID,
CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base classBOOL bRet;bRet = CWnd::Create(lpszClassName,
lpszWindowName,
dwStyle,
rect,
pParentWnd,
nID,
pContext);// this part creates the TreeCtrl and use the CLeftView
// as his parent Windowif ( m_DirTree.m_hWnd == NULL && bRet )
{
bRet = m_DirTree.Create(WS_CHILD | TVS_LINESATROOT |
TVS_HASBUTTONS | WS_VISIBLE |
TVS_HASLINES,
CRect(0, 0, 0, 0),
this
ID_TREECTRL );
if ( bRet )
m_DirTree.DisplayTree( NULL, TRUE );
}return bRet;
}void CLeftView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);// TODO: Add your message handler code here
if ( m_DirTree.m_hWnd )
m_DirTree.SetWindowPos( NULL, 0, 0, cx, cy, SWP_NOZORDER | SWP_NOMOVE );
}
是不是只有当用到切分窗口的时候才能创建与某个切分后的窗口相对应的视图呢?