pb,用enter键实现焦点转移

wwwsmdy 2011-08-17 04:25:13
我搜了很多资料,基本上都可以实现用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
都无法让多行编辑框实现焦点的转移,请高手指点!
...全文
741 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
亡羊补牢未晚 2013-06-19
  • 打赏
  • 举报
回复
很有帮助,非常感谢!
yyoinge 2011-08-19
  • 打赏
  • 举报
回复
1、如何创建自定义的标准控件
在pb中,菜单“File → New”
在New窗口中,切换到PB Object标签页
选择Standard Visual,然后单击【OK】按钮
在Select Standard Visual...窗口中,选中multilineedit,然后单击【OK】按钮
这样就可以创建一个自定义的标准控件了(上面那个uo_multilineedit就是这么创建的)

2、如何使用自定义的标准控件
在需要使用1中创建的控件的窗口中的Layout面板中,选择菜单“Insert → Control → UserObject...”
在弹出的Select Object窗口中,选择该对象(如上面的uo_multilineedit),然后单击按钮【OK】
此时光标变为+型,在窗口任意位置单击鼠标左键,即可将该对象插入
wwwsmdy 2011-08-19
  • 打赏
  • 举报
回复
(yyoinge)
你真的好厉害,不过,这个东西如何才可以通用?现在只可以用到你的WW窗口中,而且里面只有一种控件——多行编辑框,如果还有别的控件,是不是也可以实现跳转,你不用Pb编程?难道你都只用记事本编程?太厉害了,佩服佩服。
wwwsmdy 2011-08-19
  • 打赏
  • 举报
回复
非常感谢你的回答,对我的帮助很大,谢谢!
sunfor 2011-08-18
  • 打赏
  • 举报
回复
我也碰到过下拉数据窗口也存在这样问题!
yyoinge 2011-08-18
  • 打赏
  • 举报
回复
2、将以下内容复制保存为到文本文档中,然后将文件名改名为:ww.srw
然后将该文件import到pbl中
$PBExportHeader$ww.srw
forward
global type ww from window
end type
type mle_3 from uo_multilineedit within ww
end type
type mle_2 from uo_multilineedit within ww
end type
type mle_1 from uo_multilineedit within ww
end type
end forward

global type ww from window
integer width = 2295
integer height = 824
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
mle_3 mle_3
mle_2 mle_2
mle_1 mle_1
end type
global ww ww

on ww.create
this.mle_3=create mle_3
this.mle_2=create mle_2
this.mle_1=create mle_1
this.Control[]={this.mle_3,&
this.mle_2,&
this.mle_1}
end on

on ww.destroy
destroy(this.mle_3)
destroy(this.mle_2)
destroy(this.mle_1)
end on

type mle_3 from uo_multilineedit within ww
integer x = 1509
integer y = 116
integer taborder = 30
end type

type mle_2 from uo_multilineedit within ww
integer x = 759
integer y = 104
integer taborder = 20
end type

type mle_1 from uo_multilineedit within ww
integer x = 64
integer y = 100
integer taborder = 10
end type



3、运行窗口ww,试试效果
yyoinge 2011-08-18
  • 打赏
  • 举报
回复
一楼的方法可用的,是你自己写错了,多行文本框是 case multilineedit!

1、将以下内容复制保存为到文本文档中,然后将文件名改名为:uo_multilineedit.sru
然后将该文件import到pbl中
$PBExportHeader$uo_multilineedit.sru
forward
global type uo_multilineedit from multilineedit
end type
end forward

global type uo_multilineedit from multilineedit
integer width = 549
integer height = 452
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
string text = "none"
borderstyle borderstyle = stylelowered!
event type integer post_key ( keycode key, integer keyflags )
event keydown pbm_keydown
end type
global uo_multilineedit uo_multilineedit

type prototypes
SUBROUTINE keybd_event(UInt bVk,UInt bScan,Long dwFlags,Long dwExtraInfo ) LIBRARY 'user32.dll'
end prototypes
event 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 CHOOSE
RETURN 1
end event

event keydown;post event post_key(key, keyflags)
end event

on uo_multilineedit.create
end on

on uo_multilineedit.destroy
end on

wwwsmdy 2011-08-18
  • 打赏
  • 举报
回复
这个自定义multilineedit控件,要如何定义,是属于Eventlist还是function?
forward
global type uo_multilineedit from multilineedit
end type
end forward

放什么位置?
谢谢啊!
一楼的方法我早已用过,不可用,谢谢!
yyoinge 2011-08-17
  • 打赏
  • 举报
回复
试试看这个自定义multilineedit控件, uo_multilineedit
按回车键时可以响应tab,同时不会录入回车符

forward
global type uo_multilineedit from multilineedit
end type
end forward

global type uo_multilineedit from multilineedit
integer width = 549
integer height = 452
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
string text = "none"
borderstyle borderstyle = stylelowered!
event type integer post_key ( keycode key, integer keyflags )
event keydown pbm_keydown
end type
global uo_multilineedit uo_multilineedit

type prototypes
SUBROUTINE keybd_event(UInt bVk,UInt bScan,Long dwFlags,Long dwExtraInfo ) LIBRARY 'user32.dll'
end prototypes
event 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 CHOOSE
RETURN 1
end event

event keydown;post event post_key(key, keyflags)
end event

on uo_multilineedit.create
end on

on uo_multilineedit.destroy
end on

yyoinge 2011-08-17
  • 打赏
  • 举报
回复

CASE MultiLineEdit!

不是

CASE SingleLineEdit!

不过这样虽然可以响应tab,但是还是会输入一个回车符号的

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧