Jump to content

Can't use Rich text control


Recommended Posts

Hi, I'm a newbie and my english is bad , so it's difficult to understand, sorry!

So, my code

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt('MustDeclareVars', 1)
Main()
Func Main()
Local $hGui, $hRichEdit, $iMsg
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName,4) &")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
   BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
GUISetState()

While True
  $iMsg = GUIGetMsg()
  Select
   Case $iMsg = $GUI_EVENT_CLOSE
    GUIDelete()
    Exit
   EndSelect
  if _IsPressed ('0D') Then
   _GuiCtrlRichEdit_AppendText($hRichEdit, @CR & "This is appended text.")
  EndIf
WEnd
EndFunc   ;==>Main

When i presses Enter key, "This is appended text" is repeated many times, I do not want such, so please fix it.

Thank.

Link to comment
Share on other sites

If you only want the text to be appended once then you need to wait until the key is no longer pressed before continuing.

Like this:

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt('MustDeclareVars', 1)

Main()

Func Main()
  Local $hGui, $hRichEdit, $iMsg
  $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName,4) &")", 320, 350, -1, -1)
  $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _  
  BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
  GUISetState()

  While True
    $iMsg = GUIGetMsg()
    Select
      Case $iMsg = $GUI_EVENT_CLOSE
        GUIDelete()
        Exit
      EndSelect
    if _IsPressed ('0D') Then
      _GuiCtrlRichEdit_AppendText($hRichEdit, @CR & "This is appended text.")
      while _IsPressed ('0D')
      WEnd
    EndIf
  WEnd
EndFunc ;==>Main
Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...