Thread: MessageBox()

  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, 01:48 PM
  2. problem with A simple modeless messagebox
    By hanhao in forum C++ Programming
    Replies: 8
    Last Post: 07-05-2005, 11:18 PM
  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