グループに追加されているラジオボタンの数を取得します。
書式
int GetRadioButtonCount();
|
パラメータ
戻り値
グループに追加されているラジオボタンの数が返されます。
解説
グループに「Add」でラジオボタンを追加したときの、ラジオボタンの数を取得します。
例
ウィンドウ(ダイアログ)を生成して、その中にグループを配置します。
さらに、グループ内にラジオボタンを3つ追加しています。
CPWindow win;
CPGroup group;
CPRadioButton r1,r2,r3;
int cou,rpos;
//ダイアログを生成する
win.Clear();
win.CreateNewDialog("TestDialog",120,120,240,120);
//グループの位置・サイズを指定
group.SetBounds(10,10,200,100);
//グループの文字列を指定
group.SetText("Group");
//グループをCPWindowに結びつける
win.Add(&group);
//グループにラジオボタンを追加
r1.SetBounds(10,24,160,20);
r1.SetText("Radio 1");
group.Add(&r1);
r2.SetBounds(10,46,160,20);
r2.SetText("Radio 2");
group.Add(&r2);
r3.SetBounds(10,68,160,20);
r3.SetText("Radio 3");
group.Add(&r3);
//グループ内のラジオボタンの数を取得
cou=group.GetRadioButtonCount();
//ラジオボタンの1番目を選択
group.SelectRadioButton(&r2);
//現在選択されているラジオボタンの番号を取得
rpos=group.GetRadioButton();
//ダイアログの表示・イベントループの開始
win.DoModal();
この例の場合、
以下のようなダイアログが表示されます。

また、「cou=3 / rpos=1」が返されます。
ビルド時に必要なファイル
ライブラリ
| :CPartsLib.lib (Macintoshの場合は、CPartsCW.a)
|
ヘッダ
| :CPGroup.h
|
関連リンク
CPGroupクラス
CPRadioButtonクラス
CPGroup::SelectRadioButton
CPGroup::GetRadioButton