Jump to content

About GUICtrlSetLimit?


youtuber
 Share

Recommended Posts

  • Moderators

Without any context, how is anyone supposed to help?

  • Why do you feel you need to limit the number of characters?
  • And if you're going to limit the number of characters, why put in the max, as that simply defeats the purpose?

Please explain more about what you're trying to do.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

You're missing the point. If you don't want to limit the characters, then just don't use GUICtrlSetLimit at all. If you search the forum I know the question about control text limits has been asked before, IIRC it was 65,535 bytes for a multi-line. Needless to say they are high enough for someone to add a lot of text without concerns for running out of room.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

youtuber,

Edit controls are one of 5 controls that this function applies to.  However, I have curious in the past as to how to use this function with an edit control beyond just setting the limit to an impossible value.

@JL - Can you run this code.  I'm probably misunderstanding something but this seems to demonstrate that you can affect the limit but not monitor it. 

#include <String.au3>

Local $gui = GUICreate('Limit Test')
Local $edit010 = GUICtrlCreateEdit('', 05, 10, 390, 360)
GUICtrlSetLimit(-1, 100)
Local $status = GUICtrlCreateLabel('', 05, 385, 390, 20)
GUISetState()

Local $str = _StringRepeat(Chr(Random(65, 90, 1)), 48) & @CRLF, $icnt = 0, $ret = 0
ConsoleWrite(stringlen($str) & @CRLF)

While GUIGetMsg() <> -3
    $ret = GUICtrlSetData($edit010, $str, 1)
    If $ret <> 1 Then Exit MsgBox(17, 'Limit Reached', 'Edit control limit = ' & $icnt, 5)
    GUICtrlSetData($status, $icnt)
    $icnt += 100
WEnd

 kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

@InnIYeah, I guess that worked GUICtrlSendMsg($Edit1, $EM_LIMITTEXT, -1, 0) :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 502, 477, 242, 100)
$Edit1 = GUICtrlCreateEdit("" & @CRLF, 32, 48, 201, 353, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
GUICtrlSendMsg($Edit1, $EM_LIMITTEXT, -1, 0)
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 248, 48, 225, 353, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Test", 32, 424, 75, 25)
$Label1 = GUICtrlCreateLabel("", 176, 424, 52, 17)
GUISetState(@SW_SHOW)

Local $lines0
While 1
     $lines = ControlCommand($Form1, "", $Edit1, "GetLineCount")

     If $lines <> $lines0 Then
        guictrlsetdata($Label1, $lines)
        $lines0 = $lines
EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

     Case $Button1

         For $i = 1 To 10000 Step 1
             GUICtrlSetData($Edit1, $i & @CRLF, 1)
             GUICtrlSetData($Edit2, $i & @CRLF, 1)
         Next
    EndSwitch
WEnd
Spoiler

o6E5qk.png

 

 

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...