View Full Version : Problem with ScreenToClient()

09-02-2003, 06:52 PM
I wrote the "Towers of Hanoi" game, which you can download form
In this game I use own drag-and-drop to allow moving the blocks together with Mouse cursor. I write my own function to convert the cursor coordinates to client ones. But now I tried to use the ScreenToClient method. When you start dragging the block, it begins to vibrate.
I use the onTimer() event
Is this bug or I'm using ScreenToClient wrong?

10-02-2003, 12:30 PM
I've tried to download it here at my work, with a super-fast connection. It's downloading from the site at 56 BYTES(!) a second. :pig: If you mail it to me (link should be at the bottom) then I'll upload it to my site tonight so that other people can have a look at it.

10-02-2003, 08:51 PM
I've uploaded the exe to my site: http://www.alistairkeys.co.uk/darhazer/hanoi.zip (214K). (Incidentally, Darhazer, if you have any other code/bits and bobs you want me to upload, just let me know.)

First question about the code: you're using a TTimer component to do stuff, you say. What's the interval? If it's less than 55 then *TTimer can't update that quickly!* It may sometimes, but a lot of the time it won't, because it's based on the Windows WM_TIMER message behind the scenes. This can cause jerkiness.

You might want to try a better timer (such as the ones from DelphiX, PowerDraw, or any of the other component sets -- maybe TRXTimer if you can find it somewhere).

That may or may not be the cause of the jerkiness - we'd need to see some code to know for sure. :cat:

13-02-2003, 05:55 PM
I know that 55 is the minimum interval and I use that interval
I use own code to convert screen koordinates to client:
I use object Mouse: TMouse
and I use
This code works perfect
But when i change it to
It starts vibrate

Useless Hacker
15-02-2003, 08:25 PM
A wild stab in the dark, but try:

with ScreenToClient(Mouse.CursorPos) do begin
Left := X;
Top := Y;

Failing that, try using the API ScreenToClient directly.