Scrollbar within an AfxMessageBox
Hello everybody,
my problem is that i have an AfxMessageBox(msg) where msg is a CString object.
msg is too long, it does not fit on the screen, so i need a scrollbar.
I did not found anything, so i hope i am retrieving some help in this forum ?!
My mainclass where the AfxMessageBox has to show some important messages is
class CMyMainClass : public CDocument
I am programming with MS VS 6.
I hope that someone could help me on !
Best regards,
#50
Re: Scrollbar within an AfxMessageBox
Why don't you add some newlines to the string so it wont be to long ?
Re: Scrollbar within an AfxMessageBox
i need a vertically scrollbar, because there are to many lines ... ;)
Re: Scrollbar within an AfxMessageBox
if you really need a scrollbar you need to write your own messagebox class. if the message you are showing in the message box is too long, no one will spend time reading it. keep it concise.
1 Attachment(s)
Re: Scrollbar within an AfxMessageBox
As already discussed here a message box is only for displaying (short) messages.
However, let's say, we have a requirement:
"Must be possible to close any informative message-box either by pushing the <OK> button or after a pre-defined time; additionally it has to display a vertical progress-bar showing the remaining time".
Our MFC application already has hundreds of AfxMessageBox calls so writing our own message-box function/class to replace them is not the best solution.
Weird or not, is has to be done... ;)
A message box which is shown by a call of MessageBox API function (or AfxMessageBox if using MFC) is a modal dialog so normally we have not any control after creating it.
Luckily, we can start by taking a look at Fancy Custom MessageBox article to get the idea: using a CBT hook to subclass the message-box dialog window. After that, once we have one application-defined procedure attached, it's a piece of cake to add controls, set timers, and so on...
We can adapt that to a MFC application knowing that
AfxMessageBox internally calls the CWinApp:: DoMessageBox virtual function.
So, we have to override that function and install a CBT hook before calling the base class method.
Attached here is an example.
[ later edit ]
Intentionally, I have chosen a different scenario just to be a little bit more interesting/practical/fun :).
Returning to the OP requirements: normally, the message-box is used for short messages which make no sense to use scroll-bars. For long messages use multi-line edit controls or edit views which have built-in scroll capability.
Re: Scrollbar within an AfxMessageBox
Quote:
Originally Posted by ovidiucucu
Returning to the OP requirements: normally, the message-box is used for short messages which make no sense to use scroll-bars. For long messages use multi-line edit controls or edit views which have built-in scroll capability.
Thanks a lot for the answers.
one point why i am using AfxMessageBox is, that i did not know another possibility in this special situation ...
can you give me a more detailed hint what you think i should use ... please ?!
i am a totally novice in programming ... especially with the MFC.
so an explicit code what other options to print messages to the screen i could use in my problem setting would be a huge help !
best regards,
#50
Re: Scrollbar within an AfxMessageBox
Hello everybody ...
i am still working on solving my problem ... unfortunately ...
my new way is to use another box to show the message.
first question:
what kind of message box would you prefer ?
i played a little bit with the wizards and wanted to use the edit boxes, with some scrolling bars. but instead of beginning a newline there is a black |.
This is of course not what i want ?!
second question:
Can anybody give me another possibility to show my (very very long message) ?!
Best regards!
#50
Re: Scrollbar within an AfxMessageBox
Quote:
Originally Posted by Raute50
... but instead of beginning a newline there is a black |.
This is of course not what i want ?!
You sould use two symbols CR LF ("\r\n") to force the text in the edit control to go to the new line.
Quote:
Originally Posted by Raute50
second question:
Can anybody give me another possibility to show my (very very long message) ? :confused:
Again: who is supposed to read such a "very very long message"?
Almost no one ans Alin already poined out, would do it!