Jump to content

Gui Edit Box Counter & Constrained/Wordwrapped text


Hyflex
 Share

Recommended Posts

Hey,

I've got a few things what I'm trying to do but I have no idea how to do them... Here is part of my code

$StatusBar = _GUICtrlStatusBar_Create($PostMe)
_GUICtrlStatusBar_SetMinHeight($StatusBar, 20)
$Button_PAll = GUICtrlCreateButton("PAll", 5, 330, 433, 50)
$Edit_TextToPost = GUICtrlCreateEdit("", 10, 10, 425, 315, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_BORDER))
GUICtrlSetData(-1, "")
GUICtrlSetLimit($Edit_TextToPost,1244)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1

;_GUICtrlStatusBar_SetText($StatusBar, )

$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

I'm trying to add a counter which counts down from 1244 characters, every time a character is added to the Edit box and for it to auto-update using the status bar so if I was to have the word: "dog" in the edit box the status bar would appear: Characters left: 1241

I also have an issue with the status bar not being "constrained"/wordwrapped if I type loads it just goes off to the right, I want it to move down move down

instead of this happening where it goes on and on and on and on and on and on

it would look like this

where it goes to the next

line after as soon as it hits

the edge of the box

Any help would be greatly appreciated. I've got a awful headache trying to work this out but nothing has worked. Edited by XxXGoD
Link to comment
Share on other sites

Try this

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
$chars = 200
$hGui = GUICreate( "Edit", 445, 365, 590, 200 )
$idEdit = GUICtrlCreateEdit("", 10, 10, 425, 315, $ES_WANTRETURN)
$hEdit = GUICtrlGetHandle( $idEdit )
GUICtrlSetLimit($idEdit,$chars)
$label = GUICtrlCreateLabel ( $chars, 10, 335, 50, 20 )
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode
$hWndFrom = $ilParam
$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low word
$iCode = BitShift($iwParam, 16)   ; High word
Switch $hWndFrom
  Case $hEdit
   Switch $iCode
    Case $EN_CHANGE
     $textLen = StringLen( GUICtrlRead( $idEdit ) )
     $charsLeft = $chars - $textLen
     GUICtrlSetData( $label, $charsLeft )
   EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
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...