SkinUI5.0官方文档

SkinUI5.0官方文档


热键选择框

<p>热键选择框CHotKeyView,继承于CEditView,支持CEditView的所有属性和方法。</p> <h2>消息处理</h2> <h4>WM_HOTKEY_CHANGE</h4> <p>热键列表框的值发生变化时,会给所在窗口发送自定义消息WM_HOTKEY_CHANGE。</p> <p>参考下面的示例代码:</p> <pre><code class="language-cpp">void CHotKeyView::HandleKeyDown(TCHAR vkey, UINT repeats, UINT code, BOOL&amp; bHandle) { String strVirtualKeyCode = CStringHelper::VirtualKeyCodeToString(vkey); if(!strVirtualKeyCode.empty()) { m_bKeyUpClear = FALSE; m_wVirtualKeyCode = vkey; m_wModifiers = CMiscHelper::GetCurModifiers(); if(m_wModifiers == 0 &amp;&amp; CMiscHelper::NeedDefaultModifiers(vkey)) { m_wModifiers = 3; } SetText(CStringHelper::ModifiersToString(m_wModifiers) + strVirtualKeyCode); GetOwner()-&gt;SendMessage(WM_HOTKEY_CHANGE, GetId(), reinterpret_cast&lt;LPARAM&gt;(this)); } else { m_wModifiers = 0; m_wVirtualKeyCode = 0; m_bKeyUpClear = TRUE; if(vkey == VK_SHIFT || vkey == VK_CONTROL || vkey == VK_MENU) { WORD wModifiers = CMiscHelper::GetCurModifiers(); String strModifiers = CStringHelper::ModifiersToString(wModifiers); SetText(strModifiers); } else if(vkey == VK_BACK || vkey == VK_DELETE || vkey == VK_RETURN) { SetText(String()); } } bHandle = TRUE; }</code></pre> <h2>请看下面的示例</h2> <h4>效果图</h4> <p><img src="http://www.skinui.cn/doc/img/5.0/3/ComboBox.png" alt="下拉列表框" /></p> <pre><code class="language-xml">&lt;RelativeLayout AlignParentLeft="40" AlignParentTop="0" AlignParentRight="20" AlignParentBottom="0"&gt; &lt;HotKeyView Id="1001" Width="200" Height="30" Background="Edit.png" AlignParentLeft="0" AlignParentVertCenter="0"/&gt; &lt;/RelativeLayout&gt;</code></pre> <h4>h文件</h4> <pre><code class="language-cpp">#pragma once class CDemoHotKeyViewLayout : public CScrollLayout { public: enum { IDC_HOTKEY = 1001, }; public: CDemoHotKeyViewLayout(CView* pParent); public: virtual void OnBuildFinish(); protected: void OnHotKeyChange(LONG nId, CHotKeyView* pHotKeyView, BOOL&amp; bHandle); SKINUI_DECLARE_MESSAGE_MAP() SKINUI_DECLARE_DYNCREATE(CDemoHotKeyViewLayout, CScrollLayout) };</code></pre> <h4>cpp文件</h4> <pre><code class="language-cpp">#include &lt;stdafx.h&gt; #include "DemoHotKeyViewLayout.h" SKINUI_BEGIN_MESSAGE_MAP(CDemoHotKeyViewLayout, CScrollLayout) ON_SKINUI_WM_HOTKEY_CHANGE() SKINUI_END_MESSAGE_MAP() CDemoHotKeyViewLayout::CDemoHotKeyViewLayout(CView* pParent) : CScrollLayout(pParent) { } void CDemoHotKeyViewLayout::OnBuildFinish() { CScrollLayout::OnBuildFinish(); CHotKeyView* pHotKeyView = dynamic_cast&lt;CHotKeyView*&gt;(GetChildById(IDC_HOTKEY)); if(pHotKeyView) { pHotKeyView-&gt;SetHotKey(HOTKEYF_CONTROL | HOTKEYF_SHIFT, VK_DOWN); } } void CDemoHotKeyViewLayout::OnHotKeyChange(LONG nId, CHotKeyView* pHotKeyView, BOOL&amp; bHandle) { bHandle = TRUE; GetOwner()-&gt;Toast(_T("HotKey Change To: ") + pHotKeyView-&gt;GetText()); }</code></pre>

页面列表

ITEM_HTML