windows_window_pos.cpp 905 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/windows/window.h>
  5. namespace __vic { namespace windows {
  6. //----------------------------------------------------------------------------
  7. void Window::SetClientAreaSize(int width, int height)
  8. {
  9. RECT r_out = GetRect();
  10. RECT r_in = GetClientRect();
  11. int dx = r_out.right - r_out.left - r_in.right,
  12. dy = r_out.bottom - r_out.top - r_in.bottom;
  13. SetSize(width + dx, height + dy);
  14. }
  15. //----------------------------------------------------------------------------
  16. void Window::MoveToCenter()
  17. {
  18. int cx_maximized = ::GetSystemMetrics(SM_CXMAXIMIZED),
  19. cy_maximized = ::GetSystemMetrics(SM_CYMAXIMIZED);
  20. RECT r = GetRect();
  21. int x = (cx_maximized - (r.right - r.left)) / 2,
  22. y = (cy_maximized - (r.bottom - r.top)) / 2;
  23. MoveTo(x, y);
  24. }
  25. //----------------------------------------------------------------------------
  26. }} // namespace