Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im using this code to draw a line with a mouse on top of all windows, Im using mouse hook to get mouse coordinates and on each mouse movement while right mouse button is down I'm drawing the line. Im using NOTXORPEN so I will be able to delete the line only by drawing it again.

Init
Delphi
ScreenDC := GetDcEx(GetDesktopWindow,0,DCX_LOCKWINDOWUPDATE);

PenHandle := CreatePen(PS_SOLID,HitStorage.GetPenWidth,10);

SelectObject(ScreenDC ,PenHandle);
OldPenMode := SetRop2(ScreenDC, R2_NOTXORPEN);  // Setting the PenMode to NotXor

MoveToEx(ScreenDC, X, Y, Nil);                  //Move The Pen Position to the Cursor Position


I'm using this code on each mouse movement :
Delphi
LineTo(ScreenDC, X, Y);                      // Draw a Line between the previous Point to the Current Point


This code worked for 95,98,2000,XP windows ... and now with windows 7 its very very very slow!

For general, I wrote a mouse gestures program (written in 1999) in Delphi 3 using ONLY Windows API (mouse hook was written in VC because of Delphi BUG in version 3). The program is doing exactly what StrokeIt is Doing but somehow StrokeIt managed to figure out the solution to this annoying problem.

StrokeIt Site for Downloading :
http://www.tcbmi.com/strokeit/[^]

Please Help ,
Thanks!!
Posted
Comments
Mehdi Gholam 10-Nov-11 10:52am    
Try setting the compatibility mode on the app exe and see what happens?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900