Jump to content

Label/text - Hyperlink


Recommended Posts

I use a function similiar to MsgBox to support scrollbar by MrCreatoR found >here

$Text = ""
For $i = 1 To 30
    $Text &= "Line " & $i & @CRLF
Next
$Text = StringTrimRight($Text, 1) ;Strip the last @CRLF

_MsgBoxScrollable(104, "Test - No Scroll Bars", $Text)

;And now we look how the msgbox expanded with scroll bars (lots of text :D) ...

$Text = ""
For $i = 1 To 150
    $Text &= "Line " & $i & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & ", More text, And some More text" & @CRLF
Next
$Text = StringTrimRight($Text, 1) ;Strip the last @CRLF

_MsgBoxScrollable(104, "Test - With Scroll Bars", $Text)

Func _MsgBoxScrollable($mb_Icon, $mb_Title, $mb_Text, $mb_Time = '')
    Local $StrnLenText = LongestStringLen($mb_Text)
    Local $NumberOfLines = (UBound(StringSplit($mb_Text, @CRLF)) - 1) * 6.5
    If (160 + $NumberOfLines) >= @DesktopHeight Then $NumberOfLines = @DesktopHeight - 200
    If $StrnLenText + 150 >= @DesktopWidth - 200 Then $StrnLenText = @DesktopWidth - 200
    Local $Button1Txt = "OK"
    Local $Button2Txt = "Cancel"
    Local $MsgValue = 0
    Local $Timer = ''
    Local $ScrollLabel1 = -1, $ScrollLabel2 = -1
    Local $iMsgBox = GUICreate($mb_Title, $StrnLenText + 150, 100 + $NumberOfLines, -1, -1, 0x00400000, 0x00000008)
    
    Local $DefaultEditStyle = 0
    If $NumberOfLines >= (@DesktopHeight - 200) Or $StrnLenText + 150 >= 200 Then $DefaultEditStyle = 3150016
    Local $Edit = GUICtrlCreateEdit($mb_Text, 60, 10, $StrnLenText + 80, $NumberOfLines + 30, _
        BitOr($DefaultEditStyle, 64+128+2048+4), 0x990)
    Local $IconID = GUICtrlCreateIcon(@SystemDir & "\User32.dll", $mb_Icon, 10, 10, 35, 35)
    $Button1 = GUICtrlCreateButton($Button1Txt, 10 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen($Button1Txt), 25)
    $Button2 = GUICtrlCreateButton($Button2Txt, 80 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen($Button2Txt), 25)
    
    If $NumberOfLines = (@DesktopHeight - 200) Then
        $ScrollLabel1 = GUICtrlCreateLabel("т", 40, ((100 + $NumberOfLines)/2)+20, 20)
        GUICtrlSetTip(-1, "Click here to jump Down")
        GUICtrlSetFont(-1, 18, 600, 0, "Wingdings")
        $ScrollLabel2 = GUICtrlCreateLabel("с", 40, ((100 + $NumberOfLines)/2)-20, 20)
        GUICtrlSetTip(-1, "Click here to jump UP")
        GUICtrlSetFont(-1, 18, 600, 0, "Wingdings")
    EndIf
    
    GUISetState()
    If $mb_Time <> 0 Then $Timer = TimerInit()
    ControlFocus($iMsgBox, "", $IconID)
    
    While 1
        $imsg = GUIGetMsg()
        Select
            Case $imsg = $Button1
                $MsgValue = 6
                ExitLoop
            Case $imsg = $Button2
                $MsgValue = 7
                ExitLoop
            Case $imsg = $ScrollLabel1
                ControlSend($iMsgBox, "", $Edit, "{PgDn}")
                ControlFocus($iMsgBox, "", $IconID)
            Case $imsg = $ScrollLabel2
                ControlSend($iMsgBox, "", $Edit, "{PgUp}")
                ControlFocus($iMsgBox, "", $IconID)
            Case $mb_Time <> 0
                If TimerDiff($Timer) / 1000 >= $mb_Time Then ExitLoop
        EndSelect
    WEnd
    GUIDelete($iMsgBox)
    Return $MsgValue
EndFunc

Func LongestStringLen($sText)
    Local $BiggestStr = 0
    Local $sSplit = StringSplit($sText, @CRLF)
    
    For $i = 1 To UBound($sSplit)-1
        If StringLen($sSplit[$i]) > $BiggestStr Then $BiggestStr = StringLen($sSplit[$i])
    Next
    
    Return Round(($BiggestStr*2)+($BiggestStr/4))
EndFunc

 

It has been served me very well.

I would like to enhance it to allow me to add a hyperlink on some text.

So if I pass text like this:

[autoit]
$Text = "click <a href="http://www.mywebsite.com>here</a> for details"
[/autoit]

It will display word "here" as a hyperlink to http://www.mywebsite.com

Thank you!!

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