home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 4
/
BUGCD1997_05.BIN
/
aplic
/
clip4win
/
clip4win.exe
/
C4W30E.HUF
/
SOURCE
/
MENUF2.PRG
< prev
next >
Wrap
Text File
|
1995-04-24
|
2KB
|
81 lines
// menufn.prg - menu functions
//
// Written by: John M. Skelton, Jun-94.
//
// Copyright (C) 1994 Skelton Software, Kendal Cottage, Hillam, Leeds LS25 5HP, UK.
// All Rights Reserved.
//
// Part of Clip-4-Win.
#define WIN_WANT_MF
#include "windows.ch"
//#include "topclass.ch"
#include "vo.ch"
#include "menu.ch"
STATIC GLOBAL hCurMenu
STATIC GLOBAL aStack := {}
STATIC GLOBAL snId := 10000
function _Menu_Begin(cnResId, hWnd, cDLL, hInst)
aadd(aStack, hWnd)
return hCurMenu := CreateMenu()
function _Popup_Begin(cText, hMenu, nFlags, cnId)
local hPopup
default hMenu to hCurMenu
default nFlags to MF_ENABLED + MF_POPUP
default cnId to ltrim(str(hMenu[1]))
AppendMenu(hMenu, cnId, nFlags, cText, hPopup := CreatePopupMenu())
aadd(aStack, hCurMenu)
return hCurMenu := hPopup
function _Menu_Append(cText, hMenu, cnId, bCmd, bAction, oHelp, oAccel, ;
lChecked, lDisabled, lGrayed, cBmpFile, ;
cnResId, cDLL, hInst)
local nFlags := 0
default hMenu to hCurMenu
default cnId to snId++
// Done by pre-processor:
//default bAction to &("{|| " + cCmd + "()}") // hope {|| YourCmd()} will do
default bAction to bCmd
default lChecked to .f.
default lDisabled to .f.
default lGrayed to .f.
nFlags += iif(lChecked, MF_CHECKED, MF_UNCHECKED)
nFlags += iif(lDisabled, MF_DISABLED, MF_ENABLED)
nFlags += iif(lGrayed, MF_GRAYED, 0)
if cText == nil
if cBmpFile == nil
nFlags = MF_SEPARATOR
bAction = nil
else
nFlags = MF_BITMAP
cText = LoadBitmap(hInst, cnResId)
endif
endif
return AppendMenu(hMenu, cnId, nFlags, cText, bAction)
function _Popup_End()
hCurMenu = atail(aStack)
asize(aStack, len(aStack) - 1)
return hCurMenu
function _Menu_End()
local hWnd := atail(aStack), hMenu
asize(aStack, len(aStack) - 1)
if !empty(hWnd)
if (hMenu := GetMenu(hWnd)) != nil
DestroyMenu(hMenu)
endif
SetMenu(hWnd, hCurMenu)
endif
return hCurMenu