包含另一个按钮的那个按钮的名称是什么? [英] whats is the name of that button whic contain another button?

查看:137
本文介绍了包含另一个按钮的那个按钮的名称是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,

我正在delphi-2010中工作.
我添加了2个TSpeedButton.

我想在每个按钮中添加另一个按钮.
例如-
在工具箱中的Photoshop中,其中包含切片"工具.
然后有3种不同类型的切片可用,但是一次只有一个被激活.

我该如何制作这种类型的按钮.

请帮助我.

Dear sir,

I''m working in delphi-2010.
I have added 2 TSpeedButton.

I want to add another button in each button.
For Example-
In photoshop from Toolbox which contain a Slice tool.
Then there are 3 different types of slice available but at a time only one is activated.

How can I make this type of button.

Please Help me.

推荐答案

您好,

要实现的功能有很多可能的解决方案.这是较容易使用的组件之一(除了购买一组具有该功能的第三方组件; P之外):

成分
2个TSpeedButton
1个TPopupMenu组件
n x TMenuItem(用于您不同的按钮"选项)

食谱
并排放置两个按钮.使第二个按钮刚好足以容纳向下箭头的图像.根据您要显示按钮的选定"事件/动作的方式,您可以摆弄第一个按钮的大小.在第二个按钮单击事件上,您将执行以下操作:
Hello,

There are many possible solutions to the feature you want to implement. Here is one of the more easier ones (besides buying a set of third party components that have that functionality ;P):

Ingredients
2 x TSpeedButton
1 x TPopupMenu component
n x TMenuItem (for your different ''button'' options)

Recipe
Place the 2 buttons side-by-side. Make the second button just wide enough to hold the down arrow image. Depending on how you want to display the ''selected'' event/action for the button, you can fiddle around with the size of the first button. On your second button click event, you will to do something like:
procedure SecondButtonClickEvent(Sender : TObject);
begin
  // NOTE: You can define your own calculation to find a particular 
  // position where you want the menu to popup, like the bottom-right
  // of the button for instance...
  MyPopupMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
end;


在菜单项事件中,请确保您有一行这样的代码:


In your menu item events, make sure you have a line of code that goes something like this:

procedure SetupMyFirstButton(SelectedItem : TMenuItem);
begin
  FirstSpeedButton.OnClick := SelectedItem.OnClick;
  // You may also want to set the caption and/or image
  // as well as anything else that may come to mind...
end;

procedure SomeMenuItemOnClickEvent(Sender : TObject);
begin
  // Perform some stuff for the event...
  // Now do this:
  if (Sender is TMenuItem) then
  // We only want to do this if the calling component is
  // actually a menu item because it would be pointless to
  // assign this when we click the button.
  begin
    SetupMyFirstButton(TMenuItem(Sender));
  end;
end;


这样,您可以确保您的上次选择"菜单项始终链接到第一个按钮.另外,初始化窗体时,您可以将默认"事件分配给第一个按钮,如下所示:


By doing this, you can make sure you have your ''last selected'' menu item is always linked to the first button. In addition, you can assign a ''default'' event to the first button when you initialise the form that you are building this on like so:

//In some initialisation part of your form...
SetupMyFirstButton(TheMenuItemYouWantToBeDefault);


免责声明:这绝不是做到这一点的最正确"方法.如果此代码由于某种原因或其他原因导致普通海参的生命周期变得无法挽回,则我概不负责. :-D


DISCLAIMER: This is by no means the ''most correct'' way of doing this. I take no responsiblity if this code, for some or other reason, causes the lifecycle of the common sea cucumber to become irrevocably broken... :-D


这篇关于包含另一个按钮的那个按钮的名称是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆