How to find dialog icon location in c++

So I'm working on some existing project when I try to add a new item a dialog box open, sometimes means 1 out of 10 times dialog icon will spread all over the dialog window, I'm not able to see what's causing this issue and where should I go to resolve it. I also wanted to see their coordinates and display it using Alert Message in c++.

How to get size and location of a control placed on a dialog in MFC?

I have tried using this but it giving null in pWnd

I haven't worked on C++ project earlier so I'm stuck because of this issue.