- case WM_SIZING:
- {
- // WINDOW_HEIGHT/WINDOW_WIDTH 为窗口初始长宽
- static float sScale = (WINDOW_HEIGHT*1.0/WINDOW_WIDTH);
- int cx, cy;
- LPRECT lpRect = (LPRECT)lParam;
- if (wParam == WMSZ_LEFT || wParam == WMSZ_RIGHT)
- {
- cx = lpRect->right - lpRect->left;
- cy = (int)(cx * sScale);
- lpRect->bottom = lpRect->top + cy;
- }
- else if (wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT)
- {
- cy = lpRect->bottom - lpRect->top;
- cx = (int)(cy / sScale);
- lpRect->left = lpRect->right - cx;
- }
- else
- {
- cy = lpRect->bottom - lpRect->top;
- cx = (int)(cy / sScale);
- lpRect->right = lpRect->left + cx;
- }
- break;
- }
- //该片段来自于http://www.codesnippet.cn/detail/2210201410780.html
来源: http://www.codesnippet.cn/detail/2210201410780.html