wxPropertyGrid控件中使用wxColour类型

12 views
Skip to first unread message

xunj...@gmail.com

unread,
May 10, 2006, 2:47:41 AM5/10/06
to wxLife
假设有wxPropertyGrid类型的控件ppg,向ppg中添加wxColour类型的属性的过程如下:
ppg->Append( wxColourProperty( wxT("ColorProperty"), wxPG_LABEL, *
wxBLACK ) );

修改该属性的代码如下:
ppg->SetPropertyValue( wxT("ColorProperty"), &color );

在属性编辑器控件的事件中获取wxColour类型的值的过程如下:
const wxObject * pObj = event.GetPropertyValueAsWxObjectPtr();
wxColour value = * wxDynamicCast( pObj, wxColour );

xunj...@gmail.com

unread,
May 11, 2006, 10:16:11 PM5/11/06
to wxLife
还可以使用以下方法:
wxVariant v_txcol = pg->GetPropertyValue(wxT("ColourProperty"));
const wxColour& value = wxGetVariantCast(v_txcol,wxColour);
Reply all
Reply to author
Forward
0 new messages