首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

pb中getfocus()函数为何返回为null

2013-01-05 
pb中getfocus()函数为啥返回为null代码如下在key(keycode key ,unsignedlong keyflags)函数中GraphicObjec

pb中getfocus()函数为啥返回为null
代码如下在key(keycode key ,unsignedlong keyflags)函数中

GraphicObject which_control
commandbutton cb_which
tab tab_which
if key = KeyEnter! then
which_control =getfocus()
  choose case typeof(which_control)
    case commandbutton!
          cb_which = which_control
 if cb_which = cb_1 then
 cb_1.triggerevent(clicked!)
 end if
 return
   end choose
keybd_event(9,0,0,0)
keybd_event(9,0,2,0)
end if
//这是很简单的enter键变为tab的一段代码,pb自带的例子也有相似代码,我在tab order 也已经将顺序改好,不过在调试过程中,getfocus()方法始终返回null,很是费解,望高手指明。
[解决办法]
debug时取到的就是空,直接运行时取值是没问题的,你可以在确定焦点是你的按钮时:
  choose case typeof(which_control)
    case commandbutton!
       这里加一句 messagebox("",abc)

会发现 abc弹出来了 此时debug的话 getfocus还会是空 为啥我不知道。

如果楼主想实现enter键变为tab功能的话

if key = KeyEnter! then

Send(Handle(This),256,9,Long(0,0))
return 1

end if 

这句话就是模拟tab键了 

热点排行