Jump to content
Sign in to follow this  
Andreik

What is wrong in my function?

Recommended Posts

Andreik

Func ColorTextBox($title,$text,$color)
    Local $L_TEXT = StringLen($text)
    Local $ROW = Int(Number($L_TEXT) / 45) + 1
    Local $GUI = GUICreate($title,300,15*Number($ROW) + 30,-1,-1)
    Local $FIELD = GUICtrlCreateLabel($text,5,5,290,150,0x01)
    Local $OK = GUICtrlCreateButton("OK",130,15*Number($ROW) + 5,40,20)
    GUICtrlSetColor ($FIELD,$color)
    GUISetState(@SW_SHOW,$GUI)
    While 1
        Local $MSG = GUIGetMsg()
        If $MSG = $OK Then 
        GUIDelete($GUI)
        ExitLoop
        EndIf
    WEnd
EndFunc

$MESSAGE = "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI.  It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys)."
ColorTextBox("Test colors",$MESSAGE,0xFF00FF)
ColorTextBox("Test colors",$MESSAGE,0x0000FF)
ColorTextBox("Test colors",$MESSAGE,0x00FF00)
ColorTextBox("Test colors",$MESSAGE,0xFF0000)
ColorTextBox("Test colors",$MESSAGE,0xC8C8C8)

What is wrong with OK button?


When the words fail... music speaks

Share this post


Link to post
Share on other sites
zorphnog

Your label and button controls are overlapping. Try:

Func ColorTextBox($title,$text,$color)
    Local $L_TEXT = StringLen($text)
    Local $ROW = Int(Number($L_TEXT) / 45) + 1
    Local $GUI = GUICreate($title,300,15*Number($ROW) + 30,-1,-1)
    Local $FIELD = GUICtrlCreateLabel($text,5,5,290,15*Number($ROW),0x01)
    Local $OK = GUICtrlCreateButton("OK",130,15*Number($ROW) + 5,40,20)
    GUICtrlSetColor ($FIELD,$color)
    GUISetState(@SW_SHOW,$GUI)
    While 1
        Local $MSG = GUIGetMsg()
        If $MSG = $OK Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
    WEnd
EndFunc

$MESSAGE = "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI.  It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys)."
ColorTextBox("Test colors",$MESSAGE,0xFF00FF)
ColorTextBox("Test colors",$MESSAGE,0x0000FF)
ColorTextBox("Test colors",$MESSAGE,0x00FF00)
ColorTextBox("Test colors",$MESSAGE,0xFF0000)
ColorTextBox("Test colors",$MESSAGE,0xC8C8C8)

Share this post


Link to post
Share on other sites
Andreik

Your label and button controls are overlapping. Try:

Func ColorTextBox($title,$text,$color)
    Local $L_TEXT = StringLen($text)
    Local $ROW = Int(Number($L_TEXT) / 45) + 1
    Local $GUI = GUICreate($title,300,15*Number($ROW) + 30,-1,-1)
    Local $FIELD = GUICtrlCreateLabel($text,5,5,290,15*Number($ROW),0x01)
    Local $OK = GUICtrlCreateButton("OK",130,15*Number($ROW) + 5,40,20)
    GUICtrlSetColor ($FIELD,$color)
    GUISetState(@SW_SHOW,$GUI)
    While 1
        Local $MSG = GUIGetMsg()
        If $MSG = $OK Then
            GUIDelete($GUI)
            ExitLoop
        EndIf
    WEnd
EndFunc

$MESSAGE = "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI.  It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys)."
ColorTextBox("Test colors",$MESSAGE,0xFF00FF)
ColorTextBox("Test colors",$MESSAGE,0x0000FF)
ColorTextBox("Test colors",$MESSAGE,0x00FF00)
ColorTextBox("Test colors",$MESSAGE,0xFF0000)
ColorTextBox("Test colors",$MESSAGE,0xC8C8C8)
Thanks zorphnog! :)

When the words fail... music speaks

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  

×