Click to See Complete Forum and Search --> : Writing in view from another dialog
Shahzad
April 6th, 1999, 02:49 PM
I want to write into view window from a dialog (to present data for printer!)
I have simply created CDC object and used TextOut but it is not working.
How can I write into view window from another new dialog.
Please help
delbert Harry
April 6th, 1999, 03:09 PM
What I would try is use a sink approach to accomplish this. What if you had a class that was able to access the Main Frame or childframe depending on which way you go about it. You would have variables in that class that you would set from the dialog box class and you would have functions in the dialog box class that you can call that would take the information in the variables in the class and write that to the screen of the view.
delbert Harry
April 6th, 1999, 03:57 PM
I wrote a sample of what I was talking about in VC4.1. If you want it then send me an email and I will send it to you.
April 7th, 1999, 11:16 AM
add th following to your dialog header:
#include "Your View.h"
class ..
{
public:
friend class CYourView;
CYourView *GetView();
..
};
#ifndef _DEBUG //
inline (CYourView* CYourDialog::GetView()
{ return (CYourView*)pView; }
#endif
add to your dialog-implementationfile(*.cpp):
#ifdef _DEBUG
CYourView *CBautagebuchDoc::GetView()
{
CMDIFrameWnd* pWnd = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd* pChild = (CMDIChildWnd*)pWnd->GetActiveFrame();
if(!pChild)
return NULL;
CView *pView = pChild->GetActiveView();
if(!pView)
return NULL;
POSITION pos = GetFirstViewPosition();
while (pos != NULL && !pView->IsKindOf(RUNTIME_CLASS(CYourView)))
{
pView = GetNextView(pos);
}
return (CYour*)pView;
}
#endif
______________________
now you can do the following in your Dialog Class:
CYourView *pView = getView();
pView->all_your_public_elements_and_functions
by the way: use SetWindowText instead of TextOut!!!
Rene´
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.