找回密码
 加入
搜索
查看: 2239|回复: 7

怎么才能自动换行

[复制链接]
发表于 2009-5-25 14:11:17 | 显示全部楼层 |阅读模式
本帖最后由 kayiwa 于 2009-5-26 01:05 编辑

我创建一个文本输入框,如果你一直输入,到达边界的时候,他就会自动跳到第2行,不过显示的时候,还是没换行的。怎么才能让我显示的时候跟文本框的格式一样吗?就是会换行
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("", 190, 240)
$Edit1 = GUICtrlCreateEdit("",0, 0, 190, 190, $ES_WANTRETURN )
$Button1 = GUICtrlCreateButton("显示", 10, 200, 150, 30)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"",GUICtrlRead($Edit1))
        EndSwitch
WEnd
发表于 2009-5-25 14:34:14 | 显示全部楼层
貌似没有这样的GUI 控件样式
你这个要求相当于要平面镜显示出凸面镜的效果
如果你真的msgbox需要换行显示
就应该在edit输入到右侧末端的时候回车换行
发表于 2009-5-25 14:48:19 | 显示全部楼层
也有一种比较笨重的方法,就是字符串控制
可以实现你要的效果
但是前提是没有空格和其他制表符
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
     Case $Button1
      Dim $v,$var2
      $v = GUICtrlRead($Edit1)
      $var = StringMid($v, 1, 30)
      $var2 = StringMid($v, 30, 30)
                        MsgBox(0,"",$var&@CRLF&$var2 )
        EndSwitch
WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-5-25 14:55:11 | 显示全部楼层
投机取巧+没有考虑中文的情况  自己处理下

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <string.au3>
$Form1 = GUICreate("", 190, 240)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 190, 190, $ES_WANTRETURN)
$Button1 = GUICtrlCreateButton("显示", 10, 200, 150, 30)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $a = GUICtrlRead($Edit1)
                        $b = StringLen($a)
                        For $i = 1 To Round($b / 30)
                                If $i = 1 Then
                                        $a = _StringInsert($a, @CR, $i * 30)
                                Else
                                        $a = _StringInsert($a, @CR, $i * 30 + ($i - 1))
                                EndIf
                        Next
                        MsgBox(0, "", $a)
        EndSwitch
WEnd

评分

参与人数 1贡献 +1 收起 理由
lynfr8 + 1 原创内容,感谢你对论坛的支持;希望继续发 ...

查看全部评分

发表于 2009-5-25 17:38:37 | 显示全部楼层
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
$Form1 = GUICreate("", 190, 240)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 190, 190, $ES_WANTRETURN)
$Button1 = GUICtrlCreateButton("显示", 10, 200, 150, 30)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        _GUICtrlEdit_FmtLines($Edit1, True)
                        MsgBox(0, "", StringStripCR(GUICtrlRead($Edit1)))
        EndSwitch
WEnd
发表于 2009-5-25 19:54:50 | 显示全部楼层
恩 学习了
btw:感叹下 如果开源多好 能和udf一样看到原型
发表于 2009-5-25 23:30:01 | 显示全部楼层
本帖最后由 lynfr8 于 2009-5-26 01:41 编辑

学到东西
开心
_GUICtrlEdit_FmtLines确定是否修改控制,包括软线断字符

StringStripCR 删除字符串中的所有回车

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2009-5-26 01:04:44 | 显示全部楼层
非常感谢大家的帮忙
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-6 04:23 , Processed in 0.081179 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表