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