2

Is there a way to loop through all MFC Child Dialogs, MDI frames and etc? And is there a way to find out which dialog or window I am looping through?

Pops
  • 30,199
  • 37
  • 136
  • 151
faya
  • 5,535
  • 11
  • 37
  • 49

2 Answers2

7

Taken from Анатолий Тутов (https://web.archive.org/web/20140110220804/http://www.asis.ru/posts/27):

for (CWnd *pWnd = GetWindow(GW_CHILD);  pWnd != NULL;  pWnd = pWnd->GetNextWindow(GW_HWNDNEXT))
{
    //Insert your code here. pWnd is a pointer to control window.
}
Oliver Zendel
  • 2,695
  • 34
  • 29
  • It looks like there's a capitalization typo in the code near the end of the line: `pWnd = pwnd->GetNextWindow(GW_HWNDNEXT)` - should be `pWnd->`, not `pwnd->` – Krease Apr 01 '14 at 17:38
5

You could use EnumChildWindows to iterate through child windows of certain window.

Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212