用listbox.itemindex可以知道当前那一个条目被选择

解决方案 »

  1.   

    procedure TForm1.ListBox1Click(Sender: TObject);
    begin
       showmessage(inttostr(ListBox1.ItemIndex));
    end;
      

  2.   

    这两天看windows编程看的已经木了,谢谢提醒
      

  3.   

    procedure TMyListBoxDescendant.SubClassWndProc(var Message: TMessage);begin
      if Message.Msg = WM_GETSEL then
        Style := TListBoxStyle(Message.WParam)
      else
        WndProc(Message);end;procedure TMyListBoxDescendant.ToggleSubClass(On: Boolean);begin
      if On then
        WindowProc := SubClassWndProc;
      else
        WindowProc := WndProc;end;procedure TForm1.SubClassRadioGroup1Click(Sender: TObject);begin
      MyListBoxDescendant1.ToggleSubClass(SubClassRadioGroup1.ItemIndex = 0);
    end;