how to get Dialog handle in a dll ?
I am working in a project where in a dialog is called from a cs project.
This dialog is in dll (vc project).the dialog's handle is null, due to this i am unable to launch the dialog.
Code:
AFX_MANAGE_STATE(AfxGetStaticModuleState())
CFDialog dlg;
int responce = dlg.DoModal();
the dlg handle is NULL(i debugged the Application and found) and the application crashes;
where am i going wrong ?
Re: how to get Dialog handle in a dll ?
dialog window is created within the DoModal call and destroyed just before DoModal returns. So dialog handle exists only between these two "events" and you cannot access it using the code you showed.
Why do you need the dialog handle?
Where exactly and how does your application crash?
1 Attachment(s)
Re: how to get Dialog handle in a dll ?
thanks a lot for the reply.
[code]
AFX_MANAGE_STATE(AfxGetStaticModuleState())
CFDialog dlg;
int responce = dlg.DoModal(); //it fails here and i am unable to launch dialog.
[\code]
i have attached the screen shot.
Re: how to get Dialog handle in a dll ?
The dialog seems failing to create. Which means either dialog resource is wrong/unreachable or the dialog contains common controls while common controls library appears not initialized to he moment of dialog creation. These two are the most frequent reasons of DoModal failure.
I would suggest to call the dll in debug mode from trivial C++ client and go through dialog creation step by step. Hope you have MFC sources installed along with your Visual Studio.
Re: how to get Dialog handle in a dll ?
Quote:
Originally Posted by
dskp
thanks a lot for the reply.
[code]
AFX_MANAGE_STATE(AfxGetStaticModuleState())
CFDialog dlg;
int responce = dlg.DoModal(); //it fails here and i am unable to launch dialog.
[\code]
i have attached the screen shot.
I would expect this. The dialog window is not created until you call the "DoModal" function. IIRC, nothing much happens in the CDialog constructor. Your picture shows the state of the dialog instance after the constructor has been called.
Viggy