查看单个帖子
旧 2009-05-05, 08:54 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】dynamic properties - how

dynamic properties - how?
dynamic properties - how?
i am using the wingdi rendering object in my application. i would like to add two new properties to it (similar to windowhdc and windowhwnd that are already implemented). i have added code in exgswin32device.h and exgswin32device.cpp to create the properties. even though it looks to me like i have done exactly the same thing that exgswin32device already had to implement windowhdc and windowhwnd, the device appears to not support the new properties.
i want to add a way to set an override color on the device and to have the device draw only in that color. one property will specify the color while the other will specify whether or not to use the override color.
i added this to exwin32device.h in a public section of the exgswin32device class:
colorref gethighlightcolor() const;
void sethighlightcolor(colorref crhighlightcolor);
bool getusehighlightcolor() const;
void setusehighlightcolor(bool busehighlightcolor);
i added my properties to the property map by modifying exgswin32device.cpp as follows:
odrx_declare_property(windowhdc)
odrx_declare_property(windowhwnd)
odrx_declare_property(dpi)
odrx_declare_property(highlightcolor)
odrx_declare_property(usehighlightcolor)
odrx_begin_dynamic_property_map(exgswin32device);
odrx_inherit_properties(odcommondeviceprops)
odrx_generate_property(windowhdc)
odrx_generate_property(windowhwnd)
odrx_generate_property(dpi)
odrx_generate_property(highlightcolor)
odrx_generate_property(usehighlightcolor)fff">odrx_end_dynamic_property_map(exgswin32device);
odrx_define_property_methods(windowhdc, exgswin32device, gethdc, sethdc, long);
odrx_define_property_methods(windowhwnd, exgswin32device, gethwnd, sethwnd, long);
odrx_define_property_methods(dpi, exgswin32device, dpi, setdpi, long);
odrx_define_property_methods(highlightcolor, exgswin32device, gethighlightcolor, sethighlightcolor, colorref);
odrx_define_property_methods(usehighlightcolor, exgswin32device, getusehighlightcolor, setusehighlightcolor, bool);
i added this code to exgswin32device.cpp to actually implement the property functions:
colorref exgswin32device::gethighlightcolor() const
{
return m_crhighlightcolor;
}
void exgswin32device::sethighlightcolor
(
colorref crhighlightcolor
)
{
m_crhighlightcolor = crhighlightcolor;
}
bool exgswin32device::getusehighlightcolor() const
{
return m_busehighlightcolor;
}
void exgswin32device::setusehighlightcolor
(
bool busehighlightcolor
)
{
m_busehighlightcolor = busehighlightcolor;
}
however, when i check the device to see if it supports the new properties, it returns false:
odrxdictionaryptr pprops = m_pdevice->properties();
pprops->putat("windowhdc", odrxvariantvalue((long)hdc));
if (pprops->has("highlightcolor"))
{
pprops->putat("highlightcolor",odrxvariantvalue((long)crh ighlightcolor));
}
if (pprops->has("usehighlightcolor"))
{
pprops->putat("usehighlightcolor",odrxvariantvalue(true)) ;
}
both of these calls to "has" return false. it seems so simple, that i feel that i must be missing something obvious.
can anyone help?
thanks.

never mind. i was building wingdi in release, but i was building my application in debug.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)