2010年5月13日星期四

WinAPI 改变窗口大小

void SetClientWindowSize(HWND, int , int)

void SetClientWindowSize(HWND hWnd, int nClientWidth, int nClientHeight)
{
RECT WindowRect,ClientRect;

int nDeltaWidth, nDeltaHeight;

GetWindowRect( hWnd , &WindowRect );
GetClientRect( hWnd , &ClientRect );

nDeltaWidth = ( WindowRect.right - WindowRect.left ) - ( ClientRect.right - ClientRect.left );
nDeltaHeight = ( WindowRect.bottom - WindowRect.top ) - ( ClientRect.bottom - ClientRect.top );

MoveWindow( hWnd , WindowRect.left , WindowRect.top , nWidth + nDeltaWidth , nHeight + nDeltaHeight , TRUE );
}

SetClientWindowSize( hWnd , nWidth , nHeight );

没有评论: