Futurebasic/语言/参考/def embedbutton
✔ 外观 ✔ 标准 ✔ 控制台
DEF EMBEDBUTTON(childButtonID&, parentButtonID&)
2002 年 2 月(6.0 版)
外观管理器可以将多个按钮(子控件)嵌入单个父按钮(或超级控件)中。实际上,按钮可以嵌入到按钮中,而按钮又可以嵌入到其他按钮中。这样做的好处非常多。以这个例子为例:每个窗口都有一个根控件。窗口内的所有按钮都嵌入到该根控件或其子控件之一中。当窗口变为非活动状态时,根控件会被禁用。通过该单一命令(由 FB 运行时实现),窗口内的所有其他控件都会自动被禁用。
这种灵活性和显示或隐藏选项卡控件中的窗格或组内的按钮等功能相辅相成。
以下示例创建了一个单选按钮组,并将单个按钮嵌入到超级控件中。因此,您可以查询组按钮以了解当前选中的单选子控件。
image d/DEF%20EMBEDBUTTON02.gif
DIM r as rect
DIM pR as rect
DIM h as handle
DIM bRef as long
DIM err as OSErr
// 创建窗口
SETRECT(r,0,0,_btnWd_btnMargin_btnMargin,120)
APPEARANCE WINDOW 1,,@r
err = FN SETTHEMEWINDOWBACKGROUND( window( _wndPointer ),¬
_kThemeActiveDialogBackgroundBrush, _zTrue )
// 按钮 #1 是父按钮
// 请注意,父按钮有足够的空间,因此它可以容纳所有嵌入在其矩形内的嵌入按钮
SETRECT(r,_btnMargin,_btnMargin,¬
_btnMargin_btnWd,(_btnMargin_btnHt)*3)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"",@r,_kControlRadioGroupProc
bRef ++
SETRECT(r,_btnMargin,_btnMargin,_btnMargin_btnWd,¬
_btnMargin_btnHt)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"Radio 1",@r,_kControlRadioButtonProc
DEF EMBEDBUTTON(bRef,1)
bRef ++ : offsetrect(r,0,_btnHt_btnMargin)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"Radio 2",@r,_kControlRadioButtonProc
DEF EMBEDBUTTON(bRef,1)
bRef ++ : offsetrect(r,0,_btnHt_btnMargin)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"Radio 3",@r,_kControlRadioButtonProc
DEF EMBEDBUTTON(bRef,1)
LOCAL FN handleDialog
DIM AS LONG action,reference
action = DIALOG(0)
reference = DIALOG(action)
LONG IF action = _btnclick
MOVETO(8,100)
PRINT "Current Button ";button(1);
END IF
END FN
ON DIALOG FN handleDialog
DO
HANDLEEVENTS
UNTIL 0