Results 1 to 5 of 5

Thread: Problem with ScreenToClient()

  1. #1

    Problem with ScreenToClient()

    Hi
    I wrote the "Towers of Hanoi" game, which you can download form
    http://free.top.bg/darklight/hanoi.zip
    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?
    http://www.kaldata.net

  2. #2

    Problem with ScreenToClient()

    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. 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.
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  3. #3

    Problem with ScreenToClient()

    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.
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  4. #4

    Problem with ScreenToClient()

    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
    Left:=Mouse.CursorPos.X-Form1.Left-Form1.Width+Form1.ClientWidth;
    Topy:=Mouse.CursorPos.Y-Form1.Top-Form1.Height+Form1.ClientHeight;
    This code works perfect
    But when i change it to
    Left:=ScreenToClient(Mouse.CursorPos).X
    Top:=ScreenToClient(Mouse.CursorPos).Y
    It starts vibrate
    http://www.kaldata.net

  5. #5

    Problem with ScreenToClient()

    A wild stab in the dark, but try:
    [pascal]
    with ScreenToClient(Mouse.CursorPos) do begin
    Left := X;
    Top := Y;
    end;
    [/pascal]

    Failing that, try using the API ScreenToClient directly.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •