2009-07-04 28 views
8

कुछ लंबी वस्तुओं के साथ एक सूची बॉक्स है। ये लंबी वस्तुएं सूची बॉक्स के दाएं किनारे से बाहर हो रही हैं और यहां माउस के ऊपर होने पर ऐसी वस्तुओं के लिए संकेत दिखाने का विचार आता है। (http://delphi.about.com/cs/adptips2001/a/bltip0201_4.htm से)लिस्टबॉक्स लंबे आइटम संकेत

procedure TForm1.ListBox1MouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer) ; 
var lstIndex : Integer ; 
begin 
    with ListBox1 do 
    begin 
    lstIndex:=SendMessage(Handle, LB_ITEMFROMPOINT, 0, MakeLParam(x,y)) ; 
    if (lstIndex >= 0) and (lstIndex <= Items.Count) then 
    Hint := Items[lstIndex] 
    else 
    Hint := '' 
    end; 
    end; 

यह काम करता है, लेकिन हर बार जब मैं एक और आइटम मैं अपने माउस ListBox और फिर बिंदु से दूर स्थानांतरित करने के लिए है के लिए एक संकेत को देखना चाहते:

मैं एक उदाहरण मिल गया है एक और वस्तु पर इसके संकेत देखने के लिए। क्या सूची को बॉक्सबॉक्स से दूर ले जाने के बिना हर आइटम के लिए संकेत देखने का कोई तरीका है?

उत्तर

11
var fOldIndex: integer = -1; 

procedure TForm1.ListBox1MouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer) ; 
var lstIndex : Integer ; 
begin 
    with ListBox1 do 
    begin 
    lstIndex:=SendMessage(Handle, LB_ITEMFROMPOINT, 0, MakeLParam(x,y)) ; 

    // this should do the trick.. 
    if fOldIndex <> lstIndex then 
    Application.CancelHint; 
    fOldIndex := lstIndex; 

    if (lstIndex >= 0) and (lstIndex <= Items.Count) then 
    Hint := Items[lstIndex] 
    else 
    Hint := '' 
    end; 
end; 
+0

बिंगो! आपका बहुत बहुत धन्यवाद! – Vlad

+0

वास्तव में नहीं होना चाहिए (lstIndex <= आइटम.काउंट) वास्तव में होना चाहिए (lstIndex <आइटम.काउंट) – Tom

संबंधित मुद्दे