Thread: MessageBox Problem

  1. #1
    Just a Human Anuradh_a's Avatar
    Join Date
    Jan 2008
    Posts
    50

    MessageBox Problem

    Greetings People
    have question here.Is there any way that I can out put a value (which is stored in a variable )
    using MessageBox() .
    thanks.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Can you pass variables TO MessageBox, you mean? If that's the question, then yes.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Just a Human Anuradh_a's Avatar
    Join Date
    Jan 2008
    Posts
    50
    then how do I do it????

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    I would think you would need to wsprintf() to a temporary string first then pass that to MessageBox().

    Of course, that only applies to primitive variable types (int, long, double, etc.). If you've got a fancy-pants C++ class member that you want to work with then you'll probably need to convert it first.

  5. #5
    Just a Human Anuradh_a's Avatar
    Join Date
    Jan 2008
    Posts
    50
    is there any examples on this SMurf???
    thanks

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    It depends on which language you want to do it in. As I normally use C:-
    Code:
    char szTemp[16]; // this must accomodate AT LEAST the maximum string length of what you want to display PLUS an extra character for null termination
    int iValue = 123456789; // the value that you want to display
    
    wsprintf(szTemp, "%i", iValue);
    MessageBox(NULL, szTemp, NULL, MB_ICONINFORMATION);

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    If you have to do this conversion more than once, you might want to use Prelude's stringstream example from the FAQ Section.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  3. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  4. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM