Jump to content

GUI with 2 hyperlinks: the 2nd line disappears when clicking a link on the first line


 Share

Recommended Posts

Hi all,

I have created a GUI that includes two hyperlinks, using GUI Hyperlink control.

There are two lines in this GUI, and both of them have an hyperlink.

When running the script, if I click on the hyperlink on the 2nd line, no problem.

But if I click on the hyperlink on the 1st line, then the 2nd line disappears.

Here is the script (I am attaching modified versions of Events.au3 and GuiHyperLink.au3 as the original ones do not work anymore as explained at the end of this discussion.

Any idea?

#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GuiHyperLink.au3>
#include <Events.au3>

Local $Links[2] = ["http://www.google.com", "http://www.cnn.com"]
Local $Link_On[2] = ["google", "CNN"]
Local $hl_ctrl[2]
$Form1 = GUICreate("Test", 408, 150, -1, -1)

$hl_ctrl[0] = _GuiCtrlHyperLinkCreate ($Form1, _
            'Click Google', _
            $Links[0], $Link_On[0], _
            10, 10, 384, 40)

_GuiCtrlHyperLinkSetFont ($hl_ctrl[0], "MS Sans Serif", 14, 800, False)

$hl_ctrl[1] = _GuiCtrlHyperLinkCreate ($Form1, _
            'Click CNN', _
            $Links[1], $Link_On[1], _
            12, 32, 350, 40)

_GuiCtrlHyperLinkSetFont ($hl_ctrl[1], "MS Sans Serif", 14, 800, False)

$Next = GUICtrlCreateButton("Next", 167, 112, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
WinSetOnTop ( "Test", "", 1 )

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
    $Msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    Case $msg = $Next
            ExitLoop
    EndSelect
WEnd

GUIDelete ( $Form1 )
Exit

Events.au3

GuiHyperLink.au3

Edited by Akshay07
Link to comment
Share on other sites

Hi all,

I have created a GUI that includes two hyperlinks, using GUI Hyperlink control.

There are two lines in this GUI, and both of them have an hyperlink.

When running the script, if I click on the hyperlink on the 2nd line, no problem.

But if I click on the hyperlink on the 1st line, then the 2nd line disappears.

Here is the script (I am attaching modified versions of Events.au3 and GuiHyperLink.au3 as the original ones do not work anymore as explained at the end of this discussion.

Any idea?

#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GuiHyperLink.au3>
#include <Events.au3>

Local $Links[2] = ["http://www.google.com", "http://www.cnn.com"]
Local $Link_On[2] = ["google", "CNN"]
Local $hl_ctrl[2]
$Form1 = GUICreate("Test", 408, 150, -1, -1)

$hl_ctrl[0] = _GuiCtrlHyperLinkCreate ($Form1, _
            'Click Google', _
            $Links[0], $Link_On[0], _
            10, 10, 384, 40)

_GuiCtrlHyperLinkSetFont ($hl_ctrl[0], "MS Sans Serif", 14, 800, False)

$hl_ctrl[1] = _GuiCtrlHyperLinkCreate ($Form1, _
            'Click CNN', _
            $Links[1], $Link_On[1], _
            12, 32, 350, 40)

_GuiCtrlHyperLinkSetFont ($hl_ctrl[1], "MS Sans Serif", 14, 800, False)

$Next = GUICtrlCreateButton("Next", 167, 112, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
WinSetOnTop ( "Test", "", 1 )

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
    $Msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    Case $msg = $Next
            ExitLoop
    EndSelect
WEnd

GUIDelete ( $Form1 )
Exit

I dont understand why you cant use ShellExecute if you want to open it into a browser, but nevertheless, the solution was one of those ones where you will kick yourself...

the height of the first control is too high...when you click on it, it just overlaps the second control so you cant see it...just change the height of the label which says, "Click Google", to 20, and it is all fine!

Instant Lockerz Invite - www.instantlockerzinvite.co.uk
Link to comment
Share on other sites

I dont understand why you cant use ShellExecute if you want to open it into a browser, but nevertheless, the solution was one of those ones where you will kick yourself...

the height of the first control is too high...when you click on it, it just overlaps the second control so you cant see it...just change the height of the label which says, "Click Google", to 20, and it is all fine!

That is a quick and effective answer, it works :D

Regarding the use of ShellExecute, I don't know how this works. I asked in a previous thread how I could insert a hyperlink into a GUI, and I was redirected to this GUI Hyperlink control discussion.

For my own learning, could you please elaborate a bit more about what you mean by using ShellExecute? I'm always willing to learn :huggles:

I'll also look for ShellExecute in Autoit Help.

Link to comment
Share on other sites

The problem is your choice of dimensions and thier placement. They are overlapping.

10, 10, 384, 40

12, 32, 350, 40

you have a depth of 40 but your 2nd button is only 22 below the 1st

so when you select the 1st, it covers the second.

changing 40 to 20 would solve the issue.


ShellExecute('http://www.google.com')

The above will open the the users default web browser to navigate to the url specified.

Edited by Shark007
Link to comment
Share on other sites

Here's a quick example to show you how the concept works. Run this script and click on a label in the GUI.

Local $hGUI = GUICreate("Test", 200, 100), $msg
Local $label_1 = GUICtrlCreateLabel("AutoIt", 10, 10, 50, 20)
Local $label_2 = GUICtrlCreateLabel("Google", 10, 50, 50, 20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $label_1
            ShellExecute("http://www.autoitscript.com/autoit3/")
        Case $label_2
            ShellExecute("http://www.google.com/")
    EndSwitch
WEnd

Just read the script (did not try it). If I understand it, it seems that if I click on $label_1, it will open http://www.autoitscript.com/autoit3. But what I want to do is clicking on one word or one set of words in $label_1 to open this hyperlink.

For example, label_1 = "Click on AutoIt" should open http://www.autoitscript.com/autoit3 only if the user clicks on the (visible) hyperlink "AutoiIt" ("Click on AutoIt), and not on the full label.

That's why I used GUI Hyperlink control.

Edited by Akshay07
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...