Hi,
I referred Auto-close message box.
But i like to view the message box with out title bar and buttons. Is possible?
Printable View
Hi,
I referred Auto-close message box.
But i like to view the message box with out title bar and buttons. Is possible?
Sure, modify the code to remove the title style and hide the buttons.
set its Border value to None or set Title bars value to false makes empty dialog box.
Dialog Frame, Child, Popup, and Overlapped characteristics have title bar.
Its value like WS_DLGFRAME, WS_CHILE, WS_POPUP, WS_OVERLAPPED.
NONE Style sets empty title bar. but i don't know how to set.
Just create a test program with a regular dialog box and mess with the styles until you get it right. Then make the changes to your program.
To find which styles, do a search in bing or google for "Modal dialog in MFC without a title bar"
I would like to suggest a more reliable method for customizing a message box:
- before calling ::MessageBox, set a CBT Hook.
- in the CBT hook procedure, catch the creation of the message box and subclass it (replace the default dialog procedure with your own, application-defined procedure);
- in the application-defined dialog procedure, handle the messages you want for customizing it (for example, handle WM_INITDIALOG for modifying the styles, adding and/or removing child controls, setting a timer for auto-close, and so on.
You can find an example using raw-WinAPI in this Codeguru article: Fancy Custom MessageBox.
If using MFC, download, have a look and eventually adapt according to your own needs the demo application from this article: AfxMessageBox with Auto-close
Here is an example of how can remove the caption and hide "OK" button:
No sweat! :)Code:LRESULT CAutoMessageBox::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
// Remove caption
ModifyStyle(WS_CAPTION, 0);
// hide "OK" button
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
// other: set timer for auto-close, resize, and so on.
// ...
// ...
return TRUE;
}