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.

108 lines
3.3 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // File: iputils.hxx
  4. //
  5. // Contents: Helper functions for in-place activation
  6. //
  7. //----------------------------------------------------------------------
  8. #include "headers.hxx"
  9. #pragma hdrstop
  10. #define MAXLABELLEN 32
  11. //+---------------------------------------------------------------
  12. //
  13. // Function: InsertServerMenus
  14. //
  15. // Synopsis: Inserts the objects menus into a shared menu after
  16. // the top-level application has inserted its menus
  17. //
  18. // Arguments: [hmenuShared] -- the shared menu to recieve the objects menus
  19. // [hmenuObject] -- all of the objects menus
  20. // [lpmgw] -- menu group widths indicating where the menus
  21. // should be inserted
  22. //
  23. // Returns: Success if the menus were merged successfully
  24. //
  25. // Notes: The function does most of the shared menu work
  26. // by the object between the IOleInPlaceFrame::InsertMenus and
  27. // IOleInPlaceFrame::SetMenu method calls.
  28. // c.f. RemoveServerMenus
  29. //
  30. //----------------------------------------------------------------
  31. HRESULT
  32. InsertServerMenus(HMENU hmenuShared,
  33. HMENU hmenuObject,
  34. LPOLEMENUGROUPWIDTHS lpmgw)
  35. {
  36. int i, j;
  37. HMENU hmenuXfer;
  38. TCHAR szLabel[MAXLABELLEN];
  39. UINT iServer = 0;
  40. UINT iShared = 0;
  41. // for each of the Edit, Object, and Help menu groups
  42. for (j = 1; j <= 5; j += 2)
  43. {
  44. // advance over container menus
  45. iShared += (UINT)lpmgw->width[j-1];
  46. // pull out the popup menus from servers menu
  47. for (i = 0; i < lpmgw->width[j]; i++)
  48. {
  49. GetMenuString(hmenuObject,
  50. iServer,
  51. szLabel,
  52. MAXLABELLEN,
  53. MF_BYPOSITION);
  54. hmenuXfer = GetSubMenu(hmenuObject, iServer++);
  55. if (!InsertMenu(hmenuShared,
  56. iShared++,
  57. MF_BYPOSITION|MF_POPUP,
  58. (UINT_PTR)hmenuXfer,
  59. szLabel))
  60. {
  61. return HRESULT_FROM_WIN32(GetLastError());
  62. }
  63. }
  64. }
  65. return NOERROR;
  66. }
  67. //+---------------------------------------------------------------
  68. //
  69. // Function: RemoveServerMenus
  70. //
  71. // Synopsis: Removes the objects menus from a shared menu
  72. //
  73. // Arguments: [hmenuShared] -- the menu contain both the application's
  74. // and the object's menus
  75. // [lpmgw] -- menu group widths indicating which menus should
  76. // be removed
  77. //
  78. // Notes: c.f. InsertServerMenus
  79. //
  80. //----------------------------------------------------------------
  81. void
  82. RemoveServerMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpmgw)
  83. {
  84. int i, j;
  85. UINT iShared = 0;
  86. // for each of the Edit, Object, and Help menu groups
  87. for (j = 1; j <= 5; j += 2)
  88. {
  89. // advance over container menus
  90. iShared += (UINT)lpmgw->width[j-1];
  91. // pull out the popup menus from shared menu
  92. for (i = 0; i < lpmgw->width[j]; i++)
  93. {
  94. RemoveMenu(hmenuShared, iShared, MF_BYPOSITION);
  95. }
  96. }
  97. }
  98.