Re: Another UpdateAllViews doesnt work problem.

Tech-Archive recommends: Fix windows errors by optimizing your registry



Ok, update: the OnUpdate overide works when overiding itself, so it
must be something to do with the way I define the document templates:

CMultiDocTemplate* pChild1Template;
pChild1Template = new CMultiDocTemplate(IDR_MDITestingTYPE,
RUNTIME_CLASS(CMDITestingDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CChild1));
if (!pChild1Template)
return FALSE;
AddDocTemplate(pChild1Template);

CMultiDocTemplate* pChild2Template;
pChild2Template = new CMultiDocTemplate(IDR_MDITestingTYPE,
RUNTIME_CLASS(CMDITestingDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CChild2));
if (!pChild2Template)
return FALSE;
AddDocTemplate(pChild2Template);

Thanks,

Phil Winder
Ajay Kalra wrote:
The updates will be called on the view. What is CChild2? It appears to be
child frame.

--
Ajay Kalra [MVP - VC++]
ajaykalra@xxxxxxxxx


<philipwinder@xxxxxxxxxxxxxx> wrote in message
news:1158885513.089287.121970@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi, fairly simple, I cant get this UpdateAllViews to work, the OnUpdate
function never gets called. heres the code im using:

void CChild1::OnBnClickedButton1()
{

CMDITestingDoc* pDoc = (CMDITestingDoc*)this->GetDocument();
if (pDoc->CMyData.GetData() == 1) pDoc->CMyData.SetData(0);
else pDoc->CMyData.SetData(1);
ASSERT_VALID(pDoc);
pDoc->UpdateAllViews(NULL);

}

void CChild2::OnUpdate(CView* pSender,LPARAM lHint,CObject* pHint)
{
CMDITestingDoc* pDoc = (CMDITestingDoc*)this->GetDocument();
CWnd* pEdit = this->GetDlgItem(IDC_EDIT1);

char buffer[10];
int value = (int)pDoc->CMyData.GetData();
_itoa(value,buffer,10);
pEdit->SetWindowTextA((LPCTSTR) buffer ); // Pass value to text box

}

Many thanks,

Phil Winder


.


Quantcast