发信人: pb_lover()
整理人: leitiger(2002-06-05 23:47:38), 站内信件
|
: 想在数据窗口中用enter替代tab?没有什么好办法 : 能不能用send函数发送一个事件id? : 例如: : IF keydown(keyEnter!) THEN : ....... 可以这么做: 先在该数据窗口定义一个用户事件,如"enterkey" 其 envent id 为 "pbm_dwnprocessenter" 然后在该事件中写入 send(Handle(this),256,9,long(0,0)) P.S.谢谢你的filter,真是一言惊醒梦中人!
斑竹edison注: 这是老方法,由于这也是一种可行的方法。因此,我们将他保留于此。 关于解决这个问题的新方法请看下文!
-- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.96.122.250]
发信人: edison (edison), 信区: Powerbuilder 标 题: Re: 如何使用Enter代替TAB 发信站: 网易 BBS (Thu Sep 9 12:29:09 1999), 站内信件
这是外国人写的我将它翻译了!
用Enter键替代Tab键切换栏目的数据窗 许多情况下,PowerBuilder应用的数据是通过数据窗输入的,而且输入的数据是单纯的数字数据, 也就是说,输入内容完全可以通过敲击键盘右面的数字小键盘来完成。但在实际使用中,数据窗栏目间 的切换却要通过按键盘最左边的Tab键来实现,既不方便又影响录入速度。如果能用Enter键替代Tab键切 换栏目就好了。由于按Enter键是Windows直接支持的消息,故我们可以使用用户事件来解决问题。在用 户事件中,PowerBuilder提供的一条pbm_事件对应Windows的一条或几条消息。我们在数据窗dw_datamon 的用户事件中选择pbm_dwnProcessEnter并命名为Enterkeydown。在该事件下写代码: Send(Handle(this),256,9,Long(0,0)) This.SetActionCode(1) 这将把消息传递给Tab键,同时忽略Enter键的处理。 下面是一段用数据窗接收数据的完整的程序段,其中采用了用Enter键替代Tab键的代码。当光标在每行最 后一列时按Enter键,光标会移至下一行第一列;当光标在最后一行的最后一列时按Enter键,会自动产生 新行并将光标置于该行的第一列;在其它情况下按Enter键,光标会移至当前行的下一列。这段程序仍然 写在与pbm_dwnProcessEnter相对应的用户事件Enterkeydown下: IF This.AcceptText()<0 then this.setactioncode(1) return endif if this.getcolumn()=Long(This.DwDescribe("datawindow.column.count")) then if this.getrow()=This.RowCount() then this.insertrow(0) this.scrolltorow(this.getrow()+1) this.setcolumn(1) this.setactioncode(1) return endif endif send(handle(this),256,9,long(0,0)) this.setactioncode(1)
-- ※ 来源:.网易 BBS bbs.netease.com.[FROM: 202.103.190.9]
发信人: ilike (自在飞花), 信区: Powerbuilder 标 题: 肃清晓通的流毒(1)击键综述 发信站: 网易虚拟社区 (Sat Oct 9 21:09:44 1999), 转信
很多人都知道怎样在datawindow按下enter键模拟tab键的效果: 在datawindow中扩展出pbm_dwnprocessenter事件: 加入代码 Send( Handle( This),256,9,Long(0,0)) Return 1
这种方法曾经出现在晓通那一套天价的书上,网上各网站你抄我的,我抄你的, 好象只有这一种方法,一种思路,不知误导了多少人。
今天我就来肃清晓通的流毒。 这种方法其实效果也还可以,只不过是很久以前的Windows 3.1的技术了,在Win dows95以上的版本,我们有更好,更规范,功能更强的方法来实现。 在windows95以上,特意增加了一个API调用,keybd_event,这个API调用的功能 就是模拟键盘击键。 定义如下: subroutine keybd_event(uint bVk,uint bScan,long dwFlags,long dwExtraIn fo ) library 'user32.dll'
// 以下这段抄自MSDN, 是关于各参数的说明 Parameters bVk Specifies a virtual-key code. The code must be a value in the range 1 to 254. bScan Specifies a hardware scan code for the key. dwFlags A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined co nstant values to set the flags. Value Meaning KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a pr efix byte having the value 0xE0 (224). KEYEVENTF_KEYUP If specified, the key is being released. If not specif ied, the key is being depressed.
dwExtraInfo Specifies an additional 32-bit value associated with the key stroke.
谁有耐心慢慢看去,以下只说明我们要用的两个参数 bVk,指需要模拟的击键 dwflags, =0 ,按下 = 2 ,释放
下面我们看看如何实现以下功能: 按下enter键以及下箭头,相当于按下tab键 按下上箭头,相当于按下Shift-tab键 如果是在datawindow下,扩展出pbm_dwnkey,增加如下代码: If key = KeyEnter! Or Key = KeyDownArrow! Then keybd_event ( 9, 0, 0 , 0 ) // 按下tab keybd_event ( 9, 0, 2, 0 ) // 释放tab Return 1 End If
If Key = KeyUpArrow! Then keybd_event ( 16, 0, 0, 0 ) // 按下shift keybd_event ( 9, 0, 0 , 0 ) // 按下tab keybd_event ( 9, 0, 2, 0 ) // 释放tab keybd_event ( 16, 0, 2, 0 ) // 释放shift Return 1 End If
我们也可以在window级实现以上功能,很简单,将上面代码加在window的key事件 中即可.
keybd_event还有一些很神奇的作用,比如以下代码打开windows的“开始菜单”
keybd_event ( 91, 0, 0 , 0 ) // 按下win(不知道应该叫什么)键 keybd_event ( 91, 0, 2, 0 ) // 放开
-- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.103.137.180]
|
|