MessageBox()

This is a discussion on MessageBox() within the Windows Programming forums, part of the Platform Specific Boards category; I've tried various ways to display the content of output in a message box but it keeps displaying a message ...

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    MessageBox()

    I've tried various ways to display the content of output in a message box but it keeps displaying a message box with garbage printed. This is what I have after some point.
    Code:
    string output = "Left button is clicked";
    MessageBox(hwnd, reinterpret_cast<const char *>(&output),  "Mouse Event", MB_OK);
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use c_str() member function ie:
    Code:
    std::string output = "Left button is clicked";
    MessageBox(hwnd, output.c_str(),  "Mouse Event", MB_OK);
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    kewl, it works, thnx
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Delete files that are used
    By Yuri in forum C++ Programming
    Replies: 8
    Last Post: 10-18-2005, 02:48 PM
  2. problem with A simple modeless messagebox
    By hanhao in forum C++ Programming
    Replies: 8
    Last Post: 07-06-2005, 12:18 AM
  3. Forcing MessageBox to be non-concurrent?
    By JasonD in forum Windows Programming
    Replies: 17
    Last Post: 12-10-2003, 03:16 PM
  4. EnterCriticalSection and MessageBox
    By novacain in forum Windows Programming
    Replies: 13
    Last Post: 01-30-2003, 08:48 AM
  5. double in a MessageBox
    By Robert602 in forum Windows Programming
    Replies: 3
    Last Post: 12-17-2001, 03:10 PM

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