Help

This is a discussion on Help within the Windows Programming forums, part of the Platform Specific Boards category; Someone tell me how come can't I pass an 'int' to the MessageBox()'s 2nd parameter??...

  1. #1
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542

    Help

    Someone tell me how come can't I pass an 'int' to the MessageBox()'s 2nd parameter??
    what does signature stand for?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,648
    Is that a trick question? Because it takes a char* numbskull! j/k

    Here, add this to your toolbox:

    Code:
    int Alert(int style, const char * message, ...)  {
      char output[strlen(message) + 1024];
      va_list p;
      va_start(p, message);
      vsprintf(output, message, p);
      return MessageBox(NULL, "Notification: ", output, style);
      }
    
    int Alert(const char * message, ...) {
      char output[strlen(message) + 1024];
      va_list p;
      va_start(p, message);
      vsprintf(output, message, p);
      return MessageBox(NULL, "Notification: ",  output, MB_OK);
      }
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  3. #3
    btq
    btq is offline
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    how come can't I pass an 'int' to the MessageBox()'s 2nd parameter
    because it wants a LPCSTR..
    use itoa() to convert the integer to a char* string first and then pass it..

    /btq
    ...viewlexx - julie lexx

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21