Sign in to follow this  
Followers 0
AcidCorps

Word Wrap

3 posts in this topic

I searched and found the other examples on this forum but can't seem to get the word wrap to work on my edit box

;Includes
#include <String.au3>
#include <Array.au3>
#include <GuiConstants.au3>
#include <File.au3>

;File Install
If Not FileExists('Icon.ico') Then 
    FileInstall('Icon.ico', @TempDir & '\Icon.ico')
    $Icon = @TempDir & '\Icon.ico'
Else
    $Icon = 'Icon.ico'
EndIf


;Variables
$Width = IniRead('SimplePad.dat', 'Size', 'Width', -1)
$Height = IniRead('SimplePad.dat', 'Size', 'Height', -1)
$Left = IniRead('SimplePad.dat', 'Location', 'Left', -1)
$Top = IniRead('SimplePad.dat', 'Location', 'Top', -1)
$Style = IniRead('SimplePad.dat', 'Styles', 'Style', BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))
$ExStyle = IniRead('SimplePad.dat', 'Styles', 'ExStyle', BitOR($WS_EX_ACCEPTFILES, $WS_EX_CLIENTEDGE))
$Folder = IniRead('SimplePad.dat', 'Misc', 'Folder', @MyDocumentsDir)

;Create SimplePad.dat if not already exsist
If $Width = -1 Or $Height = -1 Or $Left = -1 Or $Top = -1 Then
    $TempGui = GUICreate('', -1, -1, -1, -1)
    GUISetState()
    While WinActive($TempGui)
        $Pos = WinGetPos($TempGui)
        ExitLoop
    WEnd
    WinClose($TempGui)
    IniWrite('SimplePad.dat', 'Size', 'Width', $Pos[2])
    IniWrite('SimplePad.dat', 'Size', 'Height', $Pos[3])
    IniWrite('SimplePad.dat', 'Location', 'Left', $Pos[0])
    IniWrite('SimplePad.dat', 'Location', 'Top', $Pos[1])
    If @Compiled = 1 Then Run(@ScriptFullPath)
    If @Compiled = 0 Then Run(@AutoItExe & ' ' & @ScriptName)
EndIf

;HotKeys
HotKeySet("{TAB}", "_Tab"); Fix Tab not inserting tab bug

;GUI
$Gui = GUICreate('L.a.c. SimplePad', $Width, $Height, $Left, $Top, $Style, $ExStyle)
GUISetIcon($Icon)
Menus()
$Edit = GUICtrlCreateEdit('', 0, 0, $Width, $Height, BitOR($ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetState($Edit, $GUI_DROPACCEPTED)
GUICtrlSetResizing($Edit, $GUI_DOCKBORDERS)

GUISetState()
While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit
            $Pos = WinGetPos($Gui)
            IniWrite('SimplePad.dat', 'Size', 'Width', $Pos[2])
            IniWrite('SimplePad.dat', 'Size', 'Height', $Pos[3])
            IniWrite('SimplePad.dat', 'Location', 'Left', $Pos[0])
            IniWrite('SimplePad.dat', 'Location', 'Top', $Pos[1])
            IniWrite('SimplePad.dat', 'Misc', 'Folder', $Folder)
            Exit
        Case $Msg = $New
            _New()
        Case $Msg = $Open
            $File = _Open()
            $Folder = StringReplace($File, StringTrimLeft($File, StringInStr($File, '\', 0, -1) - 1), '')
            IniWrite('SimplePad.dat', 'Misc', 'Folder', $Folder)
        Case $Msg = $Save
            _Save()
        Case $Msg = $SaveAs
            _SaveAs()
        Case $Msg = $Print
            _Print()
        Case $Msg = $Help
            _Help()
        Case $Msg = $About
            _About()
    EndSelect
WEnd

;Functions
Func Menus()
    ;File Menu
    Global $File = GUICtrlCreateMenu('File')
    Global $New = GUICtrlCreateMenuItem('New', $File)
    Global $Open = GUICtrlCreateMenuItem('Open...', $File)
    Global $Save = GUICtrlCreateMenuItem('Save', $File)
    Global $SaveAs = GUICtrlCreateMenuItem('Save As...', $File)
    Global $SaveToWeb = GUICtrlCreateMenuItem('Save To Web...', $File)
    GUICtrlCreateMenuBreak($File)
    Global $Print = GUICtrlCreateMenuItem('Print...', $File)
    GUICtrlCreateMenuBreak($File)
    Global $Exit = GUICtrlCreateMenuItem('Exit', $File)
    
    
    ;Help
    Global $HelpM = GUICtrlCreateMenu('Help')
    Global $Help = GUICtrlCreateMenuItem('Help', $HelpM)
    GUICtrlCreateMenuBreak($HelpM)
    Global $About = GUICtrlCreateMenuItem('About', $HelpM)
EndFunc   ;==>Menus

Func GUICtrlCreateMenuBreak($s_Menu)
    GUICtrlCreateMenuItem('', $s_Menu)
EndFunc   ;==>GUICtrlCreateMenuBreak

Func _Tab()
    Send('{CTRLDOWN}{TAB}{CTRLUP}')
EndFunc   ;==>_Tab

Func _New()
    $Erase = MsgBox(276, "New...", "Are you sure you want to start a new file?" & @CRLF & "This will erase your old text" & @CRLF & @CRLF & "(If you have already saved your document" & @CRLF & "you don't have to worry)")
    If $Erase = 6 Then GUICtrlSetData($Edit, '')
    Send('{RIGHT}')
EndFunc   ;==>_New

Func _Open()
    $File = FileOpenDialog('Open File', $Folder, 'Text Files (*.txt)', 3)
    $Read = FileRead($File)
    GUICtrlSetData($Edit, $Read)
    Return $File
EndFunc   ;==>_Open

Func _Save()
    If IsDeclared('File') Then
        FileOpen($File, 2)
        FileWrite($File, GUICtrlRead($Edit))
    Else
        _SaveAs()
    EndIf
EndFunc   ;==>_Save

Func _SaveAs()
    $File = FileSaveDialog('Save File', $Folder, 'Text Files (*.txt)', 16)
    FileOpen($File, 2)
    FileWrite($File, GUICtrlRead($Edit))
EndFunc   ;==>_SaveAs

Func _Print()
    $Temp = _TempFile(@TempDir, '~', '.txt')
    FileOpen($Temp, 2)
    FileWrite($Temp, GUICtrlRead($Edit))
    $Print = _FilePrint($Temp)
    If $Print Then
        MsgBox(0, 'Printing...', 'Note is being printed')
    Else
        MsgBox(0, 'Error', @error & @CRLF & 'The file was not printed.')
    EndIf
EndFunc   ;==>_Print

Func _Help()
    MsgBox(0, 'Help', 'Not available in beta')
EndFunc   ;==>_Help

Func _About()
    MsgBox(0, 'About', 'Not available in beta')
EndFunc   ;==>_About

Func RandomString($sLenght)
    Local $Return
    For $x = 1 To $sLenght
        $Return &= Chr(Random(65, 90, 1))
    Next
    Return $Return
EndFunc   ;==>RandomString

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites



I searched and found the other examples on this forum but can't seem to get the word wrap to work on my edit box

;Includes
#include <String.au3>
#include <Array.au3>
#include <GuiConstants.au3>
#include <File.au3>

;File Install
If Not FileExists('Icon.ico') Then 
    FileInstall('Icon.ico', @TempDir & '\Icon.ico')
    $Icon = @TempDir & '\Icon.ico'
Else
    $Icon = 'Icon.ico'
EndIf


;Variables
$Width = IniRead('SimplePad.dat', 'Size', 'Width', -1)
$Height = IniRead('SimplePad.dat', 'Size', 'Height', -1)
$Left = IniRead('SimplePad.dat', 'Location', 'Left', -1)
$Top = IniRead('SimplePad.dat', 'Location', 'Top', -1)
$Style = IniRead('SimplePad.dat', 'Styles', 'Style', BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX))
$ExStyle = IniRead('SimplePad.dat', 'Styles', 'ExStyle', BitOR($WS_EX_ACCEPTFILES, $WS_EX_CLIENTEDGE))
$Folder = IniRead('SimplePad.dat', 'Misc', 'Folder', @MyDocumentsDir)

;Create SimplePad.dat if not already exsist
If $Width = -1 Or $Height = -1 Or $Left = -1 Or $Top = -1 Then
    $TempGui = GUICreate('', -1, -1, -1, -1)
    GUISetState()
    While WinActive($TempGui)
        $Pos = WinGetPos($TempGui)
        ExitLoop
    WEnd
    WinClose($TempGui)
    IniWrite('SimplePad.dat', 'Size', 'Width', $Pos[2])
    IniWrite('SimplePad.dat', 'Size', 'Height', $Pos[3])
    IniWrite('SimplePad.dat', 'Location', 'Left', $Pos[0])
    IniWrite('SimplePad.dat', 'Location', 'Top', $Pos[1])
    If @Compiled = 1 Then Run(@ScriptFullPath)
    If @Compiled = 0 Then Run(@AutoItExe & ' ' & @ScriptName)
EndIf

;HotKeys
HotKeySet("{TAB}", "_Tab"); Fix Tab not inserting tab bug

;GUI
$Gui = GUICreate('L.a.c. SimplePad', $Width, $Height, $Left, $Top, $Style, $ExStyle)
GUISetIcon($Icon)
Menus()
$Edit = GUICtrlCreateEdit('', 0, 0, $Width, $Height, BitOR($ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetState($Edit, $GUI_DROPACCEPTED)
GUICtrlSetResizing($Edit, $GUI_DOCKBORDERS)

GUISetState()
While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit
            $Pos = WinGetPos($Gui)
            IniWrite('SimplePad.dat', 'Size', 'Width', $Pos[2])
            IniWrite('SimplePad.dat', 'Size', 'Height', $Pos[3])
            IniWrite('SimplePad.dat', 'Location', 'Left', $Pos[0])
            IniWrite('SimplePad.dat', 'Location', 'Top', $Pos[1])
            IniWrite('SimplePad.dat', 'Misc', 'Folder', $Folder)
            Exit
        Case $Msg = $New
            _New()
        Case $Msg = $Open
            $File = _Open()
            $Folder = StringReplace($File, StringTrimLeft($File, StringInStr($File, '\', 0, -1) - 1), '')
            IniWrite('SimplePad.dat', 'Misc', 'Folder', $Folder)
        Case $Msg = $Save
            _Save()
        Case $Msg = $SaveAs
            _SaveAs()
        Case $Msg = $Print
            _Print()
        Case $Msg = $Help
            _Help()
        Case $Msg = $About
            _About()
    EndSelect
WEnd

;Functions
Func Menus()
    ;File Menu
    Global $File = GUICtrlCreateMenu('File')
    Global $New = GUICtrlCreateMenuItem('New', $File)
    Global $Open = GUICtrlCreateMenuItem('Open...', $File)
    Global $Save = GUICtrlCreateMenuItem('Save', $File)
    Global $SaveAs = GUICtrlCreateMenuItem('Save As...', $File)
    Global $SaveToWeb = GUICtrlCreateMenuItem('Save To Web...', $File)
    GUICtrlCreateMenuBreak($File)
    Global $Print = GUICtrlCreateMenuItem('Print...', $File)
    GUICtrlCreateMenuBreak($File)
    Global $Exit = GUICtrlCreateMenuItem('Exit', $File)
    
    
    ;Help
    Global $HelpM = GUICtrlCreateMenu('Help')
    Global $Help = GUICtrlCreateMenuItem('Help', $HelpM)
    GUICtrlCreateMenuBreak($HelpM)
    Global $About = GUICtrlCreateMenuItem('About', $HelpM)
EndFunc   ;==>Menus

Func GUICtrlCreateMenuBreak($s_Menu)
    GUICtrlCreateMenuItem('', $s_Menu)
EndFunc   ;==>GUICtrlCreateMenuBreak

Func _Tab()
    Send('{CTRLDOWN}{TAB}{CTRLUP}')
EndFunc   ;==>_Tab

Func _New()
    $Erase = MsgBox(276, "New...", "Are you sure you want to start a new file?" & @CRLF & "This will erase your old text" & @CRLF & @CRLF & "(If you have already saved your document" & @CRLF & "you don't have to worry)")
    If $Erase = 6 Then GUICtrlSetData($Edit, '')
    Send('{RIGHT}')
EndFunc   ;==>_New

Func _Open()
    $File = FileOpenDialog('Open File', $Folder, 'Text Files (*.txt)', 3)
    $Read = FileRead($File)
    GUICtrlSetData($Edit, $Read)
    Return $File
EndFunc   ;==>_Open

Func _Save()
    If IsDeclared('File') Then
        FileOpen($File, 2)
        FileWrite($File, GUICtrlRead($Edit))
    Else
        _SaveAs()
    EndIf
EndFunc   ;==>_Save

Func _SaveAs()
    $File = FileSaveDialog('Save File', $Folder, 'Text Files (*.txt)', 16)
    FileOpen($File, 2)
    FileWrite($File, GUICtrlRead($Edit))
EndFunc   ;==>_SaveAs

Func _Print()
    $Temp = _TempFile(@TempDir, '~', '.txt')
    FileOpen($Temp, 2)
    FileWrite($Temp, GUICtrlRead($Edit))
    $Print = _FilePrint($Temp)
    If $Print Then
        MsgBox(0, 'Printing...', 'Note is being printed')
    Else
        MsgBox(0, 'Error', @error & @CRLF & 'The file was not printed.')
    EndIf
EndFunc   ;==>_Print

Func _Help()
    MsgBox(0, 'Help', 'Not available in beta')
EndFunc   ;==>_Help

Func _About()
    MsgBox(0, 'About', 'Not available in beta')
EndFunc   ;==>_About

Func RandomString($sLenght)
    Local $Return
    For $x = 1 To $sLenght
        $Return &= Chr(Random(65, 90, 1))
    Next
    Return $Return
EndFunc   ;==>RandomString

Any help would be greatly appreciated

Try removing the style $ES_AUTOHSCROLL from the edit.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks that worked

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0