bbq123bbq 发表于 2008-11-29 00:49:31

学用AU3做文档

#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)
这样虽然能显示出来,可点一下输入框就边成空,没有文档内容

sanhen 发表于 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

bbq123bbq 发表于 2008-11-29 01:20:00

怎样可以实现自动换行,在输入框只有右边滚动条,下边不要滚动条,像文本文档那样自动换行:face (35):

sanhen 发表于 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

bbq123bbq 发表于 2008-11-29 01:41:49

:face (29): 太感谢拉
能解释一下 $Edit1 = GUICtrlCreateEdit("", 8, 40, 409, 257,$WS_VSCROLL+$ES_AUTOVSCROLL) 中的 $ES_AUTOVSCROLL是什么意思,AU3说明是英文的,我在GOOGLE翻译又看不懂...

netegg 发表于 2008-12-1 10:13:38

$ES_AUTOVSCROLL后面是专门针对edit控件的自动垂直滚动的属性
页: [1]
查看完整版本: 学用AU3做文档