的
的士
Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
和TSpeedButton按钮一样,它有如下属性:
Down, GroupIndex, AllowUp;
但我无法实现按钮组的功能,即同一组的TColorButton中只能
有一个在按下状态。因为控件无收到CM_ButtonPressed消息
TColorButton = class(TGraphicControl)
private
FDown: boolean;
FGroupIndex: integer;
FAllowUp: boolean;
....
....
protected
....
....
procedure CMButtonPressed(var message: TMessage);message CM_ButtonPressed;
public
....
....
publishced
....
....
...
end;
procedure TColorButton.CMButtonPressed(var message: TMessage);
var
Sender: TColorButton
begin
if Message.WParam = FGroupIndex then
begin
Sender := TColorButton(Message.LParam);
if Sender <> Self then
begin
if Sender.Down and FDown then
begin
FDown := False;
if (Action is TCustomAction) then
TCustomAction(Action).Checked := False;
Invalidate;
end;
end;
end;
end;
请大侠指点迷津。