How to add close button in MFC dialog

mfc, visual-c++

Solution

Use the `WS_SYSMENU` style instead of `WS_CLOSE`

Problem

I have an MFC dialog which displays an image. I added this code ``` CDialogEx::OnInitDialog(); SetWindowLong(this->m_hWnd, GWL_STYLE, GetWindowLong(this->m_hWnd, GWL_STYLE) | WS_MINIMIZEBOX | WS_MAXIMIZEBOX |WS_CLOSE); ``` but I still don't get a close button on title bar. Please tell me how to get a close button.

Original source