AfxMessageBox with clipboard copy capability. - Programmer

This is a discussion on AfxMessageBox with clipboard copy capability. - Programmer ; 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 ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: AfxMessageBox with clipboard copy capability.

  1. AfxMessageBox with clipboard copy capability.

    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



  2. Re: AfxMessageBox with clipboard copy capability.

    "Ed J" wrote in message
    news:46b3818d$0$4641$4c368faf@roadrunner.com...
    > 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?


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

    [Jw]



  3. Re: AfxMessageBox with clipboard copy capability.

    On Aug 3, 12:27 pm, "Ed J" wrote:
    > 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



    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.



  4. Re: AfxMessageBox with clipboard copy capability.

    On Aug 3, 12:27 pm, "Ed J" 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


  5. Re: AfxMessageBox with clipboard copy capability.

    wrote in message
    news:1188415020.801187.131850@e9g2000prf.googlegro ups.com...
    > On Aug 3, 12:27 pm, "Ed J" 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.


    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]



  6. Re: AfxMessageBox with clipboard copy capability.


    > 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


  7. Re: AfxMessageBox with clipboard copy capability.

    wrote in message
    news:1188513230.304114.134640@x35g2000prf.googlegr oups.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]- 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.


    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]



+ Reply to Thread