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.
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.
Last edited by ovidiucucu; October 31st, 2008 at 07:54 AM.
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 !
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) ?!
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.