SkinUI入门教程

SkinUI入门教程


3.15 时间控件

<p>日期控件由CSkinTimeView类来代表,继承于CSkinRelativeLayout,支持CSkinRelativeLayout的所有属性和方法。</p> <h2>1 属性和相关方法:</h2> <h4>1.1 设置时间</h4> <ul> <li>通过C++程序代码调用方法控制如下: <pre><code class="language-c">void SetTime(LONG nHour, LONG nMinute, LONG nSecond);</code></pre></li> </ul> <h4>1.2 获取时间</h4> <ul> <li>通过C++程序代码调用方法控制如下: <pre><code class="language-c">void GetTime(LONG&amp;amp; nHour, LONG&amp;amp; nMinute, LONG&amp;amp; nSecond);</code></pre></li> </ul> <h2>请看下面的示例</h2> <h4>效果图</h4> <p><img src="http://www.skinui.cn/doc/img/3/15/1.png" alt="时间控件" /></p> <h4>布局文件</h4> <pre><code class="language-xml">&amp;lt;SkinDialog DefaultWidth=&amp;quot;400&amp;quot; DefaultHeight=&amp;quot;300&amp;quot; SysButton=&amp;quot;CLOSE&amp;quot; Icon=&amp;quot;128&amp;quot; Caption=&amp;quot;IDS_CONTROL_SHOW15&amp;quot; Animation=&amp;quot;SizeChange&amp;quot;&amp;gt; &amp;lt;SkinTimeView Id=&amp;quot;101&amp;quot; LayoutWidth=&amp;quot;200&amp;quot; LayoutHeight=&amp;quot;30&amp;quot; Layout=&amp;quot;TimeView.xml&amp;quot; Image=&amp;quot;Edit.png&amp;quot; AlignParentHorizontalCenter=&amp;quot;0&amp;quot; AlignParentVerticalCenter=&amp;quot;-20&amp;quot; /&amp;gt; &amp;lt;SkinButton Id=&amp;quot;102&amp;quot; LayoutWidth=&amp;quot;100&amp;quot; LayoutHeight=&amp;quot;30&amp;quot; ChildText1=&amp;quot;获取日期&amp;quot; Image=&amp;quot;Button.png&amp;quot; Layout=&amp;quot;Button.xml&amp;quot; AlignParentHorizontalCenter=&amp;quot;0&amp;quot; AlignParentVerticalCenter=&amp;quot;30&amp;quot; /&amp;gt; &amp;lt;/SkinDialog&amp;gt;</code></pre> <h4>h文件</h4> <pre><code class="language-cpp">#pragma once class CTimeViewDialog : public CSkinDialog { public: enum { IDC_TIMEVIEW = 101, IDC_BUTTON = 102, }; public: CTimeViewDialog(const tstring&amp;amp; strXml); public: virtual void OnInitDialog(); protected: void OnBtnClickedGetTime(UINT uNotifyCode, int nID, CSkinView* pView); SKINUI_DECLARE_MESSAGE_MAP() private: CSkinTimeView* m_pTimeView; };</code></pre> <h4>cpp文件</h4> <pre><code class="language-cpp">#include &amp;quot;stdafx.h&amp;quot; #include &amp;quot;TimeViewDialog.h&amp;quot; SKINUI_BEGIN_MESSAGE_MAP(CTimeViewDialog, CSkinDialog) ON_SKINUI_COMMAND(IDC_BUTTON, OnBtnClickedGetTime) SKINUI_END_MESSAGE_MAP() CTimeViewDialog::CTimeViewDialog(const tstring&amp;amp; strXml) : CSkinDialog(strXml) , m_pTimeView(NULL) { } void CTimeViewDialog::OnInitDialog() { CSkinDialog::OnInitDialog(); m_pTimeView = static_cast&amp;lt;CSkinTimeView*&amp;gt;(GetChildById(IDC_TIMEVIEW)); if(m_pTimeView) { m_pTimeView-&amp;gt;SetTime(12, 34, 56); } } void CTimeViewDialog::OnBtnClickedGetTime(UINT uNotifyCode, int nID, CSkinView* pView) { if(m_pTimeView) { LONG nHour = 0, nMinute = 0, nSecond = 0; m_pTimeView-&amp;gt;GetTime(nHour, nMinute, nSecond); MsgBox(SkinUI::StringFormat(_T(&amp;quot;当前时间为:%d时%d分%d秒&amp;quot;), nHour, nMinute, nSecond)); } }</code></pre>

页面列表

ITEM_HTML