 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
AGermanUser
Joined: 12 Feb 2005 Posts: 81
|
Posted: Thu Nov 10, 2005 4:22 pm Post subject: Gui & Hyperlink |
|
|
Thx to shimanov there is a workaround for displaying URLs in a gui.
I thought it's better to post here again so that it doesn't get lost in the "Ask for Help" section.
Important point is, the associated variable of the control must start with URL in order to work.
| Code: | Gui, Margin, 5, 5
Gui, Add, Text, xm ym, Multiple URLs in one GUI
Gui, Add, Text, xp+8 yp+25 cBlue gLink1 vURL_Link1, www.autohotkey.com
Gui, Add, Text, xp yp+20 cBlue gLink2 vURL_Link2, de.autohotkey.com
Gui, Add, Text, xp yp+20 cBlue gLink3 vURL_Link3, www.google.com
Gui, Add, Text, xp yp+20 cBlue gLink4 vURL_Link4, www.msdn.com
Gui, Font, norm
Gui, Show,, URL
; Retrieve scripts PID
Process, Exist
pid_this := ErrorLevel
; Retrieve unique ID number (HWND/handle)
WinGet, hw_gui, ID, ahk_class AutoHotkeyGUI ahk_pid %pid_this%
; Call "HandleMessage" when script receives WM_SETCURSOR message
WM_SETCURSOR = 0x20
OnMessage(WM_SETCURSOR, "HandleMessage")
; Call "HandleMessage" when script receives WM_MOUSEMOVE message
WM_MOUSEMOVE = 0x200
OnMessage(WM_MOUSEMOVE, "HandleMessage")
Return
GuiClose:
ExitApp
;######## End of GUI ###########################################################
;######## GUI glabels ##########################################################
Link1:
Run, http://www.autohotkey.com/forum
Return
Link2:
Run, http://de.autohotkey.com
Return
Link3:
Run, http://www.google.com
Return
Link4:
Run, http://www.msdn.com
Return
;######## End Of GUI glabels ###################################################
;######## Function #############################################################
HandleMessage(p_w, p_l, p_m, p_hw)
{
global WM_SETCURSOR, WM_MOUSEMOVE,
static URL_hover, h_cursor_hand, h_old_cursor, CtrlIsURL, LastCtrl
If (p_m = WM_SETCURSOR)
{
If URL_hover
Return, true
}
Else If (p_m = WM_MOUSEMOVE)
{
; Mouse cursor hovers URL text control
StringLeft, CtrlIsURL, A_GuiControl, 3
If (CtrlIsURL = "URL")
{
If URL_hover=
{
Gui, Font, cBlue underline
GuiControl, Font, %A_GuiControl%
LastCtrl = %A_GuiControl%
h_cursor_hand := DllCall("LoadCursor", "uint", 0, "uint", 32649)
URL_hover := true
}
h_old_cursor := DllCall("SetCursor", "uint", h_cursor_hand)
}
; Mouse cursor doesn't hover URL text control
Else
{
If URL_hover
{
Gui, Font, norm cBlue
GuiControl, Font, %LastCtrl%
DllCall("SetCursor", "uint", h_old_cursor)
URL_hover=
}
}
}
}
;######## End Of Functions ##################################################### |
26.02.2007
+ Added support for more than one URL. _________________ Cheers
BBCodeWriter • ToDo-List • CopyPassage
Last edited by AGermanUser on Mon Feb 26, 2007 2:40 am; edited 4 times in total |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4031 Location: Pittsburgh
|
Posted: Fri Nov 11, 2005 5:20 am Post subject: |
|
|
| NICE! Do you know, why 0x2A1 = WM_MOUSEHOVER does not work? |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Fri Nov 11, 2005 5:48 am Post subject: |
|
|
| Laszlo wrote: | | NICE! Do you know, why 0x2A1 = WM_MOUSEHOVER does not work? |
It doesn't offer any advantages over monitoring WM_MOUSEMOVE. It would also needlessly complicate the program.
| MSDN wrote: |
The WM_MOUSEHOVER message is posted to a window when the cursor hovers over the client area of the window for the period of time specified in a prior call to TrackMouseEvent.
...
Hover tracking stops when WM_MOUSEHOVER is generated. The application must call TrackMouseEvent again if it requires further tracking of mouse hover behavior.
|
Most important. It does not implement the desired behavior of changing the cursor and underlining the text while the cursor remains within the context of the Text control (i.e., hover).
I would say the name WM_MOUSEHOVER is somewhat of a misnomer, since the behavior it implements is more and less than its name implies. It should be a specialized WM_MOUSEMOVE message, that acts as a filter given a specified context. |
|
| Back to top |
|
 |
Thalon
Joined: 12 Jul 2005 Posts: 640
|
Posted: Fri Nov 11, 2005 8:40 am Post subject: |
|
|
You are my hero!
(means Thanks)
I have a program now where I want to add a link into the about-box and I didn't know how to do
Thx,
Thalon _________________ AHK-Icon-Changer
AHK-IRC
deutsches Forum
SacredVault |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Fri Nov 11, 2005 9:46 am Post subject: |
|
|
| Thalon wrote: | You are my hero!
(means Thanks)
Thx,
Thalon |
I am assuming you are referring to me, since you wouldn't otherwise need to translate for AGermanUser.
| Quote: | I have a program now where I want to add a link into the about-box and I didn't know how to do  |
Can you explain what you don't know or where there is a problem? You should be able to use the code, as is, with some adjustments for your particular program.
You could also post the relevant code in the "Ask for Help" forum.
Oh, and one more thing. I am watching you too.
 |
|
| Back to top |
|
 |
Thalon
Joined: 12 Jul 2005 Posts: 640
|
Posted: Fri Nov 11, 2005 11:43 am Post subject: |
|
|
Yes, I referred to you
I did not know, but you solved my problem with this piece of code
It showed me also the advantage of the OnMessage-function, where I did never had a real look at. I will study it now with your example-code and maybe I can post a great script sometime in future... (but my normal programms are too special for sharing them (like my new gameserver-manager for the game "Sacred")...)
Thalon _________________ AHK-Icon-Changer
AHK-IRC
deutsches Forum
SacredVault |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4031 Location: Pittsburgh
|
Posted: Fri Nov 11, 2005 6:44 pm Post subject: |
|
|
How did you translate the neudeutsch sentence "No, I am a meat popsicle" to "Hi! How do you do"?
(I have not noticed that the last line on the sign constantly changes. Cool! How do you do that?) |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Fri Nov 11, 2005 10:58 pm Post subject: |
|
|
| Laszlo wrote: | How did you translate the neudeutsch sentence "No, I am a meat popsicle" to "Hi! How do you do"?
(I have not noticed that the last line on the sign constantly changes. Cool! How do you do that?) |
I don't. But they do. |
|
| Back to top |
|
 |
AGermanUser
Joined: 12 Feb 2005 Posts: 81
|
Posted: Mon Feb 26, 2007 2:11 am Post subject: |
|
|
As 'MiamiGuy' asked for a way to format more than one URL in a GUI, I spent some time with the problem and this is the solution I came up with.
This script supports more than one URL to be formatted underlined when hovered.
Important point is, the associated variable of the control must start with URL in order to work.
| Code: | Gui, Margin, 5, 5
Gui, Add, Text, xm ym, Multiple URLs in one GUI
Gui, Add, Text, xp+8 yp+25 cBlue gLink1 vURL_Link1, www.autohotkey.com
Gui, Add, Text, xp yp+20 cBlue gLink2 vURL_Link2, de.autohotkey.com
Gui, Add, Text, xp yp+20 cBlue gLink3 vURL_Link3, www.google.com
Gui, Add, Text, xp yp+20 cBlue gLink4 vURL_Link4, www.msdn.com
Gui, Font, norm
Gui, Show,, URL
; Retrieve scripts PID
Process, Exist
pid_this := ErrorLevel
; Retrieve unique ID number (HWND/handle)
WinGet, hw_gui, ID, ahk_class AutoHotkeyGUI ahk_pid %pid_this%
; Call "HandleMessage" when script receives WM_SETCURSOR message
WM_SETCURSOR = 0x20
OnMessage(WM_SETCURSOR, "HandleMessage")
; Call "HandleMessage" when script receives WM_MOUSEMOVE message
WM_MOUSEMOVE = 0x200
OnMessage(WM_MOUSEMOVE, "HandleMessage")
Return
GuiClose:
ExitApp
;######## End of GUI ###########################################################
;######## GUI glabels ##########################################################
Link1:
Run, http://www.autohotkey.com/forum
Return
Link2:
Run, http://de.autohotkey.com
Return
Link3:
Run, http://www.google.com
Return
Link4:
Run, http://www.msdn.com
Return
;######## End Of GUI glabels ###################################################
;######## Function #############################################################
HandleMessage(p_w, p_l, p_m, p_hw)
{
global WM_SETCURSOR, WM_MOUSEMOVE,
static URL_hover, h_cursor_hand, h_old_cursor, CtrlIsURL, LastCtrl
If (p_m = WM_SETCURSOR)
{
If URL_hover
Return, true
}
Else If (p_m = WM_MOUSEMOVE)
{
; Mouse cursor hovers URL text control
StringLeft, CtrlIsURL, A_GuiControl, 3
If (CtrlIsURL = "URL")
{
If URL_hover=
{
Gui, Font, cBlue underline
GuiControl, Font, %A_GuiControl%
LastCtrl = %A_GuiControl%
h_cursor_hand := DllCall("LoadCursor", "uint", 0, "uint", 32649)
URL_hover := true
}
h_old_cursor := DllCall("SetCursor", "uint", h_cursor_hand)
}
; Mouse cursor doesn't hover URL text control
Else
{
If URL_hover
{
Gui, Font, norm cBlue
GuiControl, Font, %LastCtrl%
DllCall("SetCursor", "uint", h_old_cursor)
URL_hover=
}
}
}
}
;######## End Of Functions ##################################################### |
Please check if you find a better solution and if yes, post it.  _________________ Cheers
BBCodeWriter • ToDo-List • CopyPassage |
|
| Back to top |
|
 |
MiamiGuy
Joined: 03 Nov 2006 Posts: 46 Location: Miami
|
Posted: Mon Feb 26, 2007 4:49 am Post subject: |
|
|
Holly Molly,
(I can actually hear a chorus of HALLELUJA) oh boy do I need help.
You dont know how much I've experimented with that, to no avail.
THANNNNK YOUUUUUU! Thats exactly what I was looking for. |
|
| Back to top |
|
 |
AHKPNH
Joined: 17 Feb 2006 Posts: 35
|
Posted: Tue Feb 27, 2007 9:57 pm Post subject: |
|
|
Very good.
Well done. |
|
| Back to top |
|
 |
MiamiGuy
Joined: 03 Nov 2006 Posts: 46 Location: Miami
|
Posted: Fri Mar 02, 2007 7:13 am Post subject: |
|
|
AGU, I have a question...
I'm using the code you posted with the function Handlemessage.
Basically, what I'm doing is a Gui, with 4 links. Thanks to you, now they become underlined when the mouse hovers. What those links do is open other gui windows in the same program. (Kind of reminiscent to the Control Panels window in Windows XP when you use the classic view.)
Anyway, I also have a button, which I was working on, which is basically a little arrow that when you click it, it minimizes the window. I asked SKA and he gave me an idea of where to start, but its another function, using the same WM_MOUSEMOVE, and I couldn't figure out how to make two different functions work with the same message. I started playing with your function again, and I got it to work, so that when you hover over a certain picture control, (bmp_Picture.bmp for example), I use GuiControl to change it to a lighter pic so it looks highlighted. However, the problem I"m having now is that no matter where I move the mouse on the gui, the picture of the arrow flickers. Is there something I'm doing wrong?
Look at your code and see where I added code for the arrow button, is there something I missed that would keep the image from flikering?
| Code: |
HandleMessage(p_w, p_l, p_m, p_hw)
{
global WM_SETCURSOR, WM_MOUSEMOVE,
static URL_hover, h_cursor_hand, h_old_cursor, CtrlIsURL, LastCtrl, CtrlIsbmp
If (p_m = WM_SETCURSOR)
{
If URL_hover
Return, true
}
Else If (p_m = WM_MOUSEMOVE)
{
;Mouse cursor hovers BMP picture control
StringLeft, CtrlIsbmp, A_GuiControl, 3
If (CtrlIsbmp = "bmp")
{
GuiControl,, bmp_RBU, RedButtonH.bmp
LastCtrl = %A_GuiControl%
}
;Mouse cursor doesn't hover BMP picture control
Else
{
GuiControl,, bmp_RBU, RedButtonU.bmp
}
;Mouse cursor hovers URL text control
StringLeft, CtrlIsURL, A_GuiControl, 3
If (CtrlIsURL = "URL")
{
If URL_hover=
{
Gui, Font, bold underline
GuiControl, Font, %A_GuiControl%
LastCtrl = %A_GuiControl%
h_cursor_hand := DllCall("LoadCursor", "uint", 0, "uint", 32649)
URL_hover := true
}
h_old_cursor := DllCall("SetCursor", "uint", h_cursor_hand)
}
; Mouse cursor doesn't hover URL text control
Else
{
If URL_hover
{
Gui, Font, norm cWhite bold
GuiControl, Font, %LastCtrl%
DllCall("SetCursor", "uint", h_old_cursor)
URL_hover=
}
}
}
} |
|
|
| Back to top |
|
 |
AGU Guest
|
Posted: Fri Mar 02, 2007 10:23 am Post subject: |
|
|
The problem with your current code is, that you're assigning a picture by GuiControl all the time you're moving the mouse. That's what is causing the flickering.
The problem is within this section:
| Code: | ;Mouse cursor doesn't hover BMP picture control
Else
{
GuiControl,, bmp_RBU, RedButtonU.bmp
} |
As you see, everytime you're moving the mouse, it sends a WM_MOUSEMOVE message. So it's assigning your unhovered button all the time. When you study the URL code of HandleMessage you can see this URL_hover variable. It's there because of this issue.
If you check the code, you'll see that URL_hover will be assigned "true" as long the mouse hovers the URL control. If it doesn't hover the URL anymore, the code jumps to the else block.
Within the else block is it checked if URL_hover is true. If so, it's doing some cleanup work and finally assigns URL_hover= (empty string).
Next MouseMove it doesn't hover the URL control, the check for URL_hover within the Else block fails. In this way, the function doesn't do anything.
So, you have to introduce a BMP_hover variable within your function to do the same thing for your BMP control. As you haven't posted your full code, I played a little bit with it. Therefore it's untested and more of a wild guess.
| Code: | HandleMessage(p_w, p_l, p_m, p_hw)
{
global WM_SETCURSOR, WM_MOUSEMOVE,
static URL_hover, BMP_hover, h_cursor_hand, h_old_cursor, CtrlType, LastCtrl
If (p_m = WM_SETCURSOR)
{
If URL_hover
Return, true
}
Else If (p_m = WM_MOUSEMOVE)
{
;Mouse cursor hovers BMP picture control
StringLeft, CtrlType, A_GuiControl, 3
If (CtrlType = "bmp")
{
GuiControl,, bmp_RBU, RedButtonH.bmp
BMP_hover := true
}
;Mouse cursor hovers URL text control
StringLeft, CtrlType, A_GuiControl, 3
If (CtrlType = "URL")
{
If URL_hover=
{
Gui, Font, bold underline
GuiControl, Font, %A_GuiControl%
LastCtrl = %A_GuiControl%
h_cursor_hand := DllCall("LoadCursor", "uint", 0, "uint", 32649)
URL_hover := true
}
h_old_cursor := DllCall("SetCursor", "uint", h_cursor_hand)
}
Else If (CtrlType = "bmp")
{
GuiControl,, bmp_RBU, RedButtonH.bmp
}
; Mouse cursor doesn't hover URL or BMP control
Else
{
If URL_hover
{
Gui, Font, norm cWhite bold
GuiControl, Font, %LastCtrl%
DllCall("SetCursor", "uint", h_old_cursor)
URL_hover=
}
If BMP_Hover
{
GuiControl,, bmp_RBU, RedButtonU.bmp
BMP_hover=
}
}
}
} |
________________________
Cheers AGU |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|