Leaked source code of windows server 2003
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.

67 lines
2.5 KiB

  1. #include <windows.h>
  2. //----------------------------------------------------------------------------
  3. // Function: IsInWorkArea
  4. //
  5. // Synopsis: Tests whether a help viewer window is in the work area.
  6. //
  7. // Arguments:
  8. // hwndHelpViewer: the handle (HWND) to a help viewer window
  9. //
  10. // Returns: TRUE if in the work area, otherwise, FALSE
  11. //
  12. // Modifies: None.
  13. //
  14. //----------------------------------------------------------------------------
  15. BOOL IsInWorkArea(HWND hwndHelpViewer)
  16. {
  17. RECT rectHelpViewer;
  18. BOOL bIsInWorkArea = FALSE;
  19. if (GetWindowRect(hwndHelpViewer, &rectHelpViewer))
  20. {
  21. RECT rectWorkArea;
  22. if (SystemParametersInfo(SPI_GETWORKAREA, NULL, (PVOID)&rectWorkArea, NULL))
  23. {
  24. bIsInWorkArea = (rectHelpViewer.left >= rectWorkArea.left) && (rectHelpViewer.top >= rectWorkArea.top)
  25. && (rectHelpViewer.right <= rectWorkArea.right) && (rectHelpViewer.bottom <= rectWorkArea.bottom);
  26. }
  27. }
  28. return bIsInWorkArea;
  29. }
  30. //----------------------------------------------------------------------------
  31. // Function: PlaceInWorkArea
  32. //
  33. // Synopsis: Place a help viewer in the work area.
  34. // The width becomes 0.6 of original width. The left margin is 0.2 of original width.
  35. // The height becomes 0.7 of original height. The top margin is 0.075 of original height.
  36. //
  37. // Arguments:
  38. // hwndHelpViewer: the handle (HWND) to a help viewer
  39. //
  40. // Returns: None.
  41. //
  42. // Modifies: Modifies the window position and size as specified above.
  43. //
  44. //----------------------------------------------------------------------------
  45. void PlaceInWorkArea(HWND hwndHelpViewer)
  46. {
  47. RECT rectWorkArea;
  48. if (SystemParametersInfo(SPI_GETWORKAREA, NULL, (PVOID) &rectWorkArea, NULL))
  49. {
  50. FLOAT fOrigWidth = (FLOAT) (rectWorkArea.right - rectWorkArea.left);
  51. FLOAT fOrigHeight = (FLOAT) (rectWorkArea.bottom - rectWorkArea.top);
  52. FLOAT fHRatio = (FLOAT) 0.6;
  53. FLOAT fHMarginRatio = (FLOAT) ((1.0 - fHRatio) / 2.0);
  54. FLOAT fVRatio = (FLOAT) 0.7;
  55. FLOAT fVMarginRatio = (FLOAT) ((1.0 - fVRatio) / 4.0);
  56. int iWidth = (int) (fOrigWidth * fHRatio);
  57. int iHeight = (int) (fOrigHeight * fVRatio);
  58. int iLeft = (int) rectWorkArea.left + (int) (fOrigWidth * fHMarginRatio);
  59. int iTop = (int) rectWorkArea.top + (int) (fOrigHeight * fVMarginRatio);
  60. MoveWindow(hwndHelpViewer, iLeft, iTop, iWidth, iHeight, TRUE);
  61. }
  62. }