mfc >> CDoc & CView comunication
by Ale » Sun, 19 Mar 2006 00:48:51 GMT
Hi there
I've got an object in my app's Doc class that contains all the info that
i need to draw. The object implements even a Draw method.
All I need to do is to call the Draw method of the Doc class from the
CView class, but I have no idea on how to do it.
What can I do?
thanks
mfc >> CDoc & CView comunication
by Ajay Kalra » Sun, 19 Mar 2006 01:54:37 GMT
Draw method should not be in Document class. Document should simply contain
the data. When data needs to be updated in view, you can call UpdateAllViews
of the document. In your case you probably want to call OnDraw of your
object from OnDraw of the specific view.
mfc >> CDoc & CView comunication
by David Wilkinson » Sun, 19 Mar 2006 02:02:21 GMT
Ale:
Every view can get a pointer to the document by using GetDocument().
However, it is not natural to put drawing code in the document class.
Rather do something like
CMyView::OnDraw(CDC* pDC)
{
CMyDocument* pDocument = GetDocument();
CMyObject* pObject = pDocument->GetMyObject();
CRect rect;
GetClientRect(&rect);
pObject->Draw(pDC, &rect));
}
David Wilkinson
CDoc & CView comunication
by Tom Serface » Tue, 21 Mar 2006 00:20:18 GMT
In addition to what Dave and Ajay wrote, you can also force a redraw of a
view from a document by calling UpdateAllViews() from the CDocument and
having each CView handle an OnUpdate() message. Note that you can pass a
hint in the call to single the view or views to do whatever you want
(including invalidating themselves so they redraw).
Tom
Similar Threads
1. MDI CView and some kind of bar at bottom of CView
2. Display a CDoc
3. comunication between JScript and C#
Hello,
I have a problem of communication between JScript and C#. I must say
that I'm new to both.
In a JS file I have to call a C# function.
In particular I have:
public function Eval(expr : String) : String
{
return eval(expr);
}
And I want to call:
Eval("MyNS.myFunction()");
where myFunction is declared in a C# file, under the namespace MyNS,
and returns a string.
Is it possible to do such a thing without to consider COM objects
(which I've heard to be used in similar problems)?
Note that the .js file is generated dinamically by a CodeDomProvider in
C#.
It is compiled by adding the reference of the .exe file, which contains
myfunction():
parameters.ReferencedAssemblies.Add("MyApp.exe");
So the call Eval("MyNS.myFunction()"); will be done with Reflection
One more question: is there another way to use the jscript function
eval in C#? Maybe compiling a .js module (not dinamically and not using
reflection) that can be used by a C# module?
Thank you.
Alessandro
4. Forms comunication - CSharp/C#
5. Fast Multiple Application Comunication
This post is realy to get some opinions on the best way of getting fast
comunication between multiple applications. I have scowered the web for
imformation on this subject and have just found conflicting views and
far from ideal solutions.
My application has to send small amounts of data about 50bytes to
multiple client applications. The catch is that this has to happen
about 1000 times a second.
My first attempt was .net remotting which I have to say worked very
well. After I developed a host of helper classes to get around such
problems as events it works fine and seems to work. However it is no
where near fast enough and as you start to reach the desired refresh
rate the CPU races the memory usage goes through the roof and the
entire system keels over.
So I have reached the conclusion that remoting is not going to provide
me with the answer. That leaves me with a question, what else? Here is
a list of the candidates I have found to date:
1. Named Pipes
2. Custom Remotting Sink
3. Mutex
4. TCP Socket
Unfortunatly all these solutions seem to have problems. A named pipe is
not part of the .net framework and does not seem to support message
notification very well. I am not even sure if a custom romting Sink
will actually improve things. Again Mutex's are not inherant in the
.net framework; they are not object orientated and are highly
discouraged by Microsoft. A TCP Socket would require allot of work to
construct wrappers and comunications layers, I want an easy life.
So I would apreciate comments on the best method to achieve high
performance and fast inter application comunication. I should say that
primarily I am concerned with applications running on the same machine
and idealy it would be asynchronous.
6. Instable COM-comunication to OutOfProcess-Server
7. Serial Comunication - MODEM TO MODEM
Hi All,
Anyone have same knowledge in serial comunication?
I need establish comunicatiom between 2 modems, any one have any idea how to
this work?
For sample. I have one machine that have a modem and call to other machine
that have oder modem, and this machines establish comunicatiom.
Really in this case the first machine is a POS that call to server
(Win2003).
Anyone have same idea? I need a clarification.
Thanks to all.
8. inter process comunication