以前做一个对话框style为popup,对应此对话框建立的类(CTextDialog)继承CDialog,其检测是否按下“OK”按钮的代码为:
CTextDialog dlg;
if(dlg.DoModal()==IDOK){}现在做一个对话框style为child,对应此对话框建立的类继承CFormView,其检测是否按下“OK”按钮的代码又怎么写?
注意:要函数,而不是自己建立一个onok()函数。
解决方案 »
- 各位高手,现在windows平台2D显示用什么接口?
- CDockablePane 响应关闭的映射是什么?
- 怎么将最后一条记录写到文件的最前面
- 局域网远程开机
- 到底哪些文件是程序运行时需要的?VS6自带工具DEPENDS查出来的那些都要吗?
- 着急:98下,如何控制关闭进程的顺序!!
- CComObjectCached,CComObjectNoLock.....等类有什么作用?
- 学VC该看什么书?
- 请问这种记忆功能是如何实现的?
- 求图形移动程序
- 如果做一个控制台程序,在这里面对数据库进行操作,利用ODBC API是不是就可以完成对sql数据库的操作?
- 高分请问怎么样动态的创建几个Radio控件,在线急等啊,请高手看过来
GetParent->PostMessage(WM_CLOSE); Make sure that the buttons in CFormView do not have the default IDOK or IDCANCEL identifiers. If they do, then incorrect entries in the message map and incorrect functions for the buttons will be created. http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B98598
我是楼主,如图,左边是CFormView类的对话框,我想要当客户点击OK按钮时,根据此对话框中editbox中的值,能重画右边的窗口,该怎么实现?
图片地址:http://img289.photo.163.com/tuojue/26065042/991843496.jpg
查了很多实例书,都没给出这方面的例子,我是初学者,还停留在实例阶段,这个工程等这个难题解决就差不多完成了。
然后在左边得FormView中得OK按钮的消息响应函数中根据CEdit的值来操作右边的FormView不就OK了吗。
{CXXXView(你右边的View) *pView=(CXXXView*)((CFrameWnd*)AfxGetApp()->m_pMainWnd)->GetActiveView();
pView->Invalidate();
CDialog::OnOK();
}
在左侧窗口的CTextFormView.cpp中加入以上代码(去掉最后一句CDialog::OnOK();),
并增加#include "XXXView.h"(也即MybusView.h,工程为为Mybus).但在编译时在MybusView.h文件中这句上出现了三个错误:
CMybusDoc* GetDocument();三个错误为:e:\microsoft visual studio\myprojects\mybus\mybusview.h(23) : error C2501: 'CMybusDoc' : missing storage-class or type specifierse:\microsoft visual studio\myprojects\mybus\mybusview.h(23) : error C2501: 'CMybusDoc' : missing storage-class or type specifierse:\microsoft visual studio\myprojects\mybus\mybusview.h(23) : error C2501: 'GetDocument' : missing storage-class or type specifiers
可以用CMybusDoc::UpdateAllViews(this,...)更新除本视图外的其他视图.
在CXXXFormView::OnOK里调用就可以了.
CMybusDoc::UpdateAllViews(this,...)后面省略号怎么写?
别笑我,如果我有时间一定好好查书。
注意:C和C++中cpp文件是单独被编译的!
编译时找不到CMybusDoc类的定义就会出现编译错误.应该将#include "MybusView.h"写在 #include "####Doc.h"后面
一切都没问题,可就是按那个确定按扭不好使,打个断点看下竞然在点按扭时不执行void XXXX::OnOK() ;我晕死
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
m_wndSplitter.CreateStatic(this,1,2);
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CTextView),CSize(260,0),pContext);
m_wndSplitter.CreateView(0,1,pContext->m_pNewViewClass,CSize(0,0),pContext);
SetActiveView((CView*)m_wndSplitter.GetPane(0,0));
return TRUE;
}
这个得到就一切OK了
void FormView::OnButton1()
{
CCSplitterView *pView=(CCSplitterView*)((CFrameWnd*)AfxGetApp()->m_pMainWnd)->GetActiveView();
RightView *rView = (RightView *)pView->m_splitter.GetPane(0,1);//有错
rView->str = "hahaha"; pView->Invalidate();
}
我这样写的,可是在我标有错的那句上执行不过去了
void FormView::OnButton1()
{
CCSplitterDoc *pDoc=(CCSplitterDoc*)((CFrameWnd*)AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CCSplitterView* pView;
POSITION pos=pDoc->GetFirstViewPosition();
if(pos!=NULL)
pView=(CCSplitterView*)pDoc->GetNextView(pos);
RightView *rView = (RightView*)pView->m_splitter.GetPane(0,1);
rView->str = "hahaha"; pView->Invalidate();
}
其中str是右边那个View类的成员变量,点完Button1右边就会有hahaha 出来了,
累死我了,呵呵,快放点分安慰一下吧
rView->str = "hahaha";改为rView->str=m_start;//m_start为editbox的变量,执行后写入字母点击按钮右边的窗口不会有字母出来
UpdateData(true);