Moving Cursor (under MinGW)

This is a discussion on Moving Cursor (under MinGW) within the C++ Programming forums, part of the General Programming Boards category; I want to make a very simple program, that moves the mouse in one position, clicks etc etc I have ...

  1. #1
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853

    Moving Cursor (under MinGW)

    I want to make a very simple program, that moves the mouse in one position, clicks etc etc
    I have found some instructions but only under Visual C++.
    How can this be done with MinGW?

    thanx

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I don't understand what would be different with MingW. Do you have a specific problem with the examples you've found?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Well, I tried this, found as an example. Didn't work. Do I need to include something else also?

    Code:
    #include <windows.h>
    #include <iostream>
    
    using namespace System;
    using namespace System::Drawing;
    using namespace System::Windows::Forms;
    
    namespace CustomCursor {
    public __gc class Form1 : public System::Windows::Forms::Form {
    
    public:
        Form1() {
            this->ClientSize = System::Drawing::Size(292, 266);
            this->Text = S"Cursor Example";
            this->Cursor = new System::Windows::Forms::Cursor(GetType(), S"MyCursor.Cur");
    
        }
    };
    }
    [STAThread]
    int main() {
        Application::Run(new CustomCursor::Form1());
    }

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That looks like managed C++, which is, of course, not going to compile in a traditional C++ compiler.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    So you are saying that I need a different approach for MinGW? Or should I get Visual Studio?

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by C_ntua View Post
    So you are saying that I need a different approach for MinGW? Or should I get Visual Studio?
    The code you posted is a "Windows Form" piece of code, and that is part of the "Managed code" system - it uses C++ language extensions that are not standard. Yes, you can compile it with Visual Studio if you wish, but the basic functionality for cursor management is there in the Windows API, so you don't need to use managed code to do that.

    I have done custom cursors before (I wrote the cursor management in a driver, so I had to test all sorts of weird and wonderful versions of cursor code, which meant that I had to write my own little test app to switch to cursors that I knew what they would look like, and that "stretches the envelope", e.g. a 500+ pixel size cursor with alpha-blending so that it would be variably translucent against it's background).

    The API functions that you can use for cursor manipulation are (I'm not convinced this is a complete list, but it's fairly comprehensive as far as I know - these are all links to the MSDN pages):
    SetCursor
    SetCursorPos
    CreateCursor
    LoadImage (There is a LoadCursor function, but LoadImage is a "better", more modern implementation that covers all sorts of image workings, including loading cursors).
    ShowCursor


    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Thanx a lot dude

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mingw and elcipse HELP
    By Rob4226 in forum Windows Programming
    Replies: 1
    Last Post: 03-04-2008, 01:35 AM
  2. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-24-2007, 12:05 AM
  3. moving median function
    By supermeew in forum C Programming
    Replies: 0
    Last Post: 05-04-2006, 03:37 PM
  4. 3D moving
    By bluehead in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2005, 05:46 AM
  5. compiling mingw to enable timeSetEvent
    By underthesun in forum Windows Programming
    Replies: 2
    Last Post: 02-02-2005, 06:00 PM

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