Source code of Windows XP (NT5)
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.

52 lines
1.1 KiB

  1. /****************************************************************************
  2. Copyright (c) Microsoft Corporation 1997
  3. All rights reserved
  4. ***************************************************************************/
  5. #include "pch.h"
  6. DEFINE_MODULE("Utils");
  7. //
  8. // Centers a dialog.
  9. //
  10. void
  11. CenterDialog(
  12. HWND hwndDlg )
  13. {
  14. RECT rc;
  15. RECT rcScreen;
  16. int x, y;
  17. int cxDlg, cyDlg;
  18. int cxScreen;
  19. int cyScreen;
  20. SystemParametersInfo( SPI_GETWORKAREA, 0, &rcScreen, 0 );
  21. cxScreen = rcScreen.right - rcScreen.left;
  22. cyScreen = rcScreen.bottom - rcScreen.top;
  23. GetWindowRect( hwndDlg, &rc );
  24. cxDlg = rc.right - rc.left;
  25. cyDlg = rc.bottom - rc.top;
  26. y = rcScreen.top + ( ( cyScreen - cyDlg ) / 2 );
  27. x = rcScreen.left + ( ( cxScreen - cxDlg ) / 2 );
  28. SetWindowPos( hwndDlg, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE );
  29. }
  30. //
  31. // Eats all mouse and keyboard messages.
  32. //
  33. void
  34. ClearMessageQueue( void )
  35. {
  36. MSG msg;
  37. while ( PeekMessage( (LPMSG)&msg, NULL, WM_KEYFIRST, WM_MOUSELAST,
  38. PM_NOYIELD|PM_REMOVE ) );
  39. }