In my native windows mobile app I've got a window that creates a dialog. Lets say my window handle is hMainWnd.
I create the dialog using DialogBoxParam() and passing in hMainWnd as the dialog's parent:
DialogBoxParam(_,_,hMainWnd,_,_);
Let's say the dialog's handle is hDlgWnd. From within the dialog, GetParent() returns hMainWnd as expected:
//We're inside the dialog created above
HWND hParent = GetParent(hDlgWnd); //hParent == hMainWnd
Here's the odd thing, calling GetWindow() to find the children of hMainWnd returns NULL, signifying that it has no children. I would expect the function to return hDlgWnd
//We're inside the main window
HWND hChild = GetWindow(hMainWnd, GW_CHILD); //hChild == NULL
How can a child know its parent when the parent doesn't know its child?