|
-
February 29th, 2016, 04:43 PM
#22
Re: pass variable value from one dialogbox to other/ one class to other class in vc++
 Originally Posted by Alexeyn
comletely wrong unless you mean static variables
Instead of trying to acces private variables of another class
better try to obtain current object of that class and invoke it's(public) functons
//CClass.cpp
...
//Main.cpp global scope ,CClass.h included
CClass cl;
...
//CClassZ.cpp
#include "CClass.h"
extern CClass cl;
CClassZ::Somestuff()
{
cl.whatsoever
}
BUT you cant do it this way with MFC dialogs(coz CDialog-derived constructor does need intra-instance stuff and fails at global scope)
so..
//CDialClass.cpp
...
//Main.cpp global scope ,CDialClass.h included
HWND hd;
CDialApp::InitInstance()
{
CDialClass cl;
...
//after cl window is created somehow
hd=cl.m_hWnd;
//you can do this also inside CDialClass ithelf with hd=this->m_hWnd;
}
...
//CDialClassZ.cpp
#include "CDialClass.h"
extern HWND hd;
CClassZ::Somestuff()
{
//hard
((CDialClass *)CDialog::FromHandle(hd))->whatsoever;
}
The more you add the worse it gets. I really can't even tell what you're trying to say here, how it helps the OP, or how it's an improvement over the previous answers.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|