Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <mxtk/mx.h>
  8. #include "tier0/dbg.h"
  9. #include "basedialogparams.h"
  10. //-----------------------------------------------------------------------------
  11. // Purpose:
  12. // Input : self -
  13. //-----------------------------------------------------------------------------
  14. void CBaseDialogParams::PositionSelf( void *self )
  15. {
  16. RECT rcDlg;
  17. HWND dlgWindow = (HWND)self;
  18. GetWindowRect( dlgWindow, &rcDlg );
  19. // Get relative to primary monitor instead of actual window parent
  20. RECT rcParent;
  21. rcParent.left = 0;
  22. rcParent.right = rcParent.left + GetSystemMetrics( SM_CXFULLSCREEN );
  23. rcParent.top = 0;
  24. rcParent.bottom = rcParent.top + GetSystemMetrics( SM_CYFULLSCREEN );
  25. int dialogw, dialogh;
  26. int parentw, parenth;
  27. parentw = rcParent.right - rcParent.left;
  28. parenth = rcParent.bottom - rcParent.top;
  29. dialogw = rcDlg.right - rcDlg.left;
  30. dialogh = rcDlg.bottom - rcDlg.top;
  31. int dlgleft, dlgtop;
  32. dlgleft = ( parentw - dialogw ) / 2;
  33. dlgtop = ( parenth - dialogh ) / 2;
  34. if ( m_bPositionDialog )
  35. {
  36. int top = m_nTop - dialogh - 5;
  37. int left = m_nLeft;
  38. MoveWindow( dlgWindow,
  39. left,
  40. top,
  41. dialogw,
  42. dialogh,
  43. TRUE );
  44. }
  45. else
  46. {
  47. MoveWindow( dlgWindow,
  48. dlgleft,
  49. dlgtop,
  50. dialogw,
  51. dialogh,
  52. TRUE
  53. );
  54. }
  55. }