当前位置: 代码迷 >> PB >> pb,用enter键实现焦点转移,该如何解决
  详细解决方案

pb,用enter键实现焦点转移,该如何解决

热度:543   发布时间:2016-04-29 10:41:10.0
pb,用enter键实现焦点转移
我搜了很多资料,基本上都可以实现用enter键来完成tab键的功能,但是当遇到多行编辑框的时候,焦点就无法再继续跳转了,现在我用的方法是:SUBROUTINE keybd_event(UInt bVk,UInt bScan,Long dwFlags,Long dwExtraInfo ) LIBRARY 'user32.dll'
GraphicObject which_control
which_control = GetFocus()
CHOOSE CASE TypeOf(which_control)
CASE CommandButton!
which_control.TriggerEvent(Clicked!)
CASE SingleLineEdit!
IF Key = KeyEnter! THEN
keybd_event ( 9, 0, 0 , 0 ) // 按下tab 
keybd_event ( 9, 0, 2, 0 ) // 释放tab 
END IF
END CHOOSE
RETURN 1

包括最土的方法,if keydown(keyenter!) then
string ls_name
ls_name = classname(getfocus())
choose case ls_name
case 'sle_code'
mle_content.setfocus()
case 'mle_content'
sle_1.setfocus()

return true
end choose
end if
都无法让多行编辑框实现焦点的转移,请高手指点!

------解决方案--------------------
一楼的方法可用的,是你自己写错了,多行文本框是 case multilineedit!

1、将以下内容复制保存为到文本文档中,然后将文件名改名为:uo_multilineedit.sru
然后将该文件import到pbl中
C/C++ code
$PBExportHeader$uo_multilineedit.sruforwardglobal type uo_multilineedit from multilineeditend typeend forwardglobal type uo_multilineedit from multilineeditinteger width = 549integer height = 452integer textsize = -12integer weight = 400fontcharset fontcharset = ansi!fontpitch fontpitch = variable!fontfamily fontfamily = swiss!string facename = "Arial"long textcolor = 33554432string text = "none"borderstyle borderstyle = stylelowered!event type integer post_key ( keycode key,  integer keyflags )event keydown pbm_keydownend typeglobal uo_multilineedit uo_multilineedittype prototypesSUBROUTINE keybd_event(UInt bVk,UInt bScan,Long dwFlags,Long dwExtraInfo ) LIBRARY 'user32.dll'end prototypesevent type integer post_key(keycode key, integer keyflags);//GraphicObject which_control//which_control = GetFocus()//CHOOSE CASE TypeOf(which_control)//    CASE CommandButton!//        which_control.TriggerEvent(Clicked!)//    CASE MultiLineEdit!        IF Key = KeyEnter! THEN            keybd_event ( 8, 0, 0, 0 ) // 退格            keybd_event ( 9, 0, 0, 0 ) // 按下tab              keybd_event ( 9, 0, 2, 0 ) // 释放tab          END IF//END CHOOSERETURN 1end eventevent keydown;post event post_key(key, keyflags)end eventon uo_multilineedit.createend onon uo_multilineedit.destroyend on
------解决方案--------------------
2、将以下内容复制保存为到文本文档中,然后将文件名改名为:ww.srw
然后将该文件import到pbl中
C/C++ code
$PBExportHeader$ww.srwforwardglobal type ww from windowend typetype mle_3 from uo_multilineedit within wwend typetype mle_2 from uo_multilineedit within wwend typetype mle_1 from uo_multilineedit within wwend typeend forwardglobal type ww from windowinteger width = 2295integer height = 824boolean titlebar = truestring title = "Untitled"boolean controlmenu = trueboolean minbox = trueboolean maxbox = trueboolean resizable = truelong backcolor = 67108864string icon = "AppIcon!"boolean center = truemle_3 mle_3mle_2 mle_2mle_1 mle_1end typeglobal ww wwon ww.createthis.mle_3=create mle_3this.mle_2=create mle_2this.mle_1=create mle_1this.Control[]={this.mle_3,&this.mle_2,&this.mle_1}end onon ww.destroydestroy(this.mle_3)destroy(this.mle_2)destroy(this.mle_1)end ontype mle_3 from uo_multilineedit within wwinteger x = 1509integer y = 116integer taborder = 30end typetype mle_2 from uo_multilineedit within wwinteger x = 759integer y = 104integer taborder = 20end typetype mle_1 from uo_multilineedit within wwinteger x = 64integer y = 100integer taborder = 10end type
------解决方案--------------------
1、如何创建自定义的标准控件
在pb中,菜单“File → New”
在New窗口中,切换到PB Object标签页
选择Standard Visual,然后单击【OK】按钮
在Select Standard Visual...窗口中,选中multilineedit,然后单击【OK】按钮
  相关解决方案