home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / MENUF2.PRG < prev    next >
Text File  |  1995-04-24  |  2KB  |  81 lines

  1. //    menufn.prg - menu functions
  2. //
  3. //    Written by:    John M. Skelton,  Jun-94.
  4. //
  5. //    Copyright (C) 1994 Skelton Software, Kendal Cottage, Hillam, Leeds LS25 5HP, UK.
  6. //    All Rights Reserved.
  7. //
  8. //    Part of Clip-4-Win.
  9.  
  10. #define    WIN_WANT_MF
  11. #include "windows.ch"
  12. //#include "topclass.ch"
  13. #include "vo.ch"
  14. #include "menu.ch"
  15.  
  16.  
  17. STATIC GLOBAL    hCurMenu
  18. STATIC GLOBAL    aStack := {}
  19. STATIC GLOBAL    snId := 10000
  20.  
  21.  
  22. function _Menu_Begin(cnResId, hWnd, cDLL, hInst)
  23. aadd(aStack, hWnd)
  24. return hCurMenu := CreateMenu()
  25.  
  26.  
  27. function _Popup_Begin(cText, hMenu, nFlags, cnId)
  28. local    hPopup
  29. default hMenu  to hCurMenu
  30. default nFlags to MF_ENABLED + MF_POPUP
  31. default cnId   to ltrim(str(hMenu[1]))
  32. AppendMenu(hMenu, cnId, nFlags, cText, hPopup := CreatePopupMenu())
  33. aadd(aStack, hCurMenu)
  34. return hCurMenu := hPopup
  35.  
  36.  
  37. function _Menu_Append(cText, hMenu, cnId, bCmd, bAction, oHelp, oAccel,    ;
  38.                       lChecked, lDisabled, lGrayed, cBmpFile,        ;
  39.                       cnResId, cDLL, hInst)
  40. local    nFlags := 0
  41. default hMenu to hCurMenu
  42. default cnId to snId++
  43. // Done by pre-processor:
  44. //default bAction to &("{|| " + cCmd + "()}")    // hope {|| YourCmd()} will do
  45. default bAction to bCmd
  46. default lChecked to .f.
  47. default lDisabled to .f.
  48. default lGrayed to .f.
  49. nFlags += iif(lChecked, MF_CHECKED, MF_UNCHECKED)
  50. nFlags += iif(lDisabled, MF_DISABLED, MF_ENABLED)
  51. nFlags += iif(lGrayed, MF_GRAYED, 0)
  52. if cText == nil
  53.     if cBmpFile == nil
  54.         nFlags  = MF_SEPARATOR
  55.         bAction = nil
  56.     else
  57.         nFlags = MF_BITMAP
  58.         cText  = LoadBitmap(hInst, cnResId)
  59.     endif
  60. endif
  61. return AppendMenu(hMenu, cnId, nFlags, cText, bAction)
  62.  
  63.  
  64. function _Popup_End()
  65. hCurMenu = atail(aStack)
  66. asize(aStack, len(aStack) - 1)
  67. return hCurMenu
  68.  
  69.  
  70. function _Menu_End()
  71. local    hWnd := atail(aStack), hMenu
  72. asize(aStack, len(aStack) - 1)
  73. if !empty(hWnd)
  74.     if (hMenu := GetMenu(hWnd)) != nil
  75.         DestroyMenu(hMenu)
  76.     endif
  77.     SetMenu(hWnd, hCurMenu)
  78. endif
  79. return hCurMenu
  80.  
  81.