Текущий архив: 2012.02.19;
Скачать: CL | DM;
Вниз
как присвоить radiobutton к radiogrup Найти похожие ветки
← →
Max (2011-11-09 23:47) [0]при нажатие кнопки создаются определенное количество разбросанных радио-кнопок и очень надо их присвоить к разным группам
RadioButtonA[i]:=TRadioButton.Create(Form1);
RadioButtonA[i].Parent:=Form1;
RadioButtonA[i].Top:=210+50*i;
RadioButtonA[i].Left:=75;
RadioButtonB[i]:=TRadioButton.Create(Form1);
RadioButtonB[i].Parent:=Form1;
RadioButtonB[i].Top:=210+50*i;
RadioButtonB[i]i.Left:=175;
какое свойство отвечает за группу которой предложит радио-кнопка?
что надо прописать или что надо поменять что бы RadioButtonA[i] были из RadioGrupA а RadioButtonB[i] были из RadioGrupB
надеюсь объяснил все внятно
← →
Медвежонок Пятачок © (2011-11-10 00:24) [1]TRadioGroup.Items
← →
Max (2011-11-10 00:59) [2]а можно на пальцах ? (почитал а этой функции в нете но ничего талькового не нашел)
не понимаю куда и что писать
← →
KilkennyCat © (2011-11-10 03:02) [3]RadioButton.Group := номер нужной группы
← →
KilkennyCat © (2011-11-10 03:17) [4]опс, ступил, это не в родном компоненте, а вот в этом:
есть группа
есть картинка подменитьunit KimRobRBCB;
interface
uses
WinProcs, Messages, Classes, Graphics, Controls, StdCtrls, forms;
type
TCustomKimrobRadioButton = class(TCustomControl)
private
FChecked: Boolean;
FGroupIndex: Byte;
FCaption: string;
FOldCursor: TCursor;
FGotClick: boolean;
FPicture : TPicture;
FCheckPicture : TPicture;
FDisPicture : TPicture;
FDisCheckPicture : TPicture;
procedure PictureChanged(Sender : TObject);
procedure SetPicture(Value: TPicture);
procedure SetCheckPicture(Value: TPicture);
procedure SetDisPicture(Value: TPicture);
procedure SetDisCheckPicture(Value: TPicture);
procedure TurnSiblingsOff;
procedure SetChecked(Value:Boolean);
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure SetCaption(const Value: string);
protected
procedure Paint; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState;X, Y: Integer); override;
procedure DoEnter; override;
procedure DoExit; override;
procedure Loaded; override;
procedure DoClick; virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property DisPicture: TPicture read FDisPicture write SetDisPicture;
property DisCheckPicture: TPicture read FDisCheckPicture write SetDisCheckPicture;
property Picture: TPicture read FPicture write SetPicture;
property CheckPicture: TPicture read FCheckPicture write SetCheckPicture;
property Caption: string read FCaption write SetCaption;
property Checked:Boolean read FChecked write SetChecked default False;
property GroupIndex:Byte read FGroupIndex write FGroupIndex default 0;
end;
TKimRobRadioButton = class(TCustomKimrobRadioButton)
published
property Align;
property Action;
property Anchors;
property BiDiMode;
property Constraints;
property Color;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property ParentFont;
property ParentColor;
property Picture;
property CheckPicture;
property DisPicture;
property DisCheckPicture;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property OnClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property Visible;
property Caption;
property Checked;
property GroupIndex;
end;
← →
KilkennyCat © (2011-11-10 03:17) [5]procedure Register;
implementation
procedure Register;
begin
RegisterComponents("KimRob", [TKimRobRadioButton]);
end;
function CreateGrayBmp (Source: TBitmap): TBitmap;
var
Table: array[Byte] of TRGBQuad;
I: Integer;
begin
Result := TBitmap.Create;
with Result do begin
PixelFormat := pf8Bit;
Width := Source.Width;
Height := Source.Height;
for I := Low(Table) to High(Table) do with Table[I] do begin
rgbRed := I;
rgbGreen := I;
rgbBlue := I;
rgbReserved := 0;
end;
SetDIBColorTable(Canvas.Handle, Low(Table), High(Table), Table);
end;
end;
procedure TCustomKimRobRadioButton.PictureChanged(Sender: TObject);
begin
Invalidate;
end;
procedure TCustomKimRobRadioButton.SetPicture(Value: TPicture);
begin
FPicture.Assign(Value);
FPicture.Bitmap.Transparent := true;
FPicture.Bitmap.TransparentMode :=tmAuto;
end;
procedure TCustomKimRobRadioButton.SetCheckPicture(Value: TPicture);
begin
FCheckPicture.Assign(Value);
FCheckPicture.Bitmap.Transparent := true;
FCheckPicture.Bitmap.TransparentMode :=tmAuto;
end;
procedure TCustomKimRobRadioButton.SetDisPicture(Value: TPicture);
begin
FDisPicture.Assign(Value);
FDisPicture.Bitmap.Transparent := true;
FDisPicture.Bitmap.TransparentMode :=tmAuto;
end;
procedure TCustomKimRobRadioButton.SetDisCheckPicture(Value: TPicture);
begin
FDisCheckPicture.Assign(Value);
FDisCheckPicture.Bitmap.Transparent := true;
FDisCheckPicture.Bitmap.TransparentMode :=tmAuto;
end;
procedure TCustomKimRobRadioButton.TurnSiblingsOff;
var
i:Integer;
Sibl: TKimRobRadioButton;
begin
if (Parent <> nil) then
for i := 0 to Parent.ControlCount - 1 do if Parent.Controls[i] is TKimRobRadioButton then begin
Sibl := TKimRobRadioButton(Parent.Controls[i]);
if (Sibl <> Self) and (Sibl.GroupIndex = GroupIndex) then Sibl.SetChecked(False);
end;
end;
procedure TCustomKimRobRadioButton.SetChecked(Value: Boolean);
begin
if FChecked <> Value then begin
FChecked := Value;
if Value then begin
TurnSiblingsOff;
DoClick;
end;
Invalidate;
end;
end;
constructor TCustomKimRobRadioButton.Create(AOwner: TComponent);
var
FDesignTime: boolean;
begin
inherited Create(AOwner);
FDisPicture := TPicture.Create;
FDisPicture.OnChange := PictureChanged;
FDisCheckPicture := TPicture.Create;
FDisCheckPicture.OnChange := PictureChanged;
FPicture := TPicture.Create;
FPicture.OnChange := PictureChanged;
FCheckPicture := TPicture.Create;
FCheckPicture.OnChange := PictureChanged;
Width := 135;
Height := 20;
FDesignTime := (csDesigning in ComponentState) and not ((csReading in Owner.ComponentState) or (csLoading in Owner.ComponentState));
if FDesignTime then FCaption := self.ClassName;
end;
procedure TCustomKimRobRadioButton.Paint;
var
R: TRect;
y : Integer;
begin
Canvas.Font := Font;
if not enabled then Canvas.Font.Color := clSilver;
with Canvas do begin
Lock;
try
DrawText(Handle, PChar(Caption), Length(Caption), R, DT_CALCRECT or DT_LEFT or DT_TOP or DT_SINGLELINE);
y := (ClientRect.Bottom - ClientRect.Top) div 2;
if Enabled then
if Checked then begin
Draw(0, y - (FCheckPicture.Height div 2), FCheckPicture.Graphic);
R.Left := FCheckPicture.Width;
end else begin
Draw(0, y - (FPicture.Height div 2), FPicture.Graphic);
R.Left := FPicture.Width;
end else if Checked then begin
Draw(0, y - (FDisCheckPicture.Height div 2), FDisCheckPicture.Graphic);
R.Left := FDisCheckPicture.Width;
end else begin
Draw(0, y - (FDisPicture.Height div 2), FDisPicture.Graphic);
R.Left := FDisPicture.Width;
end;
R.Right := R.Right + R.Left;
R.Top := y - (R.Bottom - R.Top) div 2 - 1;
R.Bottom := R.Bottom + R.Top;
Brush.Style := bsClear;
DrawText(Handle, PChar(Caption), Length(Caption), R, DT_SINGLELINE or DT_LEFT or DT_TOP or DT_NOPREFIX);
finally
Unlock;
end;
end;
end;
procedure TCustomKimRobRadioButton.DoClick;
begin
if not (csLoading in ComponentState) then if Assigned(OnClick) then OnClick(Self);
end;
procedure TCustomKimRobRadioButton.DoEnter;
begin
inherited DoEnter;
Checked := true;
Repaint;
end;
procedure TCustomKimRobRadioButton.DoExit;
begin
inherited DoExit;
Repaint;
end;
procedure TCustomKimRobRadioButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FGotClick := true;
if (self.CanFocus and not (csDesigning in ComponentState)) then SetFocus;
inherited MouseDown(Button, Shift, X, Y);
MouseCapture := True;
Invalidate;
end;
procedure TCustomKimRobRadioButton.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
MouseCapture := False;
if (X >= 0) and (X <= Width) and (Y >= 0) and (Y <= Height) and not Checked and FGotClick then Checked := true;
inherited MouseUp(Button, Shift, X, Y);
if FGotClick then DoClick;
Invalidate;
FGotClick := false;
end;
procedure TCustomKimRobRadioButton.MouseMove(Shift: TShiftState;X, Y: Integer);
begin
if self.Cursor = crHandPoint then self.Cursor := FOldCursor;
inherited MouseMove(Shift,X,Y);
end;
procedure TCustomKimRobRadioButton.CMEnabledChanged(var Message: TMessage);
begin
inherited;
Invalidate;
end;
destructor TCustomKimRobRadioButton.Destroy;
begin
FPicture.Destroy;
FCheckPicture.Destroy;
FDisPicture.Destroy;
FDisCheckPicture.Destroy;
inherited;
end;
procedure TCustomKimRobRadioButton.SetCaption(const Value: string);
begin
inherited Caption := Value;
FCaption := Value;
Invalidate;
end;
procedure TCustomKimRobRadioButton.Loaded;
begin
inherited;
FOldCursor := Cursor;
end;
end.
← →
MBo © (2011-11-10 06:45) [6]radiobutton группируются по контролам-контейнерам, так что для них описанного поведения достичь нелегко.
А вот со speedbutton такое сделать можно, если по виду подойдут
← →
Омлет © (2011-11-10 08:37) [7]> Max (09.11.11 23:47)
Для этого есть компонент RadioGroup в палитре стандартных компонентов.
← →
Медвежонок Пятачок © (2011-11-10 08:41) [8]не понимаю куда и что писать
Куда: президенту.
Что: При путине такого не было
← →
Плохиш © (2011-11-10 11:15) [9]
> Max (10.11.11 00:59) [2]
> а можно на пальцах ? (почитал а этой функции в нете но ничего
> талькового не нашел)
>
На пальцах расписано в справке, но она же для лохов писана.
← →
_Юрий (2011-11-10 19:45) [10]
> Медвежонок Пятачок © (10.11.11 08:41) [8]
Невъезжание в суть вопроса не должно отвращать истинного гуру от распальцовки при ответе, не так ли?
← →
Медвежонок Пятачок © (2011-11-10 21:07) [11]конечно так.
и первый же ответ был:
>TRadioGroup.Items
Жми F1 и кури. Чего еще надо?
← →
Медвежонок Пятачок © (2011-11-10 21:25) [12]Кроме того, Юра,
тебе-то кто мешал все это время ощастливить автора вопроса нужным кодом?
Страницы: 1 вся ветка
Текущий архив: 2012.02.19;
Скачать: CL | DM;
Память: 0.5 MB
Время: 0.004 c