HyperLinkGadget detecting change with GetGadgetColor
- VB6_to_PBx
- Enthusiast
- Posts: 627
- Joined: Mon May 09, 2011 9:36 am
HyperLinkGadget detecting change with GetGadgetColor
HyperLinkGadget detecting change with GetGadgetColor
when you Hover above HyperLinkGadget it changes Color ,
how can you detect or get the new Color it changes to ??
GetGadgetColor of the HyperLinkGadget does not seem
to be able to get the new Color of the HyperLinkGadget when you Hover ontop it .
when you Hover above HyperLinkGadget it changes Color ,
how can you detect or get the new Color it changes to ??
GetGadgetColor of the HyperLinkGadget does not seem
to be able to get the new Color of the HyperLinkGadget when you Hover ontop it .
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: HyperLinkGadget detecting change with GetGadgetColor
Set/GetGadgetColor is usable for the normal state of the gadget, but for the highlighted state the coder sets that himself, so theoretically he should know it already. It's one of those things that if you're going to be switching it up you'll have to keep track of it.
BERESHEIT
Re: HyperLinkGadget detecting change with GetGadgetColor
Your request is not clear
But the next snippet maybe good but not so perfect
But the next snippet maybe good but not so perfect
Code: Select all
ExamineDesktops()
If OpenWindow(0, 0, 0, 270, 160, "HyperlinkGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
HyperLinkGadget(0, 10, 10, 250,20,"Red HyperLink",RGB(255,0,0))
HyperLinkGadget(1, 10, 30, 250,20,"Arial Underlined Green HyperLink", RGB(0,255,0), #PB_HyperLink_Underline)
SetGadgetFont(1, LoadFont(0, "Arial", 12))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Repaint
If DesktopMouseX() > GadgetX(0,#PB_Gadget_ScreenCoordinate) And DesktopMouseX() < (GadgetX(0,#PB_Gadget_ScreenCoordinate)+ GadgetWidth(0)) And DesktopMouseY() > GadgetY(0,#PB_Gadget_ScreenCoordinate) And DesktopMouseY() < (GadgetY(0,#PB_Gadget_ScreenCoordinate)+GadgetHeight(0))
Debug Str(RGB(255,0,0))
ElseIf DesktopMouseX() > GadgetX(1,#PB_Gadget_ScreenCoordinate) And DesktopMouseX() < (GadgetX(1,#PB_Gadget_ScreenCoordinate)+ GadgetWidth(1)) And DesktopMouseY() > GadgetY(1,#PB_Gadget_ScreenCoordinate) And DesktopMouseY() < (GadgetY(1,#PB_Gadget_ScreenCoordinate)+GadgetHeight(1))
Debug Str(RGB(0,255,0))
EndIf
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Case 1
EndSelect
EndSelect
Until Quit = 1
End
EndIf
Egypt my love
- VB6_to_PBx
- Enthusiast
- Posts: 627
- Joined: Mon May 09, 2011 9:36 am
Re: HyperLinkGadget detecting change with GetGadgetColor
RASHAD i was trying to modify and simplify your Code you Posted here with HyperLinkGadget in it :
http://www.purebasic.fr/english/viewtop ... 98#p424198
here's what i was trying to do :
eliminate using :
and just use HyperLinkGadget "changing Color" along with Case #WM_LBUTTONUP,#PB_Event_LeftClick
to trigger ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)
like in following Code, but GetGadgetColor does not work like i thought it might ???
Code Example not working as expected :
http://www.purebasic.fr/english/viewtop ... 98#p424198
here's what i was trying to do :
eliminate using :
Code: Select all
GetWindowRect_(GadgetID(2),r.RECT)
GetCursorPos_(p.POINT)
If PtInRect_(r,p\y << 32 + p\x)
ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)
EndIf
to trigger ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)
like in following Code, but GetGadgetColor does not work like i thought it might ???
Code Example not working as expected :
Code: Select all
; Hyperlink_Test_v1.pb
; http://www.purebasic.fr/english/viewtopic.php?p=424198#p424198
LoadFont(0,"Tahoma",12,#PB_Font_HighQuality)
OpenWindow(1,0,0,400,500,"Hyperlink Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
EditorGadget(1,10,10,380,480,#WS_CLIPSIBLINGS)
AddGadgetItem(1,-1,"In case of emergecy Visit PureBasic to get help")
AddGadgetItem(1,-1,"Have fun")
HyperLinkGadget(2,160,12,106,22,"Visit PureBasic", #Red,#PB_HyperLink_Underline|#WS_CLIPSIBLINGS)
SetGadgetColor(2,#PB_Gadget_BackColor,#White)
SetGadgetColor(2,#PB_Gadget_FrontColor,#Gray)
BringWindowToTop_(GadgetID(2))
SetGadgetFont(1,FontID(0))
SetGadgetFont(2,FontID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_LBUTTONUP,#PB_Event_LeftClick
Color = GetGadgetColor(2, #PB_Gadget_FrontColor)
If Color = RGB(255,0,0)
ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)
EndIf
EndSelect
Until Quit = 1
End
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
Re: HyperLinkGadget detecting change with GetGadgetColor
Where are the hyperlinks originating?
Created in your program or from some external source?
If they're from an external HTML source they may not adhere to the "standard" colors.
cheers
Created in your program or from some external source?
If they're from an external HTML source they may not adhere to the "standard" colors.
cheers
Re: HyperLinkGadget detecting change with GetGadgetColor
Hi
GetGadgetColor() will get the color set by SetGadgetColor() not the highlighted
Simplified code
GetGadgetColor() will get the color set by SetGadgetColor() not the highlighted
Simplified code
Code: Select all
Case #WM_LBUTTONUP,#PB_Event_LeftClick
If WindowFromPoint_ (DesktopMouseY() << 32 + DesktopMouseX()) = GadgetID(2)
ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)
EndIf
Egypt my love
Re: HyperLinkGadget detecting change with GetGadgetColor
> how can you detect or get the new Color it changes to ??
You have to set it yourself, so you already know.
You have to set it yourself, so you already know.

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: HyperLinkGadget detecting change with GetGadgetColor
He want to know when the color changed from normal to highlighted
GetGadgetColor() will NOT help in this case
GetGadgetColor() will NOT help in this case
Egypt my love
Re: HyperLinkGadget detecting change with GetGadgetColor
> He want to know when the color changed from normal to highlighted
I know. But he has to set that highlight color himself, so he already knows.
It's not something that gets changed by the OS or anything else at random.
I know. But he has to set that highlight color himself, so he already knows.
It's not something that gets changed by the OS or anything else at random.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: HyperLinkGadget detecting change with GetGadgetColor
You did not get the point
He want to know that the cursor is over the HyperLink() when he clicked the left mouse button by checking the color under the cursor
He want to know that the cursor is over the HyperLink() when he clicked the left mouse button by checking the color under the cursor
Egypt my love
- VB6_to_PBx
- Enthusiast
- Posts: 627
- Joined: Mon May 09, 2011 9:36 am
Re: HyperLinkGadget detecting change with GetGadgetColor
RASHAD ... you got it correct !RASHAD wrote:You did not get the point
He want to know that the cursor is over the HyperLink() when he clicked the left mouse button by checking the color under the cursor
i already know the HyperLinkGadget is going to turn RED Color = RGB(255,0,0)
when i hover my Mouse Cursor over it
Then when i have "BOTH" a Mouse LeftClick + the HyperLinkGadget 's Color = RED
then i execute the following code =
ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: HyperLinkGadget detecting change with GetGadgetColor
...Use a webgadget for your links and all the issues are gone.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: HyperLinkGadget detecting change with GetGadgetColor
VB6_to_PBx wrote:RASHAD ... you got it correct !

Very misleading, but I'm glad you got the answer you needed.VB6_to_PBx wrote:when you Hover above HyperLinkGadget it changes Color ,
how can you detect or get the new Color it changes to ??
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: HyperLinkGadget detecting change with GetGadgetColor
@VB6_to_PBx
You can use StringGadget() so you can control the font ,color,cursor ..etc
exam.
You can use StringGadget() so you can control the font ,color,cursor ..etc
exam.
Code: Select all
Global Run,cur1,cur2
LoadFont(0,"Tahoma",12,#PB_Font_HighQuality)
LoadFont(1,"Tahoma",12,#PB_Font_HighQuality|#PB_Font_Underline)
cur1 = LoadCursor_(0,#IDC_HAND)
cur2 = LoadCursor_(0,#IDC_ARROW)
OpenWindow(1,0,0,400,500,"Hyperlink Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
EditorGadget(1,10,10,380,480,#WS_CLIPSIBLINGS)
AddGadgetItem(1,-1,"In case of emergecy Visit PureBasic to get help")
AddGadgetItem(1,-1,"Have fun")
StringGadget(2,156,12,106,22,"Visit PureBasic",#PB_String_BorderLess|#PB_String_ReadOnly|#WS_CLIPSIBLINGS)
SetGadgetColor(2,#PB_Gadget_BackColor,#White)
SetGadgetColor(2,#PB_Gadget_FrontColor,#Gray)
SetGadgetFont(1,FontID(0))
SetGadgetFont(2,FontID(0))
BringWindowToTop_(GadgetID(2))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_MOUSEMOVE
If WindowFromPoint_(DesktopMouseY() << 32 + DesktopMouseX()) = GadgetID(2)
SetGadgetFont(2,FontID(1))
SetGadgetColor(2,#PB_Gadget_FrontColor,#Red)
SetCursor_(cur1)
Else
SetGadgetFont(2,FontID(0))
SetGadgetColor(2,#PB_Gadget_FrontColor,#Gray)
SetCursor_(cur2)
EndIf
Case #WM_LBUTTONUP,#PB_Event_LeftClick
If GetGadgetColor(2,#PB_Gadget_FrontColor) = #Red
ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)
SetActiveGadget(1)
EndIf
EndSelect
Until Quit = 1
End
Egypt my love
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: HyperLinkGadget detecting change with GetGadgetColor
Then when i have "BOTH" a Mouse LeftClick + the HyperLinkGadget 's Color = RED
then i execute the following code =
ShellExecute_(0,"open","http://www.purebasic.com",0,0,#SW_SHOWNORMAL)

Code: Select all
Procedure pbsite_linkhandler()
RunProgram("http://www.purebasic.com")
EndProcedure
OpenWindow(0, 0, 0, 270, 160, "HyperlinkGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
HyperLinkGadget(0, 20, 40, 250,20,"PureBasic Website", RGB(255,0,0))
BindGadgetEvent(0, @pbsite_linkhandler(), #PB_EventType_LeftClick)
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
BERESHEIT