Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AfxMessageBox with clipboard copy capability.

82 views
Skip to first unread message

Ed J

unread,
Aug 3, 2007, 3:27:00 PM8/3/07
to
I use AfxMessageBox for error messages, but I get user complaints because
whenever an error message pops up, they cannot copy the message box text to
the clipboard for pasting into another application. They don't like having
to do the "print screen" thing and move images around.

Is there a way to make AfxMessageBox display text that is copyable, or is
there an equally simple alternative?

Thanks,

Ed


[Jongware]

unread,
Aug 3, 2007, 4:31:13 PM8/3/07
to
"Ed J" <j...@privacy.net> wrote in message
news:46b3818d$0$4641$4c36...@roadrunner.com...

Use a regular dialog box, with the error in a read-only text edit.

[Jw]


Kellie Fitton

unread,
Aug 3, 2007, 5:34:52 PM8/3/07
to


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.


jjg...@gmail.com

unread,
Aug 29, 2007, 3:17:00 PM8/29/07
to
On Aug 3, 12:27 pm, "Ed J" <j...@privacy.net> wrote:
> I useAfxMessageBoxforerrormessages, but I get user complaints because
> whenever anerrormessage pops up, they cannotcopythe message box text to

> the clipboard for pasting into another application. They don't like having
> to do the "print screen" thing and move images around.
>
> Is there a way to makeAfxMessageBoxdisplay text that is copyable, or is

> there an equally simple alternative?
>
> Thanks,
>
> Ed

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

[Jongware]

unread,
Aug 29, 2007, 4:16:15 PM8/29/07
to
<jjg...@gmail.com> wrote in message
news:1188415020.8...@e9g2000prf.googlegroups.com...

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]


jjg...@gmail.com

unread,
Aug 30, 2007, 6:33:50 PM8/30/07
to

> 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]- Hide quoted text -
>

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

[Jongware]

unread,
Aug 31, 2007, 4:24:21 PM8/31/07
to
<jjg...@gmail.com> wrote in message
news:1188513230.3...@x35g2000prf.googlegroups.com...

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]


0 new messages