0

如图所示,我需要在每个项目上制作一个带有按钮的列表,项目左下角一个按钮,右下角一个按钮。

ListBox我在上面的面板中使用控件和一些按钮制作演示应用程序ListBox,但是当ListBox滚动时,很难使按钮跟随ListItem

谁能帮忙,谢谢~~~

图片

4

1 回答 1

0

我有办法做到这一点!所以,我会自己发布答案〜,但雷米勒博启发了我。一开始,我习惯DrawFrameControl()在列表上制作按钮,它可以工作,但风格看起来像经典的windows风格,很难像示例中的图片那样制作背景颜色。然后,我使用FillRect()DrawEdge()制作了Button,我认为它很好,代码如下:

  hitPoint := lst1.ScreenToClient(Mouse.CursorPos);
  // there is a btnRect var of the Button Rect
  edgeRect.Left := btnRect.Left - 1;
  edgeRect.Top := btnRect.Top - 1;
  edgeRect.Right := btnRect.Right + 1;
  edgeRect.Bottom := btnRect.Bottom + 1;
  // make button
  lst1.Canvas.FillRect(btnRect);
  // make edge, FListMouseDown is bool var and setting value at MouseDown/MouseUp Event
  //
  if PtInRect(edgeRect, hitPoint) and FListMouseDown then begin
    DrawEdge(lst1.Canvas.Handle, edgeRect, EDGE_ETCHED, BF_RECT);  // button down style
  end else begin
    DrawEdge(lst1.Canvas.Handle, edgeRect, EDGE_RAISED, BF_RECT);
  end;

下面的工作是将Buttons的Rect存储在内存中,编写ButtonOnClick事件代码,ListMouseUp()在判断Mouse Hit Position是否在Button Rect中后,在事件中调用ButtonOnClick事件,代码不像上面画Button那样重要,所以是省略

于 2015-01-12T06:14:03.483 回答