I am sure I saw something somewhere about just putting a DOS program into a window rather DOS box...maybe google it?
I am sure I saw something somewhere about just putting a DOS program into a window rather DOS box...maybe google it?
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; }
thats works but how can i out that in a loop so it works when i move the mouse?
Use WM_MOUSEMOVE instead of WM_PAINT, and then use GetDC and ReleaseDC instead of BeginPaint and EndPaint.
well that got rid of the blingking but it still only works while the crurser inside the window.
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.
k i would like to see the code i might be able to build of it
Put this in your WINAPI WinMain, now your program also reacts when your mouse isn't on your window:
I used an Edit class window to write the mouse position to:PHP Code:
for ( ; ; )
{
if ( PeekMessage ( & msg, NULL, 0, 0, PM_REMOVE ) )
{
if ( msg.message == WM_QUIT )
{
break;
}
TranslateMessage ( & msg );
DispatchMessage ( & msg );
}
else
{
Mouse_Pos();
}
Sleep ( 10 );
}
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.PHP Code:
void Mouse_Pos()
{
POINT Cursor_Pos;
GetCursorPos ( & Cursor_Pos );
char Cursor_X [ 256 ],
Cursor_Y [ 256 ];
itoa ( Cursor_Pos.x, Cursor_X, 10 );
itoa ( Cursor_Pos.y, Cursor_Y, 10 );
strcat ( Cursor_X, " " );
strcat ( Cursor_X, Cursor_Y );
HWND Main,
Edit;
Main = FindWindow ( "YourMainWindowClass", "YourMainWindowCaption" );
Edit = FindWindowEx ( Main, NULL, "Edit", NULL );//To find the Edit class window on your main window
SendMessage ( Edit, WM_SETTEXT, ( WPARAM ) strlen ( Cursor_X ), ( LPARAM ) Cursor_X );
}