Streaming message box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CedricCicada@gmail.com

    #1

    Streaming message box

    Greetings!

    I have just returned to C++ after a couple of years in the FoxPro and
    C# worlds. I am trying to adapt and expand existing code. For
    debugging and just plain understanding the code I'm working with, I'd
    like to put little message boxes into the code. It seems a pain to
    declare a character array, write my message into it, and then call
    AfxMessageBox() to dispaly it. It seems to me that it would be easy to
    create a stream-based messagebox class that I could use as follows:

    StreamMessageBo x << "My value is " << MyValue;

    This would pop up a simple message box with a single OK button and my
    message. It should be easy to add manipulators to this class to select
    icons and use different button sets.

    Does such a thing exist? If so, where can I get it?

    Thanks very much!

    RobR

  • mlimber

    #2
    Re: Streaming message box

    CedricCic...@gm ail.com wrote:[color=blue]
    > Greetings!
    >
    > I have just returned to C++ after a couple of years in the FoxPro and
    > C# worlds. I am trying to adapt and expand existing code. For
    > debugging and just plain understanding the code I'm working with, I'd
    > like to put little message boxes into the code. It seems a pain to
    > declare a character array, write my message into it, and then call
    > AfxMessageBox() to dispaly it. It seems to me that it would be easy to
    > create a stream-based messagebox class that I could use as follows:
    >
    > StreamMessageBo x << "My value is " << MyValue;
    >
    > This would pop up a simple message box with a single OK button and my
    > message. It should be easy to add manipulators to this class to select
    > icons and use different button sets.
    >
    > Does such a thing exist? If so, where can I get it?
    >
    > Thanks very much!
    >
    > RobR[/color]

    Well, you're talking about a platform-specific library since Standard
    C++ doesn't have anything but text/binary I/O. Thus, you should ask in
    a Microsoft newsgroup about the existence of such a library. See this
    FAQ for some possibilities:



    But, you're right that it shouldn't be too hard to add that. I suspect
    you'll need to always have a manipulator at the end, however, to
    indicate that you're done appending the message and that it should now
    be displayed.

    Cheers! --M

    Comment

    • Victor Bazarov

      #3
      Re: Streaming message box

      CedricCicada@gm ail.com wrote:[color=blue]
      > I have just returned to C++ after a couple of years in the FoxPro and
      > C# worlds. I am trying to adapt and expand existing code. For
      > debugging and just plain understanding the code I'm working with, I'd
      > like to put little message boxes into the code. It seems a pain to
      > declare a character array, write my message into it, and then call
      > AfxMessageBox() to dispaly it. It seems to me that it would be easy
      > to create a stream-based messagebox class that I could use as follows:
      >
      > StreamMessageBo x << "My value is " << MyValue;
      >
      > This would pop up a simple message box with a single OK button and my
      > message. It should be easy to add manipulators to this class to
      > select icons and use different button sets.
      >
      > Does such a thing exist? If so, where can I get it?[/color]

      If it exists, you could find out about it in a newsgroup where
      'AfxMessageBox' is on topic, I am sure. Generally speaking all you
      need is to define a class that overloads operator << as a template
      and has a special (non-template, say) operator << to "show" itself.
      It would be used like this:

      StreamMessageBo x << "My value is " << MyValue << show;

      or

      StreamMessageBo x << "My value is " << MyValue;
      StreamMessageBo x.show();

      I don't think you want to attempt to make your messagebox show itself
      at the end of "full expression". It's just too tricky. Besides, the
      behaviour should be the same if you say

      StreamMessageBo x << "My value is "; StreamMessageBo x << MyValue;

      don't you think? That's why you need not only the operator << but
      also the 'show' thingie.

      V
      --
      Please remove capital 'A's when replying by e-mail
      I do not respond to top-posted replies, please don't ask


      Comment

      • CedricCicada@gmail.com

        #4
        Re: Streaming message box

        Thank you very much for your replies. I appreciate your thoughts and I
        also appreciate you pointing out that I was asking an MS-specific
        question and therefore should have been on an MS-specific list. I will
        repost to one.

        RobR

        Comment

        Working...