Is there a way to make AfxMessageBox display text that is copyable, or is
there an equally simple alternative?
Thanks,
Ed
Use a regular dialog box, with the error in a read-only text edit.
[Jw]
Hi,
Well, if the user needs to copy & paste every error message text into
the Windows clipboard, then your application can automate this
process for them. You can use the following APIs to copy the text
of the messagebox into the clipboard:
OpenClipboard()
EmptyClipboard()
SetClipboardData()
CloseClipboard()
http://msdn2.microsoft.com/en-us/library/ms649048.aspx
http://msdn2.microsoft.com/en-us/library/ms649037.aspx
http://msdn2.microsoft.com/en-us/library/ms649051.aspx
http://msdn2.microsoft.com/en-us/library/ms649035.aspx
Kellie.
Try Ctrl+C on the MessageBox and that works too. You don't need to
highlight the text, on a message box, to copy it's content to the
clipboard.
Juan
I just forced Outlook to display a standard message box and I couldn't do this.
Perhaps you were using a program which provides this functionality, but it sure
doesn't seem to be built-in behaviour.
[Jw]
You may be right about default message boxes having built-in behavior
that disallows Ctr+C from copying text to the clipboard. (I admit that
I
was vague in my previous explanation.)
However, I was referring to AfxMessageBox(). If you add the code
below
to your project and run it, you should get a dialog.
AfxMessageBox("ERROR: Message something failed.");
Then by doing a Ctr+C, this is what you will get:
---------------------------
dialog1
---------------------------
ERROR: Message something failed.
---------------------------
OK
---------------------------
As you can see, the message "ERROR: Message something failed." is
copied into the clipboard along with the title and OK. Therefore, if
Ed could
asked his users to try Ctr+C on the AfxMessageBox dialog, they can
use
the error message instead of doing a print screen to get the content
of the
message box.
Juan
No harm intended -- as I think it's really a user-friendly option -- but when I
look in the MFC source I get to this line in AfxMessageBox:
int nResult = ::MessageBox(hWnd, lpszPrompt, pszAppName, nType);
So that doesn't help. Did you by any chance use a .NET program for your example?
Mind you, my first suggestion to the OP was creating your own messagebox. In
that case one could add Ctrl+C to the short list of handled events. But I think
it would be more user-friendly if it was clear for novice users that the text
could be selected and copied -- hence my suggestion of a read-only control.
Did you know you can copy most text in the standard File Properties dialog? One
line at the time, you can't use Tab to jump from one item to the next, and it's
not visually clear what you *can* and what you *can't* copy.
[Jw]