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.

100 lines
2.8 KiB

  1. /****************************** Module Header ******************************\
  2. *
  3. * Module Name: mncreate.c
  4. *
  5. * Copyright (c) 1985 - 1999, Microsoft Corporation
  6. *
  7. * Creation routines for menus
  8. *
  9. * Public Functions:
  10. *
  11. * _CreateMenu()
  12. * _CreatePopupMenu()
  13. *
  14. * History:
  15. * 09-24-90 mikeke from win30
  16. * 02-11-91 JimA Added access checks.
  17. * 03-18-91 IanJa Window revalidation added (none required)
  18. \***************************************************************************/
  19. #include "precomp.h"
  20. #pragma hdrstop
  21. /***************************************************************************\
  22. * InternalCreateMenu
  23. *
  24. * Creates and returns a handle to an empty menu structure. Returns
  25. * NULL if unsuccessful in allocating the memory. If PtiCurrent() ==
  26. * NULL, create an unowned menu, probably the system menu.
  27. *
  28. * History:
  29. * 28-Sep-1990 mikeke from win30
  30. * 02-11-91 JimA Added access checks.
  31. \***************************************************************************/
  32. PMENU InternalCreateMenu(
  33. BOOL fPopup)
  34. {
  35. PMENU pmenu;
  36. PTHREADINFO ptiCurrent = PtiCurrent();
  37. PDESKTOP pdesk = NULL;
  38. /*
  39. * If the windowstation has been initialized, allocate from
  40. * the current desktop.
  41. */
  42. pdesk = ptiCurrent->rpdesk;
  43. /*
  44. * Just like in xxxCreateWindowEx, bypass the security check if hdesk is NULL
  45. * This allows CSR worker threads (ie harderror boxes) to do what they need to
  46. */
  47. if (ptiCurrent->hdesk != NULL) {
  48. RETURN_IF_ACCESS_DENIED(ptiCurrent->amdesk, DESKTOP_CREATEMENU, NULL);
  49. } else {
  50. UserAssert(ptiCurrent->TIF_flags & TIF_CSRSSTHREAD);
  51. }
  52. pmenu = HMAllocObject(ptiCurrent, pdesk, TYPE_MENU, sizeof(MENU));
  53. if (pmenu != NULL) {
  54. if (fPopup) {
  55. pmenu->fFlags = MFISPOPUP;
  56. }
  57. }
  58. return pmenu;
  59. }
  60. /***************************************************************************\
  61. * CreateMenu
  62. *
  63. * Creates and returns a handle to an empty menu structure. Returns
  64. * NULL if unsuccessful in allocating the memory. If PtiCurrent() ==
  65. * NULL, create an unowned menu, probably the system menu.
  66. *
  67. * History:
  68. * 28-Sep-1990 mikeke from win30
  69. * 02-11-91 JimA Added access checks.
  70. \***************************************************************************/
  71. PMENU _CreateMenu()
  72. {
  73. return InternalCreateMenu(FALSE);
  74. }
  75. /***************************************************************************\
  76. * CreatePopupMenu
  77. *
  78. * Creates and returns a handle to an empty POPUP menu structure. Returns
  79. * NULL if unsuccessful in allocating the memory.
  80. *
  81. * History:
  82. * 28-Sep-1990 mikeke from win30
  83. \***************************************************************************/
  84. PMENU _CreatePopupMenu()
  85. {
  86. return InternalCreateMenu(TRUE);
  87. }