Sign in to follow this  
Followers 0
E1M1

Edit - wordw wrap problems

7 posts in this topic

#1 ·  Posted (edited)

hi, I have problem, I want to add word warp option to my edit control.1)when I create Edit with $ES_MULTILINE then word wrap wokks, but I cant use enter.

2) if i set $ES_MULTILINE style later, word wrap won't wok and i also cant use enter.

1)

$Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445,$ES_MULTILINE)

2)

GUICtrlSetStyle ( $Edit1, $ES_MULTILINE)
Edited by E1M1

edited

Share this post


Link to post
Share on other sites



hi, I have problem, I want to add word warp option to my edit control.1)when I create Edit with $ES_MULTILINE then word wrap wokks, but I cant use enter.

2) if i set $ES_MULTILINE style later, word wrap won't wok and i also cant use enter.

1)

$Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445,$ES_MULTILINE)

2)

GUICtrlSetStyle ( $Edit1, $ES_MULTILINE)
You want $ES_WANTRETURN style also.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks, but when I click on word wrap menu, word wrap will not apply to previously typed lines. :D

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiStatusBar.au3>

$Form1 = GUICreate("Untitled - Notepad", 640, 480, 212, 164,0x14CF0000,0x00000110)
GUISetIcon("C:\WINDOWS\NOTEPAD.EXE")
;~ $Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445,$ES_MULTILINE,$ES_WANTRETURN)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
GUICtrlSetData(-1, "Edit1332432121121313"&@CRLF&"lol")
GUICtrlSetCursor (-1, 5)
$Format = GUICtrlCreateMenu("F&ormat")
$wordwrap = GUICtrlCreateMenuItem("&Word Wrap...", $Format)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $wordwrap
            GUICtrlSetStyle ( $Edit1, $ES_MULTILINE+$ES_WANTRETURN)
    EndSwitch
WEnd

edited

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks, but when I click on word wrap menu, word wrap will not apply to previously typed lines. :D

#include <EditConstants.au3>
   #include <GUIConstantsEx.au3>
   #include <StaticConstants.au3>
   #include <WindowsConstants.au3>
   #Include <GuiStatusBar.au3>
   
   $Form1 = GUICreate("Untitled - Notepad", 640, 480, 212, 164,0x14CF0000,0x00000110)
   GUISetIcon("C:\WINDOWS\NOTEPAD.EXE")
;~ $Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445,$ES_MULTILINE,$ES_WANTRETURN)
   $Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445)
   GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
   GUICtrlSetData(-1, "Edit1332432121121313"&@CRLF&"lol")
   GUICtrlSetCursor (-1, 5)
   $Format = GUICtrlCreateMenu("F&ormat")
   $wordwrap = GUICtrlCreateMenuItem("&Word Wrap...", $Format)
   GUISetState(@SW_SHOW)
   While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
           Case $GUI_EVENT_CLOSE
               Exit
           Case $wordwrap
               GUICtrlSetStyle ( $Edit1, $ES_MULTILINE+$ES_WANTRETURN)
       EndSwitch
   WEnd
I have had the same problem. I concluded that once an edit is created you cannot change its word wrap style, so I did something like this

#include <EditConstants.au3>
  #include <GUIConstantsEx.au3>
  #include <StaticConstants.au3>
  #include <WindowsConstants.au3>
  #Include <GuiStatusBar.au3>
  
  $Form1 = GUICreate("Untitled - Notepad", 640, 480, 212, 164,0x14CF0000,0x00000110)
  GUISetIcon("C:\WINDOWS\NOTEPAD.EXE")
;~ $Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445,$ES_MULTILINE,$ES_WANTRETURN)
  $Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445)
  GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
  GUICtrlSetData(-1, "Edit1332432121121313"&@CRLF&"lol")
  GUICtrlSetCursor (-1, 5)
  $Format = GUICtrlCreateMenu("F&ormat")
  $wordwrap = GUICtrlCreateMenuItem("&Word Wrap...", $Format)
  GUISetState(@SW_SHOW)
  While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
          Case $GUI_EVENT_CLOSE
              Exit
          Case $wordwrap
               $text = GUICtrlRead($Edit1)
            GUICtrlDelete($Edit1)
            $Edit = GUICtrlCreateEdit($Text, 0, 0, 640, 445,BitOR($ES_MULTILINE,$ES_WANTRETURN))
      EndSwitch
  WEnd

Edit:Corrected error. GuiCtrlDelete($Edit1) was GuiDelete($Edit1), and simplified a bit.

Edited by martin

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

I thought about It, and had question: what if user had resized GUI previously?

I need edit control width = guiWidth and edit height = GUIHeight - 15


edited

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I thought about It, and had question: what if user had resized GUI previously?

I need edit control width = guiWidth and edit height = GUIHeight - 15

Use....

WinGetPos ( "title" [, "text"] )

Parameters

title The title of the window to read. See Title special definition.

text [optional] The text of the window to read.

Return Value

Success: Returns a 4-element array containing the following information:

$array[0] = X position

$array[1] = Y position

$array[2] = Width

$array[3] = Height

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I thought about It, and had question: what if user had resized GUI previously?

I need edit control width = guiWidth and edit height = GUIHeight - 15

As Valuater says, or you could just use ControlGetPos and use the values returned directly in the GuiCtrlCreateEdit

#include <EditConstants.au3>
  #include <GUIConstantsEx.au3>
  #include <StaticConstants.au3>
  #include <WindowsConstants.au3>
  #Include <GuiStatusBar.au3>

  $Form1 = GUICreate("Untitled - Notepad", 640, 480, 212, 164,0x14CF0000,0x00000110)
  GUISetIcon("C:\WINDOWS\NOTEPAD.EXE")
;~ $Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445,$ES_MULTILINE,$ES_WANTRETURN)
  $Edit1 = GUICtrlCreateEdit("", 0, 0, 640, 445)
  GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
  GUICtrlSetData(-1, "Edit1332432121121313"&@CRLF&"lol")
  GUICtrlSetCursor (-1, 5)
  $Format = GUICtrlCreateMenu("F&ormat")
  $wordwrap = GUICtrlCreateMenuItem("&Word Wrap...", $Format)
  GUISetState(@SW_SHOW)
  While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
          Case $GUI_EVENT_CLOSE
              Exit
          Case $wordwrap
               $text = GUICtrlRead($Edit1)
               $ep = ControlGetPos($Form1,"",$Edit1)
            GUICtrlDelete($Edit1)
            $Edit = GUICtrlCreateEdit($Text,$ep[0],$ep[1],$ep[2],$ep[3],BitOR($ES_MULTILINE,$ES_WANTRETURN))
      EndSwitch
WEnd

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

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