// top / left が 0 なら、親ウインドウの中心とこのウィンドウの中心が合うようにする
if (top == 0 && left == 0) {
CWnd* pParentWnd = (CWnd*)GetParent();
if (pParentWnd)
{
CRect parentRect;
pParentWnd->GetWindowRect(&parentRect);
CRect dialogRect;
GetWindowRect(&dialogRect);
int parentCenterX = parentRect.left + (parentRect.Width() / 2);
int parentCenterY = parentRect.top + (parentRect.Height() / 2);
int dialogWidth = dialogRect.Width();
int dialogHeight = dialogRect.Height();
left = parentCenterX - (dialogWidth / 2);
top = parentCenterY - (dialogHeight / 2);
}
}