本文整理汇总了C++中dom::element::set_capture方法的典型用法代码示例。如果您正苦于以下问题:C++ element::set_capture方法的具体用法?C++ element::set_capture怎么用?C++ element::set_capture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dom::element
的用法示例。
在下文中一共展示了element::set_capture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_horizontal
bool do_horizontal(UINT event_type, POINT pt,
dom::element &splitter_el, dom::element &first, dom::element &second,
dom::element &parent_el)
{
// which element width we will change?
RECT rc_parent = parent_el.get_location();
RECT rc = first.get_location();
// if width of first element is less than half of parent we
// will change its width.
bool change_first =
(rc.right - rc.left) < (rc_parent.right - rc_parent.left)/2;
if(!change_first)
rc = second.get_location();
if(event_type == MOUSE_DOWN)
{
pressed_offset = pt.x;
splitter_el.set_capture();
return false; // don't need updates
}
// mouse move handling
if(pt.x == pressed_offset)
return false; // don't need updates
int width = rc.right - rc.left;
wchar_t buf[32];
if(change_first)
{
width += (pt.x - pressed_offset);
if(width >= 0)
{
first.delay_measure();
second.delay_measure();
swprintf(buf,L"%dpx", width);
first.set_style_attribute("width",buf);
second.set_style_attribute("width",L"100%%");
}
}
else
{
width -= (pt.x - pressed_offset);
if(width >= 0)
{
first.delay_measure();
second.delay_measure();
swprintf(buf,L"%dpx", width);
first.set_style_attribute("width",L"100%%");
second.set_style_attribute("width",buf);
}
}
return true; // need update
}
示例2: do_vertical
bool do_vertical(UINT event_type, POINT pt,
dom::element &splitter_el, dom::element &first, dom::element &second,
dom::element &parent_el)
{
RECT rc_parent = parent_el.get_location();
RECT rc = first.get_location();
// if width of first element is less than half of parent we
// will change its width.
bool change_first =
(rc.bottom - rc.top) < (rc_parent.bottom - rc_parent.top)/2;
if(!change_first)
rc = second.get_location();
if(event_type == MOUSE_DOWN)
{
pressed_offset = pt.y;
splitter_el.set_capture();
return false; // don't need updates
}
// mouse move handling
if(pt.y == pressed_offset)
return false; // don't need updates
int height = rc.bottom - rc.top;
wchar_t buf[32];
if(change_first)
{
height += (pt.y - pressed_offset);
if(height >= 0)
{
first.delay_measure();
second.delay_measure();
swprintf(buf,L"%dpx", height);
first.set_style_attribute("height",buf);
second.set_style_attribute("height",L"100%%");
}
}
else
{
height -= (pt.y - pressed_offset);
if(height >= 0)
{
first.delay_measure();
second.delay_measure();
swprintf(buf,L"%dpx", height);
first.set_style_attribute("height",L"100%%");
second.set_style_attribute("height",buf);
}
}
return true;
}