• Page:
  • 1

TOPIC: C++ VCL RadioGroup question

C++ VCL RadioGroup question 1 week 13 hours ago #14811

How can RadioGroup be rendered without a border, just the radio buttons?

I am sure this has been asked before, probably 15 years ago, but the forum is long wasted.

Please Log in or Create an account to join the conversation.

C++ VCL RadioGroup question 6 days 18 hours ago #14827

Hi Keith,

A quick Google search threw this up;

stackoverflow.com/questions/7430219/how-...r-around-tradiogroup

There is no BorderStyle on TRadioGroup so looks like you have to just put some Radio Button on a TPanel instead and deal with it that way.

Andy

Please Log in or Create an account to join the conversation.

C++ VCL RadioGroup question 6 days 13 hours ago #14837

If you want the Items functionality etc. that TRadioGroup has I think you'll need to create your own custom component for that. I tried this and it's working fine:

BorderlessRadioGroup.h
#ifndef BorderlessRadioGroupH
#define BorderlessRadioGroupH
//---------------------------------------------------------------------------
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
//---------------------------------------------------------------------------
//typedef Vcl::Controls::TCustomControl TBorderlessRadioGroupBase;
//typedef Vcl::Stdctrls::TCustomGroupBox TBorderlessRadioGroupBase;
typedef Vcl::Extctrls::TCustomRadioGroup TBorderlessRadioGroupBase;

class PACKAGE TBorderlessRadioGroup : public TBorderlessRadioGroupBase
{
private:
protected:
	virtual void __fastcall Paint(void);
public:
	__fastcall TBorderlessRadioGroup(TComponent* Owner);
__published:
	__property Align = {default=0};
	__property Anchors = {default=3};
	__property BiDiMode;
	__property Caption = {default=0};
	__property Color = {default=-16777211};
	__property Columns = {default=1};
	__property Ctl3D;
	__property DoubleBuffered;
	__property DragCursor = {default=-12};
	__property DragKind = {default=0};
	__property DragMode = {default=0};
	__property Enabled = {default=1};
	__property Font;
	__property ItemIndex = {default=-1};
	__property Items;
	__property Constraints;
	__property ParentBiDiMode = {default=1};
	__property ParentBackground = {default=1};
	__property ParentColor = {default=1};
	__property ParentCtl3D = {default=1};
	__property ParentDoubleBuffered = {default=1};
	__property ParentFont = {default=1};
	__property ParentShowHint = {default=1};
	__property PopupMenu;
	__property ShowHint;
	__property TabOrder = {default=-1};
	__property TabStop = {default=0};
	__property Touch;
	__property Visible = {default=1};
	__property StyleElements = {default=7};
	__property WordWrap = {default=0};
	__property OnClick;
	__property OnContextPopup;
	__property OnDragDrop;
	__property OnDragOver;
	__property OnEndDock;
	__property OnEndDrag;
	__property OnEnter;
	__property OnExit;
	__property OnGesture;
	__property OnStartDock;
	__property OnStartDrag;

};
//---------------------------------------------------------------------------
#endif
BorderlessRadioGroup.cpp
//---------------------------------------------------------------------------
#include <vcl.h>

#pragma hdrstop

#include "BorderlessRadioGroup.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TBorderlessRadioGroup *)
{
	new TBorderlessRadioGroup(NULL);
}
//---------------------------------------------------------------------------
__fastcall TBorderlessRadioGroup::TBorderlessRadioGroup(TComponent* Owner)
	: TBorderlessRadioGroupBase(Owner)
{
}
//---------------------------------------------------------------------------
namespace Borderlessradiogroup
{
	void __fastcall PACKAGE Register()
	{
		TComponentClass classes[1] = {__classid(TBorderlessRadioGroup)};
		RegisterComponents(L"Lyncon", classes, 0);
	}
}
//---------------------------------------------------------------------------
void __fastcall TBorderlessRadioGroup::Paint(void) {
    // Add painting the Caption here if you want that
}

Please Log in or Create an account to join the conversation.

C++ VCL RadioGroup question 6 days 7 hours ago #14852

Andy wrote: A quick Google search threw this up;

stackoverflow.com/questions/7430219/how-...r-around-tradiogroup

There is no BorderStyle on TRadioGroup so looks like you have to just put some Radio Button on a TPanel instead and deal with it that way.


Yup, that is exactly what you would have to do. TRadioGroup is hard-coded to always draw a border, there is no option to turn that off, unless you handle the painting manually.

Please Log in or Create an account to join the conversation.

Last Edit: by Remy.
  • Page:
  • 1
Moderators: April Anne