Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

版权申明
查看: 6987|回复: 0

ListBox类似组件,鼠标右键点击事件得到选中Item

[复制链接]
  • TA的每日心情
    奋斗
    2022-6-24 15:56
  • 签到天数: 10 天

    [LV.3]偶尔看看II

    发表于 2010-1-16 11:36:25 | 显示全部楼层 |阅读模式
    转自:http://www.solokey.cn/
    允许多选的ListBox需要加判断.可以参考被注释掉的代码.不再赘述.

    //OnMouseUp:

    var
      APoint: TPoint;
      Index: Integer;
    begin
      if Button=mbRight then
      begin
        APoint.x := X;
        APoint.y := Y;
        Index := ListBox.ItemAtPos(APoint, True);
        {if (ListBox.SelCount <= 1) and  (Index >= 0) then begin
          SelectedListBox(False);
          LMDListBox.Selected[Index] := True;
        end;}
        {if (LMDListBox.SelCount > 0) and (Index >= 0) and LMDListBox.Selected[Index]  then
        begin
          ListBox.ItemIndex:=Index;}
          GetCursorPos(APoint);
         { InitPopupMenu(Index,PopupMenu);}//根据选中的Item对PopupMenu的MenuItem进行调整.可选
          PopupMenu.Popup(APoint.x,APoint.y);
       { end;}
      end;
    end;
    回复

    使用道具 举报

    *滑块验证:

    本版积分规则

    QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

    GMT+8, 2024-3-19 10:53 , Processed in 0.026391 second(s), 9 queries , Redis On.

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表