Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Korrekte Zeit ermitteln bei Mouse Move (https://www.delphipraxis.net/208700-korrekte-zeit-ermitteln-bei-mouse-move.html)

venice2 9. Sep 2021 03:36

Korrekte Zeit ermitteln bei Mouse Move
 
Ich möchte so wie im Anhang zu sehen die Zeit Ausgeben wenn ich mit der Maus über die Track Bar gleite.
Die gesamt zeit ermittle ich auf diese weise und übergebe sie an meine Track Bar.

Delphi-Quellcode:
  TrackMinMax := integer(aMediaProperty.PlaybackLength div 10000);
  trbSearch.SetTrackMinMax(trbSearch.Handle, 0, TrackMinMax);
Ich habe jetzt die gesamte Laufzeit des Movies und setze diese.
Delphi-Quellcode:
trbSearch.MaxVal


Dann hole ich mir über
Delphi-Quellcode:
GetCursorPos(p);

Die aktuelle Position der Maus an der x Position.

Irgendwie bekomme ich aber nicht die richtige Zeit Ausgabe..
Was fehlt bzw.. habe ich übersehen?

Delphi-Quellcode:
Position := (p.X - - trbSearch.Left) + ((trbSearch.MaxVal div 1000) div rc1.Width);
Elapsed := FormatDateTime('hh:nn:ss', Position / SecsPerDay);
komplettes Schnipsel.
Delphi-Quellcode:
    WM_NCMOUSEMOVE, WM_MOUSEMOVE:
      begin
        if (KVideo_GetPlayerState(MainMovie) = psPlaying) or
          (KVideo_GetPlayerState(MainMovie) = psPaused) then
        begin
          GetCursorPos(p);
          ScreenToClient(WinHandle, p);

          GetClientRect(WinHandle, rc);

          ChildHwnd := ChildWindowFromPoint(WinHandle, p);

          if (ChildHwnd = trbSearch.Handle) and
            not trbSearch.CheckOverThumb(trbSearch.Handle) then
          begin
            if PtInRect(rc, p) then
            begin
              SKAERO_SetCTLText(lblMove.Handle, '');
              GetClientRect(trbSearch.Handle, rc1);

              Position := (p.X - trbSearch.Left) + ((trbSearch.MaxVal div 1000) div rc1.Width); // Nicht korrekt
              Elapsed := FormatDateTime('hh:nn:ss', Position / SecsPerDay);

              Left := (p.x - lblMove.Width) + (lblMove.Width div 2) + 10;
              if Left < trbSearch.Left then
                Left := trbSearch.Left;
              if (Left + lblMove.Width) > (gP.MainWidth - 10) then
                Left := (gP.MainWidth - lblMove.Width) - 5;

              MoveWindow(lblMove.Handle, Left, gP.MainHeight - 112, lblMove.Width,
                lblMove.Height, false);

              SKAERO_SetCTLText(lblMove.Handle, Elapsed);
            end;
          end else
          if not trbSearch.CheckOverThumb(trbSearch.Handle) then
            SKAERO_SetCTLText(lblMove.Handle, '');
        end;
      end;

venice2 9. Sep 2021 05:14

AW: Korrekte Zeit ermitteln bei Mouse Move
 
Ok hat sich erledigt..

Delphi-Quellcode:
    WM_NCMOUSEMOVE, WM_MOUSEMOVE:
      begin
        if (KVideo_GetPlayerState(MainMovie) = psPlaying) or
          (KVideo_GetPlayerState(MainMovie) = psPaused) then
        begin
          GetCursorPos(p);
          ScreenToClient(WinHandle, p);

          ChildHwnd := ChildWindowFromPoint(WinHandle, p);

          if (ChildHwnd = trbSearch.Handle) and
            not trbSearch.CheckOverThumb(trbSearch.Handle) then
          begin
            GetClientRect(WinHandle, rc);

            if PtInRect(rc, p) then
            begin
              SKAERO_SetCTLText(lblMove.Handle, '');
              GetClientRect(trbSearch.Handle, rc1);

              Img := GDIP_CreateImageFromFile(SKAERO_FOLDER + 'BTN_Thumb.png');
              GDIP_GetImageSize(Img, imgW, imgH);
              GDIP_DisposeImage(Img);

              // Get Max Values from trbSearch
              tMax := trbSearch.MaxVal div 1000;
              // Analyze new Position instead of Mouse Position
              tx := MIN(MAX((p.x - trbSearch.Left) - Integer(imgW) div 2, 0),
                rc1.Right - Integer(imgW));
              range := rc1.Right - Integer(imgW);
              increment := tMax / range;
              tVal := round(increment * tx);
              // Format tVal to DateTime
              Elapsed := FormatDateTime('hh:nn:ss', (tVal / SecsPerDay));
              // Move Label in Center of Cursor
              Left := (p.x - lblMove.Width) + (lblMove.Width div 2) +
                (trbSearch.Left - (Integer(imgW) div 2));
              if Left < trbSearch.Left then
                Left := trbSearch.Left;
              if (Left + lblMove.Width) > (gP.MainWidth - trbSearch.Left) then
                Left := (gP.MainWidth - lblMove.Width) - trbSearch.Left div 2;

              MoveWindow(lblMove.Handle, Left, gP.MainHeight - 112, lblMove.Width,
                lblMove.Height, false);

              SKAERO_SetCTLText(lblMove.Handle, Elapsed);
            end;
          end else
          if not trbSearch.CheckOverThumb(trbSearch.Handle) then
            SKAERO_SetCTLText(lblMove.Handle, '');
        end;
      end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:07 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz