Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.02.08 17:21 
Hi, Delpher,

ich habe eine Listbox, die ich nicht größer machen kann. Einige Einträge sind länger als die Breite, Scrollbar ist vorhanden.
Wie kann ich durch "Herüberfahren" mit der Maus trotzdem den kompletten Eintrag sehen?

Danke für Hilfe,
Detlef A.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Sa 09.02.08 17:39 
In OnMouseMove per ItemAtPos Hint setzen und in Application per CancelHint neuzeichnen erzwingen

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 09.02.08 18:06 
Hi, Kroko,

folgendes habe ich gefunden, bzw. ist möglich:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var item: Integer;
begin
  with Sender as TListbox do
  begin
    item := itemAtpos(Point(x, y), true);
    if item >= 0 then
    begin
      if hint <> items[item] then
      begin
        hint := items[item];
        application.cancelhint;
      end;
    end;
  end;
end;


// oder

procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var  APoint: TPoint;
  Index: Integer;
begin
  APoint.X := X;  APoint.Y := Y;
  Index := ListBox1.ItemAtPos(APoint, True);
  if Index >= 0 then ListBox1.Hint := ListBox1.Items.Strings[Index];
end;

// oder:

//ShowHint := false
procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var  APoint: TPoint;
  Index: Integer;
  HW: THintWindow;
  Rec: TRect;
  sHint: string;
begin
  APoint.X := X;  APoint.Y := Y;
  Index := ListBox1.ItemAtPos(APoint, True);
  if Index >= 0 then
  begin
    HW := THintWindow.Create(nil);
    try
      GetCursorPos(APoint);
      sHint := ListBox1.Items.Strings[Index];
      Rec.Top := APoint.Y + 20;
      Rec.Left := APoint.X;
      Rec.Right := Rec.Left + HW.Canvas.TextWidth(sHint) + 6;
      Rec.Bottom := Rec.Top + HW.Canvas.TextHeight(sHint) + 4;
      HW.ActivateHint(Rec, sHint);
      HW.Refresh;
      Sleep(1000);
      HW.ReleaseHandle;
    finally
      HW.Free;
    end;
  end;
end;


Ich habe mich (zunächst) für den zweiten Vorschlag entschieden.

Vielen Dank für deinen Hinweis,
Detlef

P.S. Deine erste Idee ist doch besser :oops: Grüße aus Lübeck, Detlef