Changing mouse pointer?

This is a discussion on Changing mouse pointer? within the Windows Programming forums, part of the Platform Specific Boards category; Hi! I'm quite a newbie at this but how would you make a program that when you open it will ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    5

    Changing mouse pointer?

    Hi!
    I'm quite a newbie at this but how would you make a program that when you open it will change the mouse pointer and then open a new program and close itself?
    I'll be happy for all the answers I receive.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    FAQ > How dow I Run a program from within a program

    Do you want to change the mouse cursor for the current user? Or have it change just while it's over your application window?

    gg

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    5
    When the mouse pointer is over the new application.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    You're gonna have a hard time changing the mouse cursor for another application.

    A Windows application can conrol the look of a cursor while the cursor is over its window by responding to the WM_SETCURSOR message.

    What exactly are you trying to apply this to? Perhaps there are better alternatives.

    gg

  5. #5
    Registered User
    Join Date
    Nov 2004
    Posts
    5
    I have a game I made with Rpg maker XP, and I need to change the cursor in the main file of the game. Alternatively can I just change the cursor for the current user, if you can show me how to do it.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    You can try playing around with SetCursor(), but there may be official support for this within RPG Maker XP.

    gg

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    Found an online forum for RPG Maker - they might be able to help.

    http://stifu.free.fr/Board/forum.php?id=3

    gg

  8. #8
    Registered User
    Join Date
    Nov 2004
    Posts
    5
    Thanks! But Rpg maker forums dosen't help because it normally isn't supported, it's a script you can use in Rpg maker that let you use the mouse. By the way, you can use Ruby in Rpg maker if you wanted to know...

  9. #9
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by Matte
    Alternatively can I just change the cursor for the current user, if you can show me how to do it.
    Use SetSystemCursor, eg:
    Code:
    /*
      change system cursor, launch another program then restore original cursor
      when other program closed.
    */
    
    /*some compilers (ms) may need OEMRESOURCE defined to use cursor identifiers*/
    #define OEMRESOURCE  
    #include <windows.h>
    
    /* Nov 2004: problem with MinGW(3101) implementation of CopyCursor
       an alternative is to just use CopyImage.
       This is not a issue with MinGW 3.4 candidate*/
    
    #if !defined CopyCursor
    #define CopyCursor(c) ((HCURSOR)CopyIcon((HICON)(c)))
    #endif
    
    int main()
    {
    HCURSOR             hOldCur,hNewCur;
    STARTUPINFO         si;
    PROCESS_INFORMATION pi;
    
    ZeroMemory(&si,sizeof(si));
    si.cb=sizeof(si);
    ZeroMemory(&pi,sizeof(pi));
    
    /*Start other program, for example, the windows calculator*/
    if(!CreateProcess(0,"calc.exe",0,0,0,0,0,0,&si,&pi)) 
      {
      MessageBox(0,"error","Failed to launch process",MB_OK);
      return 0;
      }
    /*need to copy the cursors because SetSystemCursor destroys them*/
    hOldCur=CopyCursor(((HCURSOR)LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,
                       LR_SHARED)));
    hNewCur=CopyCursor(((HCURSOR)LoadImage(0,IDC_CROSS,IMAGE_CURSOR,0,0,
                       LR_SHARED)));
    
    SetSystemCursor(hNewCur,OCR_NORMAL);
    
    /*wait for child process to quit*/
    WaitForSingleObject(pi.hProcess,INFINITE);
    
    /*clean up process garbage*/
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    
    /*and restore original cursor*/
    SetSystemCursor(hOldCur,OCR_NORMAL);
    }
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  10. #10
    Registered User
    Join Date
    Nov 2004
    Posts
    5
    Thanks!
    But where can you change the pointer file?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need Help in Mouse Pointer
    By obaid in forum C++ Programming
    Replies: 3
    Last Post: 12-07-2006, 02:33 AM
  2. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  3. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  4. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM
  5. changing mouse pointer in c
    By MMM in forum Windows Programming
    Replies: 3
    Last Post: 05-11-2003, 08:28 PM

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