在下面名为 cntbar.prg 的示例中,向系统菜单中添加一个菜单标题,创建带有四个菜单项的菜单 popenv 。当选择菜单项时,程序在每个菜单项旁放置一个标记字符。在循环中使用
cntbar( ) 可以在菜单项旁显示标记。
*** 此程序名为 cntbar.prg ***
clear
set talk off
define pad padenv of _msysmenu prompt 'e\<nvironment';
key alt+v, 'alt+v'
on pad padenv of _msysmenu activate popup popenv
define popup popenv margin relative shadow color scheme 4
define bar 1 of popenv prompt '\<status bar'
define bar 2 of popenv prompt '\<clock'
define bar 3 of popenv prompt '\<extended video'
define bar 4 of popenv prompt 'st\<icky'
on selection popup popenv do enviropop in cntbar.prg
for i = 1 to cntbar('popenv')
do case
case prmbar('popenv', i) = 'status bar'
set mark of bar i of popenv to set('status') = 'on'
case prmbar('popenv', i) = 'clock'
set mark of bar i of popenv to set('clock') = 'on'
case prmbar('popenv', i) = 'extended video'
set mark of bar i of popenv to srow( ) > 25
case prmbar('popenv', i) = 'sticky'
set mark of bar i of popenv to set('sticky') = 'on'
endcase
endfor
procedure enviropop
do case
case prompt() = 'status'
if mrkbar('popenv', bar( ))
do case
case _windows or _mac
set status bar off
case _dos
set status off
otherwise
endcase
set mark of bar bar( ) of popenv to .f.
else
do case
case _windows or _mac
set status bar on
case _dos
set status on
otherwise
endcase
set mark of bar bar( ) of popenv to .t.
endif
case prompt( ) = 'clock'
if mrkbar('popenv', bar( ))
set clock off
set mark of bar bar( ) of popenv to .f.
else
do case
case _windows or _mac
set status bar on
set clock status
case _dos
set clock on
otherwise
endcase
set mark of bar bar( ) of popenv to .t.
endif
case prompt( ) = 'extended video'
if mrkbar('popenv', bar( ))
set display to vga25
set mark of bar bar( ) of popenv to .f.
else
set display to vga50
set mark of bar bar( ) of popenv to .t.
endif
case prompt( ) = 'sticky'
if mrkbar('popenv', bar( ))
do case
case _windows or _mac
wait window 'sticky is always on in this visual foxpro version'
case _dos
set sticky off
otherwise
endcase
set mark of bar bar( ) of popenv to .f.
else
do case
case _windows or _mac
wait window 'sticky is always on in visual foxpro'
case _dos
set sticky on
otherwise
endcase
set mark of bar bar( ) of popenv to .t.
endif
endcase