Reputation: 9841
I am working in MFC application which has lots of dialog box. I am not able to tell which class or function created this dialog box while debugging.
To illustrate the problem I have created a simple Dialog based MFC application. Run it in debug mode and pause the debugging.
I can see DoModal is called in call stack using CDialog::DoModal()
. How do I understand exactly which function and from which class this DoModal()
is getting called?
Upvotes: 0
Views: 763
Reputation: 3156
You could set your breakpoint in CDialog::OnInitDialog()
, which is eventually called by DoModal()
.
OnInitDialog
method is almost always overridden by the "leaf" CDialog-derived class (although not necessarily) but more importantly, always chained back. So just move up the call stack to the "first" call to OnInitDialog()
and that should reference the class.
If it is not the 'leaf' class, or it was not chained back, @JoeWillcoxson answer still works.
Upvotes: 0
Reputation: 6040
It's easier to find the class if you set a breakpoint in the CDialog constructor. From the call stack from there you will be able to see what your dialog class is.
Upvotes: 2