SkinUI5.0官方文档

SkinUI5.0官方文档


单选框

<p>超链CRadioButton,继承于CButton,支持CButton的所有属性和方法。</p> <h2>属性和相关方法</h2> <h4>设置单选框是否选中</h4> <ul> <li>通过XML属性控制如下:</li> </ul> <pre><code class="language-xml">Checked="true"</code></pre> <ul> <li>通过C++程序代码调用方法控制如下:</li> </ul> <pre><code class="language-c">virtual void SetChecked(BOOL bChecked);</code></pre> <h4>设置单选框绑定的视图</h4> <ul> <li>通过XML属性控制如下:</li> </ul> <pre><code class="language-xml">BindView="1001"</code></pre> <ul> <li>通过C++程序代码调用方法控制如下:</li> </ul> <pre><code class="language-c">void SetBindView(LONG nBindView);</code></pre> <h2>消息处理</h2> <h4>WM_RADIO_GROUP_CHECKED_CHANGE</h4> <p>单选框一般作为CRadioGroup的子控件,这样可以用来做互斥的选择。当CRadioGroup的选中状态发生变化时,会切换绑定的视图,同时会给所在窗口发送自定义消息WM_RADIO_GROUP_CHECKED_CHANGE。</p> <ul> <li>参考下面的示例代码:</li> </ul> <pre><code class="language-cpp">void CRadioGroup::SetChecked(CRadioButton* pRadioButton) { CRadioButton* pOldChecked = GetChecked(); CRadioButton* pNewChecked = pRadioButton; if(pOldChecked == pNewChecked) { return; } CRedrawLocker locker(GetOwner()); if(pNewChecked) { pNewChecked-&gt;SetChecked(TRUE); } if(pOldChecked) { pOldChecked-&gt;SetChecked(FALSE); if(pOldChecked-&gt;IsVisible()) { pOldChecked-&gt;SetState(NORMAL); } } CView* pBindView = GetBindView(pNewChecked); if(pBindView) { CSwitchLayout* pAnimationView = dynamic_cast&lt;CSwitchLayout*&gt;(pBindView-&gt;GetParent()); if(pAnimationView) { pAnimationView-&gt;Show(pBindView); } else { pBindView-&gt;SetState(NORMAL); CView* pBindView = GetBindView(pOldChecked); if(pBindView) { pBindView-&gt;SetState(HIDED); } } } GetOwner()-&gt;SendMessage(WM_RADIO_GROUP_CHECKED_CHANGE, GetId(), reinterpret_cast&lt;LPARAM&gt;(this)); }</code></pre> <ul> <li>消息处理示例:</li> </ul> <pre><code class="language-cpp">void OnRadioGroupCheckedChange(LONG nId, CRadioGroup* pRadioGroup, BOOL&amp; bHandle); SKINUI_DECLARE_MESSAGE_MAP()</code></pre> <pre><code class="language-cpp">SKINUI_BEGIN_MESSAGE_MAP(CDemoRadioButtonLayout, CScrollLayout) ON_SKINUI_WM_RADIO_GROUP_CHECKED_CHANGE() SKINUI_END_MESSAGE_MAP() void CDemoRadioButtonLayout::OnRadioGroupCheckedChange(LONG nId, CRadioGroup* pRadioGroup, BOOL&amp; bHandle) { bHandle = TRUE; }</code></pre> <h4>WM_RADIO_BUTTON_CHECKED_CHANGE</h4> <p>单选框选中状态发生变化时,会给所在窗口发送自定义消息WM_RADIO_BUTTON_CHECKED_CHANGE。</p> <ul> <li>参考下面的示例代码:</li> </ul> <pre><code class="language-cpp">void CRadioButton::SetChecked(BOOL bChecked) { BOOL bOldChecked = IsChecked(); if(bOldChecked != bChecked) { CButton::SetChecked(bChecked); GetOwner()-&gt;SendMessage(WM_RADIO_BUTTON_CHECKED_CHANGE, GetId(), reinterpret_cast&lt;LPARAM&gt;(this)); } }</code></pre> <ul> <li>消息处理示例:</li> </ul> <pre><code class="language-cpp">void OnRadioButtonCheckedChange(LONG nId, CRadioButton* pRadioButton, BOOL&amp; bHandle); SKINUI_DECLARE_MESSAGE_MAP()</code></pre> <pre><code class="language-cpp">SKINUI_BEGIN_MESSAGE_MAP(CDemoRadioButtonLayout, CScrollLayout) ON_SKINUI_WM_RADIO_BUTTON_CHECKED_CHANGE() SKINUI_END_MESSAGE_MAP() void CDemoRadioButtonLayout::OnRadioButtonCheckedChange(LONG nId, CRadioButton* pRadioButton, BOOL&amp; bHandle) { bHandle = TRUE; }</code></pre> <h2>示例</h2> <h4>效果图</h4> <p><img src="http://www.skinui.cn/doc/img/5.0/3/RadioButton.png" alt="超链" /></p> <h4>普通单选框</h4> <pre><code class="language-xml">&lt;RadioButton Id="1000" Width="WrapContent" Height="WrapContent" Layout="RadioButton.xml" ChildText11="普通单选框"/&gt; &lt;RadioButton Id="1001" Width="WrapContent" Height="WrapContent" Layout="RadioButton.xml" ChildText11="普通单选框" Checked="true"/&gt;</code></pre> <h4>单选框不带文字</h4> <pre><code class="language-xml">&lt;RadioButton Id="1000" Width="WrapContent" Height="WrapContent" Layout="RadioButton.xml"/&gt; &lt;RadioButton Id="1001" Width="WrapContent" Height="WrapContent" Layout="RadioButton.xml" Checked="true"/&gt;</code></pre> <h4>单选框带图标</h4> <pre><code class="language-xml">&lt;RadioButton Id="1000" Width="WrapContent" Height="WrapContent" Layout="RadioButtonWithIcon.xml" ChildImage11="Icon.png" ChildText12="单选框带图标"/&gt; &lt;RadioButton Id="1001" Width="WrapContent" Height="WrapContent" Layout="RadioButtonWithIcon.xml" ChildImage11="Icon.png" ChildText12="单选框带图标" Checked="true"/&gt;</code></pre> <h4>单选框带图标不带文字</h4> <pre><code class="language-xml">&lt;RadioButton Id="1000" Width="WrapContent" Height="WrapContent" Layout="RadioButtonWithIcon.xml" ChildImage11="Icon.png"/&gt; &lt;RadioButton Id="1001" Width="WrapContent" Height="WrapContent" Layout="RadioButtonWithIcon.xml" ChildImage11="Icon.png" Checked="true"/&gt;</code></pre>

页面列表

ITEM_HTML