You're getting closer, but the comment here is wrong.  You never set hWhoDlg to NULL when the dialog is closed.  Again, see mailread.c for a safer way to do this.  You will use if (hWhoDlg == NULL) instead of if (!IsWindow(hWhoDlg)).