Hi Andrew,
using Sciter for more and more things in UI I found another issue.
Problem
If I create Sciter window with WS_EX_LAYERED style then SetWindowPos does not update window's size (position and visiblity are correctly handled):
void ListWndT::ShowPopup( const POINT& Where )
{
CRect WindowRect = CRect(0, 0, 320, 240);
if (!::IsWindow(m_hWnd))
Create(WS_POPUP, WS_EX_LAYERED, WindowRect, AfxGetMainWnd(), 0);
UINT Width = ::SciterGetMinWidth(m_hWnd);
UINT Height = ::SciterGetMinHeight(m_hWnd, Width);
WindowRect = CRect(0, 0, Width, Height);
WindowRect.OffsetRect(Where.x - WindowRect.Width(), Where.y);
SetWindowPos(&CWnd::wndTop, WindowRect.left, WindowRect.top, WindowRect.Width(), WindowRect.Height(), SWP_SHOWWINDOW);
}
If I create window without WS_EX_LAYERED everything works as expected.
Workaround
As setting window size using "view.move(...)" works fine I was able to implement following (quite suboptimal) workaround into my base class:
void WndT::OnWindowPosChanging( WINDOWPOS* lpwndpos )
{
// there is neither SWP_NOMOVE nor SWP_NOSIZE flag - position and/or size of window is changing
if (!IS_BIT_SET(lpwndpos->flags, SWP_NOMOVE) || !IS_BIT_SET(lpwndpos->flags, SWP_NOSIZE))
{
// layered window not currently handling WM_WINDOWPOSCHANGING - update size using script call
if (!m_WindowPosChanging && IS_BIT_SET(GetExStyle(), WS_EX_LAYERED))
{
m_WindowPosChanging = true;
POINT Position = { lpwndpos->x, lpwndpos->y };
SIZE Size = { lpwndpos->cx, lpwndpos->cy };
// we have SWP_NOMOVE or SWP_NOSIZE flag - we need current window rect
if (IS_BIT_SET(lpwndpos->flags, SWP_NOMOVE) || IS_BIT_SET(lpwndpos->flags, SWP_NOSIZE))
{
CRect WindowRect;
GetWindowRect(&WindowRect);
if (IS_BIT_SET(lpwndpos->flags, SWP_NOMOVE))
Position = WindowRect.TopLeft();
if (IS_BIT_SET(lpwndpos->flags, SWP_NOSIZE))
Size = WindowRect.Size();
}
std::wstring Script = boost::str( boost::wformat(L"view.move(%d,%d,%d,%d)") % Position.x % Position.y % Size.cx % Size.cy );
sciter::value RetVal;
::SciterEval(m_hWnd, Script.c_str(), Script.size(), &RetVal);
m_WindowPosChanging = false;
}
}
__super::OnWindowPosChanging(lpwndpos);
}
Expected behavior
It would be fine if Sciter can handle SetWindowPos correctly even for layered windows.
Thank you,
Martin