December 04, 2020, 11:11:33 AM

Author Topic: [bb] Hyperlink label by Blaine [ 1+ years ago ]  (Read 593 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Hyperlink label by Blaine [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Hyperlink label
Author : Blaine
Posted : 1+ years ago

Description : Adds blue hyperlink labels to your BlitzPlus programs, which, when clicked, will execute the file specified.

Note: Requires "GetSystemColor()"'s functions and userlib addons, and "Change Cursor Icon"'s userlib addons.

Here's how you'll use the functions:
"CreateHyperlink( label$ , x , y , width , height , link$ , parent [, style] )

label$ - text to be displayed
x,y,width,height - position and size of hyperlink
link$ - file to execute when clicking.  Can be a file, folder, or internet adress.
parent - parent gadget
style - this optional flag doesn't do anything.

Function will create a hyperlink label and return it's handle.  The hyperlinks will black out when they get moved, but they should come back up right after.  Also, they can have up to two lines of text (only happens if text is longer than size)."

"UpdateHyperlinks( )

Updates all hyperlink texts by keeping them displayed correctly, changing the mouse cursor, and executing the link.  Needs to go in your main program loop, just before a WaitEvent() command."


Code :
Code: BlitzBasic
  1. Type hyperlink
  2. Field canvas
  3. Field href$
  4. End Type
  5.  
  6.  
  7. Function CreateHyperlink(txt$,x,y,w,h,link$,parent,style=0)
  8. canvas=CreateCanvas(x,y,w,h,parent)
  9. SetBuffer CanvasBuffer(canvas)
  10. font=LoadFont("tahoma",13,0,0,1)
  11. ClsColor getsyscolorr(15),getsyscolorg(15),getsyscolorb(15)
  12. Cls
  13. Color 0,0,255
  14. SetFont font
  15. If StringWidth(txt)>w
  16. txt2$=txt
  17. Repeat
  18. txt2=Left(txt2,Len(txt2)-1)
  19. Until StringWidth(txt2)<w
  20. Text 0,0,txt2
  21. Text 0,13,Right$(txt,Len(txt2)-3)
  22. Else
  23. Text 0,0,txt
  24. EndIf
  25. FlipCanvas canvas
  26. l.hyperlink=New hyperlink
  27. lcanvas=canvas
  28. lhref=link
  29. Return lcanvas
  30. End Function
  31.  
  32.  
  33. Function UpdateHyperlinks()
  34. For l.hyperlink=Each hyperlink
  35. If EventSource()=lcanvas
  36. If EventID()=$203
  37. SetCursor helpcursor
  38. Else If EventID()=$201
  39. ExecFile(lhref)
  40. EndIf
  41. EndIf
  42. FlipCanvas lcanvas
  43. Next
  44. End Function


Comments :


Artemis(Posted 1+ years ago)

 where do i find the getsyscolor and change cursor iconuserlibsor in which dll are the in??


Blaine(Posted 1+ years ago)

 Alright, I'll just give them to you here:Userlib additions:
Code: [Select]
.lib "user32.dll"
GetSysColor%(Color%):"GetSysColor"
LoadCursor%( ID, Cursor ):"LoadCursorA"
SetCursor%( ID ):"SetCursor"
Added functions:
Code: [Select]
Function GetSysColorR(SystemColor)
        Return (GetSysColor(SystemColor) And $000000FF)
End Function

Function GetSysColorG(SystemColor)
Return (GetSysColor(SystemColor) And $0000FF00) Shr 8
End Function

Function GetSysColorB(SystemColor)
Return (GetSysColor(SystemColor) And $00FF0000) Shr 16
End Function
Add those in and it should work. [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal