SimpleWindow
载入中...
搜索中...
未找到
sw::UIElement类 参考abstract

表示界面中的元素 更多...

#include <UIElement.h>

类 sw::UIElement 继承关系图:
sw::WndBase sw::ILayout sw::ITag sw::Control sw::Layer sw::ItemsControl< StrList > sw::Animation sw::ButtonBase sw::DateTimePicker sw::HotKeyControl sw::ItemsControl< TItem > sw::MonthCalendar sw::PanelBase sw::ProgressBar sw::Slider sw::StaticControl sw::StatusBar sw::SysLink sw::TabControl sw::TextBoxBase sw::PanelBase sw::Window

Public 成员函数

virtual ~UIElement ()=0
 析构函数,这里用纯虚函数使该类成为抽象类
 
void RegisterRoutedEvent (RoutedEventType eventType, const RoutedEvent &handler)
 注册路由事件处理函数,当事件已注册时会覆盖已注册的函数
 
template<typename T >
void RegisterRoutedEvent (RoutedEventType eventType, T &obj, void(T::*handler)(UIElement &, RoutedEventArgs &))
 注册成员函数作为路由事件处理函数,当事件已注册时会覆盖已注册的函数
 
template<typename TEventArgs >
std::enable_if< std::is_base_of< RoutedEventArgs, TEventArgs >::value &&sw::_IsTypedRoutedEventArgs< TEventArgs >::value >::type RegisterRoutedEvent (std::function< void(UIElement &, TEventArgs &)> handler)
 根据事件参数类型注册路由事件
 
template<typename TEventArgs , typename THandleObj >
std::enable_if< std::is_base_of< RoutedEventArgs, TEventArgs >::value &&sw::_IsTypedRoutedEventArgs< TEventArgs >::value >::type RegisterRoutedEvent (THandleObj &obj, void(THandleObj::*handler)(UIElement &, TEventArgs &))
 根据事件参数类型注册成员函数作为路由事件
 
void UnregisterRoutedEvent (RoutedEventType eventType)
 取消对应类型路由事件的注册
 
bool IsRoutedEventRegistered (RoutedEventType eventType)
 判断路由事件是否已被注册
 
bool AddChild (UIElement *element)
 添加子控件
 
bool AddChild (UIElement &element)
 添加子控件
 
bool AddChild (UIElement *element, uint64_t layoutTag)
 添加子控件并设置布局标记
 
bool AddChild (UIElement &element, uint64_t layoutTag)
 添加子控件并设置布局标记
 
bool RemoveChildAt (int index)
 移除指定索引处的子控件
 
bool RemoveChild (UIElement *element)
 移除子控件
 
bool RemoveChild (UIElement &element)
 移除子控件
 
void ClearChildren ()
 移除所有子控件
 
int IndexOf (UIElement *element)
 获取指定元素的索引
 
int IndexOf (UIElement &element)
 获取指定元素的索引
 
UIElementoperator[] (int index) const
 通过索引获取子控件
 
void ShowContextMenu (const Point &point)
 弹出当前元素的上下文菜单
 
void MoveToTop ()
 移动到界面顶部
 
void MoveToBottom ()
 移动到界面底部
 
bool IsRootElement ()
 判断当前元素是否为根节点
 
UIElementGetRootElement ()
 获取当前元素所在界面树的根节点
 
UIElementGetNextElement ()
 获取当前元素在界面树上的下一个节点,若已是最后一个节点则返回根节点
 
UIElementGetNextTabStopElement ()
 获取下一个TabStop属性为true的元素
 
Color GetRealBackColor ()
 获取当前要显示的背景颜色:当Transparent为true时获取到祖先节点中首个Transparent为false的背景颜色,否则返回当前元素的背景颜色
 
Color GetRealTextColor ()
 获取当前要显示的文本颜色:当InheritTextColor为true时获取到祖先节点中首个InheritTextColor为false的文本颜色,否则返回当前元素的文本颜色
 
void SetCursor (HCURSOR hCursor)
 设置鼠标样式
 
void SetCursor (StandardCursor cursor)
 设置鼠标样式
 
void ResetCursor ()
 将鼠标样式设置为默认样式
 
void SetAlignment (sw::HorizontalAlignment horz, sw::VerticalAlignment vert)
 设置对齐方式
 
void Resize (const Size &size)
 调整当前元素的尺寸,也可以用该函数更改默认Measure函数在当前横向或纵向对齐方式为拉伸时的DesireSize
 
virtual uint64_t GetTag () override
 获取Tag
 
virtual void SetTag (uint64_t tag) override
 设置Tag
 
virtual uint64_t GetLayoutTag () override
 获取布局标记
 
virtual int GetChildLayoutCount () override
 获取参与布局的子控件数量
 
virtual ILayoutGetChildLayoutAt (int index) override
 获取对应索引处的子控件,使用此函数前必须先调用GetChildLayoutCount
 
virtual Size GetDesireSize () override
 获取控件所需尺寸
 
virtual void SetDesireSize (const Size &size) override
 设置当前控件所需的尺寸
 
virtual void Measure (const Size &availableSize) override
 测量控件所需尺寸
 
virtual void Arrange (const sw::Rect &finalPosition) override
 安排控件位置
 
- Public 成员函数 继承自 sw::WndBase
virtual ~WndBase ()=0
 析构函数,这里用纯虚函数使该类成为抽象类
 
bool operator== (const WndBase &other) const
 判断两个WndBase是否为同一实例
 
bool operator!= (const WndBase &other) const
 判断两个WndBase是否为不同实例
 
void Show (int nCmdShow)
 该函数调用ShowWindow
 
void Close ()
 发送关闭消息
 
void Update ()
 该函数调用UpdateWindow
 
void UpdateFont ()
 更新字体
 
HFONT GetFontHandle ()
 获取字体句柄
 
void Redraw (bool erase=false, bool updateWindow=false)
 重画
 
bool IsControl ()
 判断当前对象是否是控件
 
bool IsVisible ()
 判断当前对象在界面中是否可视,与Visible属性不同的是该函数返回值会受父窗口的影响
 
DWORD GetStyle ()
 获取窗口样式
 
void SetStyle (DWORD style)
 设置窗口样式
 
bool GetStyle (DWORD mask)
 判断窗口是否设有指定样式
 
void SetStyle (DWORD mask, bool value)
 打开或关闭指定的样式
 
DWORD GetExtendedStyle ()
 获取扩展窗口样式
 
void SetExtendedStyle (DWORD style)
 设置扩展窗口样式
 
bool GetExtendedStyle (DWORD mask)
 判断窗口是否设有指定扩展样式
 
void SetExtendedStyle (DWORD mask, bool value)
 打开或关闭指定的扩展样式
 
Point PointToScreen (const Point &point)
 获取用户区点在屏幕上点的位置
 
Point PointFromScreen (const Point &screenPoint)
 获取屏幕上点在当前用户区点的位置
 
LRESULT SendMessageA (UINT uMsg, WPARAM wParam, LPARAM lParam)
 发送消息(ASCII)
 
LRESULT SendMessageW (UINT uMsg, WPARAM wParam, LPARAM lParam)
 发送消息(UNICODE)
 
HitTestResult NcHitTest (const Point &testPoint)
 测试指定点在窗口的哪一部分
 
- Public 成员函数 继承自 sw::ILayout
virtual ~ILayout ()=default
 默认虚析构函数
 
- Public 成员函数 继承自 sw::ITag
virtual ~ITag ()=default
 默认虚析构函数
 

Public 属性

const Property< ThicknessMargin
 边距
 
const Property< HorizontalAlignment > HorizontalAlignment
 水平对齐方式
 
const Property< VerticalAlignment > VerticalAlignment
 垂直对齐方式
 
const ReadOnlyProperty< int > ChildCount
 子控件数量
 
const Property< bool > CollapseWhenHide
 是否在不可见时不参与布局
 
const ReadOnlyPtrProperty< UIElement * > Parent
 指向父元素的指针,当前元素为顶级窗口时该值为nullptr
 
const Property< uint64_t > Tag
 储存用户自定义信息的标记
 
const Property< uint64_t > LayoutTag
 布局标记,对于不同的布局有不同含义
 
const PtrProperty< sw::ContextMenu * > ContextMenu
 右键按下时弹出的菜单
 
const Property< bool > Float
 元素是否悬浮,若元素悬浮则该元素不会随滚动条滚动而改变位置
 
const Property< bool > TabStop
 表示用户是否可以通过按下Tab键将焦点移动到当前元素
 
const Property< ColorBackColor
 背景颜色,修改该属性会同时将Transparent属性设为false,对于部分控件该属性可能不生效
 
const Property< ColorTextColor
 文本颜色,修改该属性会同时将InheritTextColor属性设为false,对于部分控件该属性可能不生效
 
const Property< bool > Transparent
 是否使用透明背景(此属性并非真正意义上的透明,将该属性设为true可继承父元素的背景颜色)
 
const Property< bool > InheritTextColor
 是否继承父元素的文本颜色
 
- Public 属性 继承自 sw::WndBase
const ReadOnlyProperty< HWND > Handle
 窗口句柄
 
const Property< sw::FontFont
 字体
 
const Property< std::wstring > FontName
 字体名称
 
const Property< double > FontSize
 字体大小
 
const Property< sw::FontWeight > FontWeight
 字体粗细
 
const Property< sw::RectRect
 位置和尺寸
 
const Property< double > Left
 左边
 
const Property< double > Top
 顶边
 
const Property< double > Width
 宽度
 
const Property< double > Height
 高度
 
const ReadOnlyProperty< sw::RectClientRect
 用户区尺寸
 
const ReadOnlyProperty< double > ClientWidth
 用户区宽度
 
const ReadOnlyProperty< double > ClientHeight
 用户区高度
 
const Property< bool > Enabled
 窗口或控件是否可用
 
const Property< bool > Visible
 窗口或控件是否可见
 
const Property< std::wstring > Text
 窗口标题或控件文本
 
const Property< bool > Focused
 窗口是否拥有焦点
 
const ReadOnlyPtrProperty< WndBase * > Parent
 父窗口
 
const ReadOnlyProperty< bool > IsDestroyed
 是否已销毁,当该值为true时不应该继续使用当前对象
 
const Property< bool > AcceptFiles
 是否接受拖放文件
 

Protected 成员函数

 UIElement ()
 初始化UIElement
 
void RaiseRoutedEvent (RoutedEventType eventType)
 触发路由事件
 
void RaiseRoutedEvent (RoutedEventArgs &eventArgs)
 触发路由事件
 
void NotifyLayoutUpdated ()
 通知顶级窗口布局改变
 
double & GetArrangeOffsetX ()
 获取Arrange时子元素的水平偏移量
 
double & GetArrangeOffsetY ()
 获取Arrange时子元素的垂直偏移量
 
double GetChildRightmost (bool update)
 获取所有子元素在当前元素中最右边的位置(只考虑参与布局的子窗口且忽略悬浮的元素)
 
double GetChildBottommost (bool update)
 获取所有子元素在当前元素中最底边的位置(只考虑参与布局的子窗口且忽略悬浮的元素)
 
void UpdateChildrenZOrder ()
 更新子元素的Z轴位置
 
void UpdateSiblingsZOrder ()
 更新兄弟元素的Z轴位置
 
void SetNextTabStopFocus ()
 设置下一个TabStop属性为true的元素为焦点元素
 
virtual void SetBackColor (Color color, bool redraw)
 设置背景颜色
 
virtual void SetTextColor (Color color, bool redraw)
 设置文本颜色
 
virtual void OnAddedChild (UIElement &element)
 添加子元素后调用该函数
 
virtual void OnRemovedChild (UIElement &element)
 移除子元素后调用该函数
 
virtual void OnTabStop ()
 通过tab键将焦点移动到当前元素时调用该函数
 
virtual void OnDrawFocusRect ()
 绘制虚线框时调用该函数
 
virtual bool SetParent (WndBase *parent) override
 设置父窗口
 
virtual void ParentChanged (WndBase *newParent) override
 父窗口改变时调用此函数
 
virtual void OnEndPaint () override
 在OnPaint函数完成之后调用该函数
 
virtual bool OnClose () override
 接收到WM_CLOSE时调用该函数
 
virtual bool OnMove (Point newClientPosition) override
 接收到WM_MOVE时调用该函数
 
virtual bool OnSize (Size newClientSize) override
 接收到WM_SIZE时调用该函数
 
virtual void OnTextChanged () override
 Text属性更改时调用此函数
 
virtual void VisibleChanged (bool newVisible) override
 Visible属性改变时调用此函数
 
virtual bool OnSetFocus (HWND hPrevFocus) override
 接收到WM_SETFOCUS时调用该函数
 
virtual bool OnKillFocus (HWND hNextFocus) override
 接收到WM_KILLFOCUS时调用该函数
 
virtual bool OnChar (wchar_t ch, KeyFlags flags) override
 接收到WM_CHAR时调用该函数
 
virtual bool OnKeyDown (VirtualKey key, KeyFlags flags) override
 接收到WM_KEYDOWN时调用该函数
 
virtual bool OnKeyUp (VirtualKey key, KeyFlags flags) override
 接收到WM_KEYUP时调用该函数
 
virtual bool OnMouseMove (Point mousePosition, MouseKey keyState) override
 接收到WM_MOUSEMOVE时调用该函数
 
virtual bool OnMouseLeave () override
 接收到WM_MOUSELEAVE时调用该函数
 
virtual bool OnMouseWheel (int wheelDelta, Point mousePosition, MouseKey keyState) override
 接收到WM_MOUSEWHEEL时调用该函数
 
virtual bool OnMouseLeftButtonDown (Point mousePosition, MouseKey keyState) override
 接收到WM_LBUTTONDOWN时调用该函数
 
virtual bool OnMouseLeftButtonUp (Point mousePosition, MouseKey keyState) override
 接收到WM_LBUTTONUP时调用该函数
 
virtual bool OnMouseRightButtonDown (Point mousePosition, MouseKey keyState) override
 接收到WM_RBUTTONDOWN时调用该函数
 
virtual bool OnMouseRightButtonUp (Point mousePosition, MouseKey keyState) override
 接收到WM_RBUTTONUP时调用该函数
 
virtual bool OnMouseMiddleButtonDown (Point mousePosition, MouseKey keyState) override
 接收到WM_MBUTTONDOWN时调用该函数
 
virtual bool OnMouseMiddleButtonUp (Point mousePosition, MouseKey keyState) override
 接收到WM_MBUTTONUP时调用该函数
 
virtual bool OnContextMenu (bool isKeyboardMsg, Point mousePosition) override
 接收到WM_CONTEXTMENU后调用目标控件的该函数
 
virtual void OnMenuCommand (int id) override
 当WM_COMMAND接收到菜单命令时调用该函数
 
virtual bool OnColor (HDC hdc, HBRUSH &hRetBrush) override
 父窗口接收到WM_CTLCOLORxxx时调用对应控件的该函数
 
virtual bool OnSetCursor (HWND hwnd, HitTestResult hitTest, int message, bool &result) override
 接收到WM_SETCURSOR消息时调用该函数
 
virtual bool OnDropFiles (HDROP hDrop) override
 接收到WM_DROPFILES时调用该函数
 
- Protected 成员函数 继承自 sw::WndBase
 WndBase ()
 初始化WndBase
 
 WndBase (const WndBase &)=delete
 
 WndBase (WndBase &&)=delete
 
WndBaseoperator= (const WndBase &)=delete
 
WndBaseoperator= (WndBase &&)=delete
 
void InitWindow (LPCWSTR lpWindowName, DWORD dwStyle, DWORD dwExStyle)
 初始化为窗口,该函数会调用CreateWindowExW
 
void InitControl (LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, DWORD dwExStyle)
 初始化为控件,该函数会调用CreateWindowExW
 
LRESULT DefaultWndProc (const ProcMsg &refMsg)
 调用默认的WndProc,对于窗口则调用DefWindowProcW,控件则调用_controlOldWndProc
 
virtual LRESULT WndProc (const ProcMsg &refMsg)
 对WndProc的封装
 
void UpdateText ()
 更新_text字段
 
virtual std::wstring & GetText ()
 获取窗口文本
 
virtual void SetText (const std::wstring &value)
 调用SetWindowTextW设置窗口文本
 
virtual bool OnCreate ()
 接收到WM_CREATE时调用该函数
 
virtual bool OnDestroy ()
 接收到WM_DESTROY时调用该函数
 
virtual bool OnPaint ()
 接收到WM_PAINT时调用该函数
 
virtual bool OnMouseLeftButtonDoubleClick (Point mousePosition, MouseKey keyState)
 接收到WM_LBUTTONDBLCLK时调用该函数
 
virtual bool OnMouseRightButtonDoubleClick (Point mousePosition, MouseKey keyState)
 接收到WM_RBUTTONDBLCLK时调用该函数
 
virtual bool OnMouseMiddleButtonDoubleClick (Point mousePosition, MouseKey keyState)
 接收到WM_MBUTTONDBLCLK时调用该函数
 
virtual bool OnDeadChar (wchar_t ch, KeyFlags flags)
 接收到WM_DEADCHAR时调用该函数
 
virtual bool OnSysChar (wchar_t ch, KeyFlags flags)
 接收到WM_SYSCHAR时调用该函数
 
virtual bool OnSysDeadChar (wchar_t ch, KeyFlags flags)
 接收到WM_SYSDEADCHAR时调用该函数
 
virtual bool OnSysKeyDown (VirtualKey key, KeyFlags flags)
 接收到WM_SYSKEYDOWN时调用该函数
 
virtual bool OnSysKeyUp (VirtualKey key, KeyFlags flags)
 接收到WM_SYSKEYUP时调用该函数
 
virtual void OnCommand (int code)
 当父窗口接收到控件的WM_COMMAND时调用该函数
 
virtual void OnControlCommand (WndBase *pControl, int code, int id)
 当WM_COMMAND接收到控件命令时调用该函数
 
virtual void OnAcceleratorCommand (int id)
 当WM_COMMAND接收到快捷键命令时调用该函数
 
virtual void HandleInitialized (HWND hwnd)
 窗口句柄初始化完成
 
virtual void FontChanged (HFONT hfont)
 字体改变时调用该函数
 
virtual bool OnNotify (NMHDR *pNMHDR, LRESULT &result)
 接收到WM_NOTIFY后调用该函数
 
virtual bool OnNotified (NMHDR *pNMHDR, LRESULT &result)
 父窗口接收到WM_NOTIFY后且父窗口OnNotify函数返回false时调用发出通知控件的该函数
 
virtual bool OnVerticalScroll (int event, int pos)
 接收到WM_VSCROLL时调用目标控件的该函数
 
virtual bool OnHorizontalScroll (int event, int pos)
 接收到WM_HSCROLL时调用目标控件的该函数
 
virtual bool OnEnabledChanged (bool newValue)
 接收到WM_ENABLE时调用该函数
 
virtual bool OnCtlColor (WndBase *pControl, HDC hdc, HBRUSH &hRetBrush)
 接收到WM_CTLCOLORxxx时调用该函数
 
virtual void OnNcHitTest (const Point &testPoint, HitTestResult &result)
 接收到WM_NCHITTEST后调用该函数
 
virtual bool OnEraseBackground (int &result)
 接收到WM_ERASEBKGND时调用该函数
 
virtual bool OnDrawItem (int id, DRAWITEMSTRUCT *pDrawItem)
 接收到WM_DRAWITEM时调用该函数
 

额外继承的成员函数

- 静态 Public 成员函数 继承自 sw::WndBase
static WndBaseGetWndBase (HWND hwnd)
 通过窗口句柄获取WndBase
 

详细描述

表示界面中的元素

成员函数说明

◆ AddChild() [1/4]

bool sw::UIElement::AddChild ( UIElement & element)

添加子控件

返回
添加是否成功

◆ AddChild() [2/4]

bool sw::UIElement::AddChild ( UIElement & element,
uint64_t layoutTag )

添加子控件并设置布局标记

返回
添加是否成功

◆ AddChild() [3/4]

bool sw::UIElement::AddChild ( UIElement * element)

添加子控件

返回
添加是否成功

◆ AddChild() [4/4]

bool sw::UIElement::AddChild ( UIElement * element,
uint64_t layoutTag )

添加子控件并设置布局标记

返回
添加是否成功

◆ Arrange()

virtual void sw::UIElement::Arrange ( const sw::Rect & finalPosition)
overridevirtual

安排控件位置

参数
finalSize最终控件所安排的位置

实现了 sw::ILayout.

sw::Layer, sw::PanelBase , 以及 sw::TabControl 重载.

◆ GetChildBottommost()

double sw::UIElement::GetChildBottommost ( bool update)
protected

获取所有子元素在当前元素中最底边的位置(只考虑参与布局的子窗口且忽略悬浮的元素)

参数
update是否更字段
返回
_childBottommost字段

◆ GetChildLayoutAt()

virtual ILayout & sw::UIElement::GetChildLayoutAt ( int index)
overridevirtual

获取对应索引处的子控件,使用此函数前必须先调用GetChildLayoutCount

实现了 sw::ILayout.

◆ GetChildLayoutCount()

virtual int sw::UIElement::GetChildLayoutCount ( )
overridevirtual

获取参与布局的子控件数量

实现了 sw::ILayout.

◆ GetChildRightmost()

double sw::UIElement::GetChildRightmost ( bool update)
protected

获取所有子元素在当前元素中最右边的位置(只考虑参与布局的子窗口且忽略悬浮的元素)

参数
update是否更字段
返回
_childRightmost字段

◆ GetDesireSize()

virtual Size sw::UIElement::GetDesireSize ( )
overridevirtual

获取控件所需尺寸

实现了 sw::ILayout.

◆ GetLayoutTag()

virtual uint64_t sw::UIElement::GetLayoutTag ( )
overridevirtual

获取布局标记

实现了 sw::ILayout.

◆ GetTag()

virtual uint64_t sw::UIElement::GetTag ( )
overridevirtual

获取Tag

实现了 sw::ITag.

◆ IndexOf() [1/2]

int sw::UIElement::IndexOf ( UIElement & element)

获取指定元素的索引

参数
element要查找的元素
返回
若找到指定元素则返回对应的索引,否则返回-1

◆ IndexOf() [2/2]

int sw::UIElement::IndexOf ( UIElement * element)

获取指定元素的索引

参数
element要查找的元素
返回
若找到指定元素则返回对应的索引,否则返回-1

◆ IsRoutedEventRegistered()

bool sw::UIElement::IsRoutedEventRegistered ( RoutedEventType eventType)

判断路由事件是否已被注册

参数
eventType路由事件类型

◆ Measure()

virtual void sw::UIElement::Measure ( const Size & availableSize)
overridevirtual

测量控件所需尺寸

参数
availableSize可用的尺寸

实现了 sw::ILayout.

sw::BmpBox, sw::Label, sw::Layer, sw::PanelBase , 以及 sw::SysLink 重载.

◆ OnAddedChild()

virtual void sw::UIElement::OnAddedChild ( UIElement & element)
protectedvirtual

添加子元素后调用该函数

参数
element添加的子元素

sw::TabControl 重载.

◆ OnChar()

virtual bool sw::UIElement::OnChar ( wchar_t ch,
KeyFlags flags )
overrideprotectedvirtual

接收到WM_CHAR时调用该函数

参数
ch按键的字符代码
flags附加信息
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

sw::TextBoxBase 重载.

◆ OnClose()

virtual bool sw::UIElement::OnClose ( )
overrideprotectedvirtual

接收到WM_CLOSE时调用该函数

返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

sw::Window 重载.

◆ OnColor()

virtual bool sw::UIElement::OnColor ( HDC hdc,
HBRUSH & hRetBrush )
overrideprotectedvirtual

父窗口接收到WM_CTLCOLORxxx时调用对应控件的该函数

参数
hdc控件的显示上下文句柄
hRetBrush要返回的画笔
返回
若返回true则将hRetBrush作为消息的返回值,否则使用DefaultWndProc的返回值

重载 sw::WndBase .

◆ OnContextMenu()

virtual bool sw::UIElement::OnContextMenu ( bool isKeyboardMsg,
Point mousePosition )
overrideprotectedvirtual

接收到WM_CONTEXTMENU后调用目标控件的该函数

参数
isKeyboardMsg消息是否由按下快捷键(Shift+F10、VK_APPS)产生
mousePosition鼠标在屏幕中的位置
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

sw::ListBox 重载.

◆ OnDrawFocusRect()

virtual void sw::UIElement::OnDrawFocusRect ( )
protectedvirtual

绘制虚线框时调用该函数

sw::Button, sw::MonthCalendar , 以及 sw::TextBoxBase 重载.

◆ OnDropFiles()

virtual bool sw::UIElement::OnDropFiles ( HDROP hDrop)
overrideprotectedvirtual

接收到WM_DROPFILES时调用该函数

参数
hDrop描述拖入文件的句柄
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnEndPaint()

virtual void sw::UIElement::OnEndPaint ( )
overrideprotectedvirtual

在OnPaint函数完成之后调用该函数

重载 sw::WndBase .

◆ OnKeyDown()

virtual bool sw::UIElement::OnKeyDown ( VirtualKey key,
KeyFlags flags )
overrideprotectedvirtual

接收到WM_KEYDOWN时调用该函数

参数
key虚拟按键
flags附加信息
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

sw::Button , 以及 sw::TextBoxBase 重载.

◆ OnKeyUp()

virtual bool sw::UIElement::OnKeyUp ( VirtualKey key,
KeyFlags flags )
overrideprotectedvirtual

接收到WM_KEYUP时调用该函数

参数
key虚拟按键
flags附加信息
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnKillFocus()

virtual bool sw::UIElement::OnKillFocus ( HWND hNextFocus)
overrideprotectedvirtual

接收到WM_KILLFOCUS时调用该函数

参数
hNextFocus接收到焦点的hwnd,可能为NULL
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

sw::Button 重载.

◆ OnMenuCommand()

virtual void sw::UIElement::OnMenuCommand ( int id)
overrideprotectedvirtual

当WM_COMMAND接收到菜单命令时调用该函数

参数
id菜单id

重载 sw::WndBase .

sw::Window 重载.

◆ OnMouseLeave()

virtual bool sw::UIElement::OnMouseLeave ( )
overrideprotectedvirtual

接收到WM_MOUSELEAVE时调用该函数

返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseLeftButtonDown()

virtual bool sw::UIElement::OnMouseLeftButtonDown ( Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_LBUTTONDOWN时调用该函数

参数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseLeftButtonUp()

virtual bool sw::UIElement::OnMouseLeftButtonUp ( Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_LBUTTONUP时调用该函数

参数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseMiddleButtonDown()

virtual bool sw::UIElement::OnMouseMiddleButtonDown ( Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_MBUTTONDOWN时调用该函数

参数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseMiddleButtonUp()

virtual bool sw::UIElement::OnMouseMiddleButtonUp ( Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_MBUTTONUP时调用该函数

参数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseMove()

virtual bool sw::UIElement::OnMouseMove ( Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_MOUSEMOVE时调用该函数

参数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseRightButtonDown()

virtual bool sw::UIElement::OnMouseRightButtonDown ( Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_RBUTTONDOWN时调用该函数

参数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseRightButtonUp()

virtual bool sw::UIElement::OnMouseRightButtonUp ( Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_RBUTTONUP时调用该函数

参数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMouseWheel()

virtual bool sw::UIElement::OnMouseWheel ( int wheelDelta,
Point mousePosition,
MouseKey keyState )
overrideprotectedvirtual

接收到WM_MOUSEWHEEL时调用该函数

参数
wheelDelta滚轮滚动的距离,为120的倍数
mousePosition鼠标在用户区中的位置
keyState指示某些按键是否按下
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnMove()

virtual bool sw::UIElement::OnMove ( Point newClientPosition)
overrideprotectedvirtual

接收到WM_MOVE时调用该函数

参数
newClientPosition移动后用户区左上角的位置
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

◆ OnRemovedChild()

virtual void sw::UIElement::OnRemovedChild ( UIElement & element)
protectedvirtual

移除子元素后调用该函数

参数
element移除的子元素

sw::TabControl 重载.

◆ OnSetCursor()

virtual bool sw::UIElement::OnSetCursor ( HWND hwnd,
HitTestResult hitTest,
int message,
bool & result )
overrideprotectedvirtual

接收到WM_SETCURSOR消息时调用该函数

参数
hwnd鼠标所在窗口的句柄
hitTesthit-test的结果,详见WM_NCHITTEST消息的返回值
message触发该事件的鼠标消息,如WM_MOUSEMOVE
result消息的返回值,默认为false
返回
若返回true则将result作为消息的返回值,否则使用DefaultWndProc的返回值

重载 sw::WndBase .

◆ OnSetFocus()

virtual bool sw::UIElement::OnSetFocus ( HWND hPrevFocus)
overrideprotectedvirtual

接收到WM_SETFOCUS时调用该函数

参数
hPrevFocus丢失焦点的hwnd,可能为NULL
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

sw::Button , 以及 sw::IPAddressControl 重载.

◆ OnSize()

virtual bool sw::UIElement::OnSize ( Size newClientSize)
overrideprotectedvirtual

接收到WM_SIZE时调用该函数

参数
newClientSize改变后的用户区尺寸
返回
若已处理该消息则返回true,否则返回false以调用DefaultWndProc

重载 sw::WndBase .

sw::BmpBox, sw::HwndHost, sw::Label, sw::Panel , 以及 sw::Splitter 重载.

◆ OnTextChanged()

virtual void sw::UIElement::OnTextChanged ( )
overrideprotectedvirtual

Text属性更改时调用此函数

重载 sw::WndBase .

sw::Label , 以及 sw::SysLink 重载.

◆ ParentChanged()

virtual void sw::UIElement::ParentChanged ( WndBase * newParent)
overrideprotectedvirtual

父窗口改变时调用此函数

参数
newParent新的父窗口

重载 sw::WndBase .

◆ RaiseRoutedEvent() [1/2]

void sw::UIElement::RaiseRoutedEvent ( RoutedEventArgs & eventArgs)
protected

触发路由事件

参数
eventArgs要触发事件的事件参数

◆ RaiseRoutedEvent() [2/2]

void sw::UIElement::RaiseRoutedEvent ( RoutedEventType eventType)
protected

触发路由事件

参数
eventType事件类型

◆ RegisterRoutedEvent() [1/4]

void sw::UIElement::RegisterRoutedEvent ( RoutedEventType eventType,
const RoutedEvent & handler )

注册路由事件处理函数,当事件已注册时会覆盖已注册的函数

参数
eventType路由事件类型
handler处理函数,当值为nullptr时可取消注册

◆ RegisterRoutedEvent() [2/4]

template<typename T >
void sw::UIElement::RegisterRoutedEvent ( RoutedEventType eventType,
T & obj,
void(T::* handler )(UIElement &, RoutedEventArgs &) )
inline

注册成员函数作为路由事件处理函数,当事件已注册时会覆盖已注册的函数

模板参数
T成员函数所在的类
参数
eventType路由事件类型
obj注册的成员函数所在的对象
handler处理函数,当值为nullptr时可取消注册

◆ RegisterRoutedEvent() [3/4]

template<typename TEventArgs >
std::enable_if< std::is_base_of< RoutedEventArgs, TEventArgs >::value &&sw::_IsTypedRoutedEventArgs< TEventArgs >::value >::type sw::UIElement::RegisterRoutedEvent ( std::function< void(UIElement &, TEventArgs &)> handler)
inline

根据事件参数类型注册路由事件

模板参数
TEventArgs路由事件的参数类型,必须继承自RoutedEventOfType<...>
参数
handler事件的处理函数,当值为nullptr时可取消注册

◆ RegisterRoutedEvent() [4/4]

template<typename TEventArgs , typename THandleObj >
std::enable_if< std::is_base_of< RoutedEventArgs, TEventArgs >::value &&sw::_IsTypedRoutedEventArgs< TEventArgs >::value >::type sw::UIElement::RegisterRoutedEvent ( THandleObj & obj,
void(THandleObj::* handler )(UIElement &, TEventArgs &) )
inline

根据事件参数类型注册成员函数作为路由事件

模板参数
TEventArgs路由事件的参数类型,必须继承自RoutedEventOfType<...>
THandleObj成员函数所在的类
参数
obj注册的成员函数所在的对象
handler事件的处理函数,当值为nullptr时可取消注册

◆ RemoveChild() [1/2]

bool sw::UIElement::RemoveChild ( UIElement & element)

移除子控件

返回
移除是否成功

◆ RemoveChild() [2/2]

bool sw::UIElement::RemoveChild ( UIElement * element)

移除子控件

返回
移除是否成功

◆ RemoveChildAt()

bool sw::UIElement::RemoveChildAt ( int index)

移除指定索引处的子控件

参数
index要移除的索引
返回
移除是否成功

◆ SetAlignment()

void sw::UIElement::SetAlignment ( sw::HorizontalAlignment horz,
sw::VerticalAlignment vert )

设置对齐方式

参数
horz水平对齐方式
vert垂直对齐方式

◆ SetBackColor()

virtual void sw::UIElement::SetBackColor ( Color color,
bool redraw )
protectedvirtual

设置背景颜色

参数
color要设置的颜色
redraw是否重绘

sw::ListView, sw::MonthCalendar , 以及 sw::StatusBar 重载.

◆ SetCursor() [1/2]

void sw::UIElement::SetCursor ( HCURSOR hCursor)

设置鼠标样式

参数
hCursor鼠标句柄

◆ SetCursor() [2/2]

void sw::UIElement::SetCursor ( StandardCursor cursor)

设置鼠标样式

参数
cursor鼠标样式

◆ SetDesireSize()

virtual void sw::UIElement::SetDesireSize ( const Size & size)
overridevirtual

设置当前控件所需的尺寸

实现了 sw::ILayout.

◆ SetParent()

virtual bool sw::UIElement::SetParent ( WndBase * parent)
overrideprotectedvirtual

设置父窗口

返回
设置是否成功

重载 sw::WndBase .

◆ SetTag()

virtual void sw::UIElement::SetTag ( uint64_t tag)
overridevirtual

设置Tag

实现了 sw::ITag.

◆ SetTextColor()

virtual void sw::UIElement::SetTextColor ( Color color,
bool redraw )
protectedvirtual

设置文本颜色

参数
color要设置的颜色
redraw是否重绘

sw::ListView , 以及 sw::MonthCalendar 重载.

◆ ShowContextMenu()

void sw::UIElement::ShowContextMenu ( const Point & point)

弹出当前元素的上下文菜单

参数
point弹出菜单左上角在屏幕中的位置

◆ UnregisterRoutedEvent()

void sw::UIElement::UnregisterRoutedEvent ( RoutedEventType eventType)

取消对应类型路由事件的注册

参数
eventType路由事件类型

◆ VisibleChanged()

virtual void sw::UIElement::VisibleChanged ( bool newVisible)
overrideprotectedvirtual

Visible属性改变时调用此函数

重载 sw::WndBase .


该类的文档由以下文件生成: