Mouse Program

This is a discussion on Mouse Program within the C++ Programming forums, part of the General Programming Boards category; I am sure I saw something somewhere about just putting a DOS program into a window rather DOS box...maybe google ...

  1. #16
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    I am sure I saw something somewhere about just putting a DOS program into a window rather DOS box...maybe google it?

  2. #17
    Registered User asbo60's Avatar
    Join Date
    Jan 2006
    Posts
    38
    k ill try that thx

  3. #18
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Or you can just TextOut/DrawText the buffer you sprintf'ed in your last code in your WindowProcedure.

    Code:
    	case WM_PAINT:
    	{
    		char str[256];
    		POINT cursorPos;
    		HDC hDC;
    		PAINTSTRUCT pS;
    
    		hDC = BeginPaint(hWnd, &pS);
    
    		GetCursorPos(..);
    		sprintf(str, ..);
    		TextOut(hDC, x, y, str, strlen(str));
    
    		EndPaint(hwnd, &pS);
    		break;
    	}

  4. #19
    Registered User asbo60's Avatar
    Join Date
    Jan 2006
    Posts
    38
    thats works but how can i out that in a loop so it works when i move the mouse?

  5. #20
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Use WM_MOUSEMOVE instead of WM_PAINT, and then use GetDC and ReleaseDC instead of BeginPaint and EndPaint.

  6. #21
    Registered User asbo60's Avatar
    Join Date
    Jan 2006
    Posts
    38
    well that got rid of the blingking but it still only works while the crurser inside the window.

  7. #22
    Banned Yuri's Avatar
    Join Date
    Aug 2005
    Location
    Breukelen, The Netherlands
    Posts
    133
    I tried to do it on one way, it worked but I really don't recommend you to use it. Though, if you want the code, I'll post it.

  8. #23
    Registered User asbo60's Avatar
    Join Date
    Jan 2006
    Posts
    38
    k i would like to see the code i might be able to build of it

  9. #24
    Banned Yuri's Avatar
    Join Date
    Aug 2005
    Location
    Breukelen, The Netherlands
    Posts
    133
    Put this in your WINAPI WinMain, now your program also reacts when your mouse isn't on your window:

    PHP Code:
    for ( ; ; )
        {

            if ( 
    PeekMessage ( & msgNULL00PM_REMOVE ) )
            {

                if ( 
    msg.message == WM_QUIT )
                {

                    break;
                }

                
    TranslateMessage ( & msg );

                
    DispatchMessage ( & msg );
            }

            else
            {

                
    Mouse_Pos();
            }

            
    Sleep 10 );
        } 
    I used an Edit class window to write the mouse position to:

    PHP Code:
    void Mouse_Pos()
    {

        
    POINT Cursor_Pos;

        
    GetCursorPos ( & Cursor_Pos );

        
    char Cursor_X 256 ],
             
    Cursor_Y 256 ];

        
    itoa Cursor_Pos.xCursor_X10 );

        
    itoa Cursor_Pos.yCursor_Y10 );

        
    strcat Cursor_X"   " );

        
    strcat Cursor_XCursor_Y );

        
    HWND Main,
             
    Edit;

        
    Main FindWindow "YourMainWindowClass""YourMainWindowCaption" );

        
    Edit FindWindowEx MainNULL"Edit"NULL );//To find the Edit class window on your main window

        
    SendMessage EditWM_SETTEXT, ( WPARAM strlen Cursor_X ), ( LPARAM Cursor_X );

    As I said before, there are many ways to do this better, I wouldn't use it like this but this may give you some ideas.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Mouse Over Menu!!! HELP!!!
    By SweeLeen in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2006, 02:10 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM
  4. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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