Hi, all
Not so familiar with Win32, I couldn't understand clearly about
PostMessage, SetScrollInfo...etc
follwing is my code.
I'd like to resize window, in WM_SIZE message.
because i want to resize window by m_ImageSize.
My problem is
1. How can I resize window by m_ImageSize(16 pixel) size, not one pixel.
2. How can I scrool window properly? this code is "SetScrollMap()"
thx,...
In C code...
Not so familiar with Win32, I couldn't understand clearly about
PostMessage, SetScrollInfo...etc
follwing is my code.
I'd like to resize window, in WM_SIZE message.
because i want to resize window by m_ImageSize.
My problem is
1. How can I resize window by m_ImageSize(16 pixel) size, not one pixel.
2. How can I scrool window properly? this code is "SetScrollMap()"
thx,...
In C code...
case WM_SIZE:
width = LOWORD(lParam);
height = HIWORD(lParam);
width = (width + m_ImageSize) / m_ImageSize * m_ImageSize;
height = (height + m_ImageSize) / m_ImageSize * m_ImageSize;
PostMessage(hWnd, WM_SIZE, SIZE_RESTORED, (LPARAM)MAKELONG(width, height) );
// I think this is wrong, but I don't know how process it.
SetScrollMap(hWnd, LOWORD(lParam), HIWORD(lParam));
break;
.....
void SetScrollMap(HWND hWnd, int width, int height)
{
HDC hdc;
SCROLLINFO hsi;
SCROLLINFO vsi;
int nScrollHeight = GetSystemMetrics (SM_CXVSCROLL);
int nScrollWidth = GetSystemMetrics (SM_CYHSCROLL);
int temp;
vsi.cbSize = sizeof(vsi);
vsi.fMask = SIF_ALL;
GetScrollInfo(hWnd, SB_VERT, &vsi);
hsi.cbSize = sizeof(hsi);
hsi.fMask = SIF_ALL;
GetScrollInfo(hWnd, SB_HORZ, &hsi);
if ((int) hsi.nPage <= hsi.nMax) {
width += nScrollWidth;
}
if ((int) vsi.nPage <= vsi.nMax){
height += nScrollHeight;
}
temp = m_ImageSize * m_ZoomSize;
//vsi.cbSize = sizeof(vsi);
vsi.fMask = SIF_RANGE | SIF_PAGE;
vsi.nMin = 0;
vsi.nMax = m_MapY * m_ZoomSize - 1;
vsi.nPage = height / temp;
if(height%temp) vsi.nPage--;
SetScrollInfo(hWnd, SB_VERT, &vsi, TRUE);
//hsi.cbSize = sizeof(hsi);
hsi.fMask = SIF_RANGE | SIF_PAGE;
hsi.nMin = 0;
hsi.nMax = m_MapX * m_ZoomSize - 1;
hsi.nPage = width / temp;
if(width%temp) hsi.nPage--;
SetScrollInfo(hWnd, SB_HORZ, &hsi, TRUE);
if(m_hmemMapBitmap) DeleteObject(m_hmemMapBitmap);
hdc = GetDC(hWnd);
m_hmemMapBitmap = CreateCompatibleBitmap(hdc, width, height);
ReleaseDC(hWnd, hdc);
}