Thread: MessageBox questions...

  1. #16
    train spotter
    Join Date
    Aug 2001
    near a computer
    It won't.

    It will put a little picture in the MB though.
    Just a set of flags for the style. MB_OK is the default so not realy needed.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  2. #17
    Registered User
    Join Date
    Oct 2001
    Since you are using MFC, use CString for your buffer to erase the doubt and start first with the simple MessageBox function and then edit afterwards, like the code below.

    //char buff[1024];
    CString buff;
    int answer;

    answer = Cube(m_value);

    //sprintf(buff, "The value of %i is: %i", m_value, answer);
    buff.Format("The value of %d is: %d",m_value,answer);


    Just try that...

    If they can, why can't I...

  3. #18
    Registered User -leech-'s Avatar
    Join Date
    Nov 2001
    Already got it working:
    void CWinCubeDlg::OnCube() 
    	// TODO: Add your control notification handler code here
    	char buff[1024];
    	int answer;
    	answer = Cube(m_value);
    	sprintf(buff, "After being cubed, the value of %i is: %i", m_value, answer);
    	MessageBox(buff, "The results...", MB_ICONINFORMATION);
    Thanks a lot for everyone's help.
    Not yet, have to think of one...

  4. #19
    Registered User
    Join Date
    Apr 2007
    I have tried everything in this topic, and the compiler constantly gives me the error:
    error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [28]' to 'LPCTSTR'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    when I try:

    MessageBox("Help, Something went wrong.", "Error", 
          MB_ICONERROR | MB_OK);
    from the example at the msdn or something similar.
    Last edited by myle; 05-15-2007 at 08:16 AM.

  5. #20
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    Shouldn't it be
    L"Help, Something went wrong."

    TEXT ("Help, Something went wrong.")

    if you want to use UNICODE?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  6. #21
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > 11-15-2001, 12:22 AM
    You should also read the forum rules about digging up old threads.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Delete files that are used
    By Yuri in forum C++ Programming
    Replies: 8
    Last Post: 10-18-2005, 01:48 PM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. EnterCriticalSection and MessageBox
    By novacain in forum Windows Programming
    Replies: 13
    Last Post: 01-30-2003, 08:48 AM