Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Sychrone Listboxen (https://www.delphipraxis.net/207936-sychrone-listboxen.html)

stahli 19. Mai 2021 14:12

AW: Sychrone Listboxen
 
Für RichEdits habe ich es folgendermaßen umgesetzt:
(https://youtu.be/qH-kT2I5q6g)

Das kannst Du so natürlich nicht 1:1 übernehmen (da ich von einem anderen Datenbestand ausgehe und Listboxen vielleicht nicht genau so funktionieren) aber evtl. hilft es als Ideenpool...
(Die Panels sind ausgestanzt und bilden die Rahmen um die aktuellen Zeilen links und rechts.)

Delphi-Quellcode:
  case (ControlledSite) of
    csLeft:
      begin
        TLO := RichEdit1O.Perform(EM_GETFIRSTVISIBLELINE, 0, 0);
        ALO := RichEdit1O.ActiveLineNo;

        PanelLeftFrame.Top := (((ALO - TLO) * 14) + 4);
        lTag := (TLO);

        if Assigned(BlocksCtrl) then
        begin
          D := MaxInt;
          for I := 0 to BlocksCtrl.LineNumberListRight.Count - 1 do
          begin
            D_ := Abs(ALO - (BlocksCtrl.LineNumberListRight[I].LineNumber));
            if (D_ < D) then
            begin
              ALR := I;
              D := D_;
              if (D = 0) then
              begin
                TLR := RichEdit1R.Perform(EM_GETFIRSTVISIBLELINE, 0, 0);

                TLC := (I - (ALO - TLO));
                if (TLC < 0) then
                begin
                  TLC := 0;
                end;
                RichEdit1R.Perform(EM_LINESCROLL, 0, TLC - TLR);
                TLR := RichEdit1R.Perform(EM_GETFIRSTVISIBLELINE, 0, 0);
                rTag := TLR;

                PanelRightFrame.Top := (((ALR - TLR) * 14) + 4);
                PanelRightFrame.Visible := True;

                if (RichEdit1R.CaretPos.Y <> ALR) then
                  RichEdit1R.CaretPos := TPoint.Create(0, ALR);

                Break;
              end;
            end;
          end;

          if (D <> 0) then
          begin
            PanelRightFrame.Visible := False;
            rTag := -1;
          end;

          if (ALO <= BlocksCtrl.LineNumberListLeft.Count - 1) then
            BlocksCtrl.currentBlockNumber := BlocksCtrl.LineNumberListLeft[ALO].BlockNumber;
        end;
      end;
...

tomkupitz 19. Mai 2021 14:26

AW: Sychrone Listboxen
 
Lösung:

Code:
    TopLine:=...

    Application.ProcessMessages;

    SendMessage(ListBox1.Handle, WM_VSCROLL, MakeLong(LOWORD(SB_THUMBPOSITION), TopLine), 0);
    SendMessage(ListBox2.Handle, WM_VSCROLL, MakeLong(LOWORD(SB_THUMBPOSITION), TopLine), 0);

    Application.ProcessMessages;
:thumb:

tomkupitz 19. Mai 2021 14:34

AW: Sychrone Listboxen
 
Jetzt auch im Tool sichtbar: http://www.screensoft.de/txtc.zip


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:45 Uhr.
Seite 2 von 2     12   

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