Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add close button in MFC dialog

Tags:

visual-c++

mfc

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.

like image 692
Khushboo Avatar asked Sep 10 '25 06:09

Khushboo


1 Answers

Use the WS_SYSMENU style instead of WS_CLOSE

like image 178
manuell Avatar answered Sep 13 '25 09:09

manuell