Pranit Kothari
Pranit Kothari

Reputation: 9841

How to find exactly from which class DoModal() is called?

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?

enter image description here

Upvotes: 0

Views: 763

Answers (2)

franji1
franji1

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

Joseph Willcoxson
Joseph Willcoxson

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

Related Questions