크기 조정의 기본 방법이 없거나 최소한 내 지식이 없으므로 맨 위 창에 C++ 프로그램을 작성하고 있습니다. 그래서 하나의 세부 사항을 제외하고는 잘 작동하는 크기 조정을 구현했습니다. 오른쪽 또는 아래쪽의 윈도우 크기를 조정하면 완벽하게 작동하지만 왼쪽 또는 위의 크기를 조정할 때 크기를 조정하는 방식에 따라 오른쪽 또는 아래쪽 부분이 흔들립니다. 나는 이미 부분적으로 "고정"했으므로 크기를 줄이는 것이 좋을 것 같지만 창을 대형화 할 때 여전히 흔들립니다.C++ win32 팝업 창 크기 조정시 "흔들림"
난 이미 크기 조절시 비활성화하고 다시 그리기 수 있도록 노력하지만 completly 나사 일까지 있음 : P
여기 내가 현재
GetCursorPos(&m_MousePos);
int x(m_rWindowStart.left),
y(m_rWindowStart.top),
w(m_pWindow->GetWidth()),
h(m_pWindow->GetHeight());
//sizing
switch (m_SizingDir)
{
case SIZING_DIR_LEFT:
//x += m_MousePos.x - m_MousePosOld.x;
w = m_rWindowStart.right - m_MousePos.x - m_MousePosOld.x + x;
w /= m_SnapSizing;
w *= m_SnapSizing;
x = m_rWindowStart.right - w;
break;
case SIZING_DIR_TOP:
y += m_MousePos.y - m_MousePosOld.y;
h = m_rWindowStart.bottom - y;
break;
case SIZING_DIR_RIGHT:
w = m_rWindowStart.right - m_rWindowStart.left + m_MousePos.x - m_MousePosOld.x;
break;
case SIZING_DIR_BOTTOM:
h = m_rWindowStart.bottom - m_rWindowStart.top + m_MousePos.y - m_MousePosOld.y;
break;
case SIZING_DIR_LEFTTOP:
x += m_MousePos.x - m_MousePosOld.x;
w = m_rWindowStart.right - x;
y += m_MousePos.y - m_MousePosOld.y;
h = m_rWindowStart.bottom - y;
break;
case SIZING_DIR_LEFTBOTTOM:
x += m_MousePos.x - m_MousePosOld.x;
w = m_rWindowStart.right - x;
h = m_rWindowStart.bottom - m_rWindowStart.top + m_MousePos.y - m_MousePosOld.y;
break;
case SIZING_DIR_RIGHTTOP:
w = m_rWindowStart.right - m_rWindowStart.left + m_MousePos.x - m_MousePosOld.x;
y += m_MousePos.y - m_MousePosOld.y;
h = m_rWindowStart.bottom - y;
break;
case SIZING_DIR_RIGHTBOTTOM:
w = m_rWindowStart.right - m_rWindowStart.left + m_MousePos.x - m_MousePosOld.x;
h = m_rWindowStart.bottom - m_rWindowStart.top + m_MousePos.y - m_MousePosOld.y;
break;
}
//window size snaps
w /= m_SnapSizing;
w *= m_SnapSizing;
h /= m_SnapSizing;
h *= m_SnapSizing;
//limit sizing
if (h < 20)
h = 20;
if (w < 20)
w = 20;
//move window (x, y, w, h, repaint)
m_pWindow->SetPosAndSize(x, y, w, h, true);
을 사용하고 코드는 다음과에서 호출하는 방법 m_pWindow
void Window::SetPosAndSize(int x, int y, int w, int h, bool repaint)
{
ASSERT(w >= 0, _T("w(Width) must be greater than 0"));
ASSERT(h >= 0, _T("h(Height) must be greater than 0"));
m_Width = w;
m_Height = h;
if(m_hWnd)
{
RECT rPos;
GetRect(rPos);
AdjustFromClient(w, h);
MoveWindow(m_hWnd, x, y, w, h, repaint);
}
}
void Window::GetRect(RECT& r) const
{
::GetWindowRect(m_hWnd, &r);
}
void Window::AdjustFromClient(int& w, int& h) const
{
RECT rSize2be = { 0, 0, w, h };
AdjustWindowRect(&rSize2be, m_Style, false);
w = rSize2be.right-rSize2be.left;
h = rSize2be.bottom-rSize2be.top;
}
여기가 정확히 문제를 이해하지 못하는 사람들을 위해 알고 보이는 방법의 예 ,216,211,
보도 Ctrl 키와 창 Alt 키를 이동하고
하단/오른쪽에서 크기를 조정하면 버퍼가 다시 그려지지 않으므로 위쪽/왼쪽 크기를 조정하면 다시 그립니다. GUI 프레임 워크에서 이중 버퍼링을 수행하는 방법을 배웁니다. –
나는 너무 가깝게 보지 않았다. 일반적인 문제는 윈도우의 왼쪽이나 위쪽을 움직일 때 상대적인 마우스 위치가 바뀐다는 것이다. 이런 식으로하지 말고 대신 WM_NCHITTEST의 메시지 처리기를 작성하십시오. –
(새 질문으로 새 질문을 올리십시오.) 스택 오버플로는 한 질문과 여러 답변에서 가장 잘 작동합니다. 포럼이 아닙니다. –