Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Communicating between CMySocket and the document.........

I have a SDI application with a CMySocket   class derived from the CSocket class. I have CSocketFile archive all ready and pumping data in and out fine...



Now i want to update one of my document data from the OnRecieve of my CMysocket class and then call UpdateAllViews();

How can i communicate between CMySocket and document clss  ie set  some document data from the OnRecieve handle of CMySocket class.


thanks
0
ghimireniraj
Asked:
ghimireniraj
  • 4
  • 3
1 Solution
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

Have U tried with,

CAAADoc *pDoc = AfxGetMainWnd()->GetDocument();
pDoc->strData += Incomingdata;

For that U may have to include AAADoc.h file

Try it out.
VinExpert
0
 
ghimirenirajAuthor Commented:
>CAAADoc *pDoc = AfxGetMainWnd()->GetDocument();

GetDocument() is not a member of CWnd class
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

I am sorry, here it is

CFileDlgDoc *pDoc = (CFileDlgDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveView()->GetDocument();
      pDoc->strData = "dfdf";

U have to include doc.h and mainframe.h files for it.

Try it out.

VinExpert
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ghimirenirajAuthor Commented:
The solution was absolutely great .I want to give you more points but i just have 50 right now....
0
 
ghimirenirajAuthor Commented:
The solution was absolutely great .I want to give you more points but i just have 50 right now....
0
 
ghimirenirajAuthor Commented:
I had also solved the problem with a crazy way.

I declared a pointer for my view class
globally  like
CSendView* view1;
 then i used  it as in my socket file as

extern  CSendView* view1;

in the initial update of the CSendView
class i had written

view1=this;


But you solution is far better and i will switch to that. It also taught me how i can typecast anduse pointers in other situations.

niraj
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

:) well, there will be many solutions to a prob. But, try not use global variables.

VinExpert
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now