找回密码
 加入
搜索
查看: 2173|回复: 5

学用AU3做文档

[复制链接]
发表于 2008-11-29 00:49:31 | 显示全部楼层 |阅读模式
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("文档", 433, 313, 193, 115)
$Button2 = GUICtrlCreateButton("保存", 120, 8, 97, 25, 0)
$Button1 = GUICtrlCreateButton("打开", 8, 8, 97, 25, 0)
$Edit1 = GUICtrlCreateEdit("", 8, 40, 409, 257)
GUICtrlSetData(-1, "")
$Combo1 = GUICtrlCreateCombo("选择", 232, 8, 185, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button2
                        $FileSave = FileSaveDialog ("保存",@WindowsDir & "", "文本文档 (*.txt)|所有文件 (*.*)", 16 )
                        $read = GUICtrlRead ($Edit1)
                        FileWrite ($FileSave,$read)
                Case $Button1
                        $FileOpen = FileOpenDialog ("打开",@WindowsDir & "", "文本文档 (*.txt)|所有文件 (*.*)",1+2+4)
                        $Fread = FileRead ($FileOpen)
                        
        EndSwitch
WEnd

怎样可以实现文本文档那样自动换行用 GUICtrlCreateEdit 有滚动条,还有点 打开 文件后导入文档内容怎样让文档内容显示在 输入框内
Case $Button1
                        $FileOpen = FileOpenDialog ("打开",@WindowsDir & "", "文本文档 (*.txt)|所有文件 (*.*)",1+2+4)
                        $Fread = FileRead ($FileOpen)
                        GUICtrlCreateEdit($Fread, 8, 40, 409, 257)

这样虽然能显示出来,可点一下输入框就边成空,没有文档内容
发表于 2008-11-29 01:09:38 | 显示全部楼层

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("文档", 433, 313, 193, 115)
$Button2 = GUICtrlCreateButton("保存", 120, 8, 97, 25, 0)
$Button1 = GUICtrlCreateButton("打开", 8, 8, 97, 25, 0)
$Edit1 = GUICtrlCreateEdit("", 8, 40, 409, 257,-1)
GUICtrlSetData(-1, "")
$Combo1 = GUICtrlCreateCombo("选择", 232, 8, 185, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $FileSave = FileSaveDialog ("保存",@WindowsDir & "", "文本文档 (*.txt)|所有文件 (*.*)", 16 )
            $read = GUICtrlRead ($Edit1)
            FileWrite ($FileSave,$read)
        Case $Button1
            $FileOpen = FileOpenDialog ("打开",@WindowsDir & "", "文本文档 (*.txt)|所有文件 (*.*)",1+2+4)
            $Fread = FileRead ($FileOpen)
            GUICtrlSetData($Edit1 ,$Fread )
    EndSwitch
WEnd

 楼主| 发表于 2008-11-29 01:20:00 | 显示全部楼层
怎样可以实现自动换行,在输入框只有右边滚动条,下边不要滚动条,像文本文档那样自动换行
发表于 2008-11-29 01:31:31 | 显示全部楼层
继续。不知是否满足你的要求。


#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("文档", 433, 313, 193, 115)
$Button2 = GUICtrlCreateButton("保存", 120, 8, 97, 25, 0)
$Button1 = GUICtrlCreateButton("打开", 8, 8, 97, 25, 0)
$Edit1 = GUICtrlCreateEdit("", 8, 40, 409, 257,$WS_VSCROLL+$ES_AUTOVSCROLL)
GUICtrlSetData(-1, "")
$Combo1 = GUICtrlCreateCombo("选择", 232, 8, 185, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $FileSave = FileSaveDialog ("保存",@WindowsDir & "", "文本文档 (*.txt)|所有文件 (*.*)", 16 )
            $read = GUICtrlRead ($Edit1)
            FileWrite ($FileSave,$read)
        Case $Button1
            $FileOpen = FileOpenDialog ("打开",@WindowsDir & "", "文本文档 (*.txt)|所有文件 (*.*)",1+2+4)
            $Fread = FileRead ($FileOpen)
            GUICtrlSetData($Edit1 ,$Fread )
    EndSwitch
WEnd
 楼主| 发表于 2008-11-29 01:41:49 | 显示全部楼层
太感谢拉
能解释一下 $Edit1 = GUICtrlCreateEdit("", 8, 40, 409, 257,$WS_VSCROLL+$ES_AUTOVSCROLL) 中的 $ES_AUTOVSCROLL  是什么意思,AU3说明是英文的,我在GOOGLE翻译又看不懂...
发表于 2008-12-1 10:13:38 | 显示全部楼层
$ES_AUTOVSCROLL后面是专门针对edit控件的自动垂直滚动的属性
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-23 10:26 , Processed in 0.079367 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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