[已解决]输入/选择焦点切换对富文本不起作用
本帖最后由 jycel 于 2009-12-28 12:34 编辑解决方法:二三楼
我们通常都使用GUICtrlSetState (控件,$GUI_FOCUS)来切换焦点
在富文本中却没效果!那位知道其它方法吗?
测试代码如下:#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiRichEdit.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("输入/选择焦点切换", 294, 237, 335, 410)
$hRichEdit1=_GUICtrlRichEdit_Create($Form1,"", 8, 16, 273, 145,BitOR($ES_MULTILINE, $WS_VSCROLL,$ES_READONLY, $ES_AUTOVSCROLL))
$Input1 = GUICtrlCreateInput("", 8, 168, 273, 21)
$Button1 = GUICtrlCreateButton("富文本", 8, 200, 81, 25)
$Button2 = GUICtrlCreateButton("Input框", 96, 200, 89, 25)
$Button3 = GUICtrlCreateButton("退出", 192, 200, 89, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete();一定要加上否则退出后进程都还在
Exit
Case $Button1
GUICtrlSetState ($hRichEdit1,$GUI_FOCUS)
Case $Button2
GUICtrlSetState ($Input1,$GUI_FOCUS)
Case $Button3
GUIDelete();一定要加上否则退出后进程都还在
Exit
EndSwitch
WEnd
_GUICtrlRichEdit_Create返回的是句柄,而非ID,这种情况下用_WinAPI_SetFocus。 嘿嘿!这样好像可以哦!#Include <GuiRichEdit.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("输入/选择焦点切换", 300, 240)
$hRichEdit1=_GUICtrlRichEdit_Create($Form1,"", 8, 16, 273, 145,BitOR($ES_MULTILINE, $WS_VSCROLL,$ES_READONLY, $ES_AUTOVSCROLL))
$Input1 = GUICtrlCreateInput("", 8, 168, 273, 21)
$Button1 = GUICtrlCreateButton("富文本", 8, 200, 81, 25)
$Button2 = GUICtrlCreateButton("Input框", 96, 200, 89, 25)
$Button3 = GUICtrlCreateButton("退出", 192, 200, 89, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete();一定要加上否则退出后进程都还在
Exit
Case $Button1
ControlFocus ( "输入/选择焦点切换", "", 'RICHEDIT50W1')
Case $Button2
GUICtrlSetState ($Input1,$GUI_FOCUS)
Case $Button3
GUIDelete();一定要加上否则退出后进程都还在
Exit
EndSwitch
WEnd 本帖最后由 jycel 于 2009-12-28 12:33 编辑
二楼和三楼都可以!
三楼的
ControlFocus ( "输入/选择焦点切换", "", 'RICHEDIT50W1')
这里的控件ID 为“RICHEDIT50W1”没明白到!
用$hRichEdit1也可以!
又学着一点!:face (29): 嘿嘿!很简单,怎么说呢!
GUICtrlSetState是内部的(也可以理解为自身),而ControlFocus是外部。
至于'RICHEDIT50W1'是你控件的类别名!
页:
[1]