-
April 1st, 2015, 12:37 AM
#1
Auto-close MSG box - Without Button and Title
Hi,
I referred Auto-close message box.
But i like to view the message box with out title bar and buttons. Is possible?
Regards,
SaraswathiSrinath
-
April 1st, 2015, 12:48 AM
#2
Re: Auto-close MSG box - Without Button and Title
Sure, modify the code to remove the title style and hide the buttons.
-
April 1st, 2015, 01:38 AM
#3
Re: Auto-close MSG box - Without Button and Title
Originally Posted by Arjay
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.
Regards,
SaraswathiSrinath
-
April 1st, 2015, 07:42 AM
#4
Re: Auto-close MSG box - Without Button and Title
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"
-
April 7th, 2015, 10:28 AM
#5
Re: Auto-close MSG box - Without Button and Title
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:
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;
}
No sweat!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|