C++ Message Box>.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jdk0118@gmail.com

    C++ Message Box>.

    So I am making some code that shows your mouses X and Y coordinates.
    As of now I am doing it via command line and I have to press enter.

    How would I got about putting it in a MessageBox() ?
    I tried it but I can't put the variable in..

    Any help would be appreciated.
    This is what I have so far..

    #include <iostream>
    #include <windows.h>

    int main()
    {
    while(1)
    {


    POINT cursorPos;
    GetCursorPos(&c ursorPos);
    float x = 0;
    x = cursorPos.x;
    float y = 0;
    y = cursorPos.y;






    system("cls");
    std::cout << "X: ";
    std::cout << x;
    std::cout << "\n";
    std::cout << "Y: ";
    std::cout << y;
    std::cin.get();


    }

    return 0;
    }
  • asm23

    #2
    Re: C++ Message Box&gt;.

    jdk0118@gmail.c om wrote:
    So I am making some code that shows your mouses X and Y coordinates.
    As of now I am doing it via command line and I have to press enter.
    >
    How would I got about putting it in a MessageBox() ?
    I tried it but I can't put the variable in..
    >
    Any help would be appreciated.
    This is what I have so far..
    >
    #include <iostream>
    #include <windows.h>
    >
    int main()
    {
    while(1)
    {
    >
    >
    POINT cursorPos;
    GetCursorPos(&c ursorPos);
    float x = 0;
    x = cursorPos.x;
    float y = 0;
    y = cursorPos.y;
    >
    >
    >
    >
    >
    >
    system("cls");
    std::cout << "X: ";
    std::cout << x;
    std::cout << "\n";
    std::cout << "Y: ";
    std::cout << y;
    std::cin.get();
    >
    >
    }
    >
    return 0;
    }
    It's a platform related topic. You'd better try some *windows* related
    group.

    Comment

    • Ole Nielsby

      #3
      Re: C++ Message Box&gt;.

      asm23 wrote:
      jdk0118@gmail.c om wrote:
      >So I am making some code that shows your mouses X and Y coordinates.
      >[...]
      >How would I got about putting it in a MessageBox() ?
      >
      It's a platform related topic. You'd better try some *windows*
      related group.
      Or, if you don't want your apps to be MS Windows only, look
      here: http://en.wikipedia.org/wiki/List_of_widget_toolkits


      Comment

      • Ioannis Vranos

        #4
        Re: C++ Message Box&gt;.

        Ole Nielsby wrote:
        asm23 wrote:
        >
        >jdk0118@gmail.c om wrote:
        >>So I am making some code that shows your mouses X and Y coordinates.
        >>[...]
        >>How would I got about putting it in a MessageBox() ?
        >It's a platform related topic. You'd better try some *windows*
        >related group.
        >
        Or, if you don't want your apps to be MS Windows only, look
        here: http://en.wikipedia.org/wiki/List_of_widget_toolkits

        One can also use QT.

        Comment

        • Thomas J. Gritzan

          #5
          Re: C++ Message Box&gt;.

          jdk0118@gmail.c om wrote:
          >So I am making some code that shows your mouses X and Y coordinates.
          >As of now I am doing it via command line and I have to press enter.
          >>
          >How would I got about putting it in a MessageBox() ?
          >I tried it but I can't put the variable in..
          asm23 wrote:
          It's a platform related topic. You'd better try some *windows* related
          group.
          How to call MessageBox is platform specific, but the OP obviously
          wanted to build a string and pass the string to MessageBox().

          Let's assume that MessageBox takes a const char*, you could use a
          std::ostringstr eam like this:

          #include <sstream>
          #include <string>

          // a function that takes a C-style string
          void SomeFunction(co nst char*);

          int main()
          {
          float x = 0;
          float y = 0;

          std::ostringstr eam message;
          message << "X: " << x;
          message << "\n";
          message << "Y: " << y;

          // build temporary std::string from stringstream,
          // get const char* from std::string,
          // then call your function:
          SomeFunction( message.str().c _str() );
          }

          --
          Thomas

          Comment

          Working...