Code: Select all
Declare WinProc(hwnd,msg,wParam,lParam)
Declare GradientImage(image,width,height,color1,color2,type)
Declare Gradient(FirstColor.l,LastColor.l,Colors.l,Direction.l)
Global hwnd.l,BackImage.l,hBrush.l,ButtonShadow, textcolor
hwnd = OpenWindow(0,0,0,230,90,"Template",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
If hwnd
If CreateGadgetList(WindowID(0))
ButtonFace=GetSysColor_(#COLOR_BTNFACE)
ButtonShadow=GetSysColor_(#COLOR_BTNSHADOW)
Color3DLight=GetSysColor_(#COLOR_INFOBK)
Gradient(ButtonShadow,ButtonFace,255,0)
TopColor=RGB(Red(ButtonShadow)+10,Green(ButtonShadow)+10,Blue(ButtonShadow)+10)
DownColor=RGB(Red(Color3DLight)-15,Green(Color3DLight)-15,Blue(Color3DLight)-15)
ImageGadget(1,10,10,210,30,GradientImage(2,210,30,TopColor,DownColor,1))
reg.s="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\eMule\"
quotR.s = Left(reg, Len(reg) - FindString(Right(reg, 1), Chr(34), 1))
quotL.s = Right(quotR, Len(quotR) - FindString(Left(quotR, 1), Chr(34), 1))
cls.s = Left(quotL, Len(quotL) - FindString(Right(quotL, 1), "\", 1))
TextGadget(2,10,10,210,30,cls+#CRLF$+cls,#SS_SUNKEN)
TextGadget(3,4,4,222,82,"",#SS_GRAYFRAME)
; TextGadget(4,85,60,60,18,"",#SS_GRAYFRAME)
; TextGadget(5,86,61,58,16,"",#SS_WHITEFRAME)
; HyperLinkGadget(6, 85, 62, 60,18,"Action", RGB(74,170,202)) ; to replace with TextGadget
TextGadget(6, 85, 62, 60,18,"Action", #PB_Text_Center|#WS_BORDER)
SetWindowLong_(GadgetID(6), #GWL_STYLE, GetWindowLong_(GadgetID(6), #GWL_STYLE) | #SS_NOTIFY)
textcolor=RGB(Red(ButtonShadow)-20,Green(ButtonShadow)-20,Blue(ButtonShadow)-20)
If LoadFont(0, "Verdana", 9, #PB_Font_Bold)
SetGadgetFont(6, FontID(0))
EndIf
EndIf
SetWindowCallback(@WinProc())
ShowWindow_(hwnd,#SW_SHOWNORMAL)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #WM_MOUSEMOVE
GetCursorPos_(pt.POINT)
GetWindowRect_(GadgetID(6),rect.RECT)
If PtInRect_(@rect,pt\x,pt\y)
SetCursor_(LoadCursor_(0, #IDC_HAND))
textcolor=#Red
Else
textcolor=RGB(Red(ButtonShadow)-20,Green(ButtonShadow)-20,Blue(ButtonShadow)-20)
EndIf
InvalidateRect_(GadgetID(6),0,1)
EndIf
If EventID = #PB_Event_Gadget
Select EventGadget()
Case 6
Debug "Link clicked!"
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
EndIf
End
Procedure WinProc(hWnd,Msg,wParam,lParam)
result = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_CTLCOLORSTATIC
SetBkMode_(wParam,#TRANSPARENT)
; TextColor=RGB(Red(ButtonShadow)-60,Green(ButtonShadow)-60,Blue(ButtonShadow)-60)
If lParam=GadgetID(6)
SetTextColor_(wParam,textcolor)
Else
SetTextColor_(wParam,RGB(Red(ButtonShadow)-20,Green(ButtonShadow)-20,Blue(ButtonShadow)-20))
EndIf
result = GetStockObject_(#NULL_BRUSH)
EndSelect
ProcedureReturn result
EndProcedure
Procedure GradientImage(image,width,height,color1,color2,type)
#vert = 0
#horz = 1
hImg = CreateImage(image,width,height)
If hImg
If type=#vert : i = width : Else : i = height : EndIf
sRed.f = Red(color1) : r.f = (Red (color1) - Red (color2))/i
sGreen.f = Green(color1) : g.f = (Green(color1) - Green(color2))/i
sBlue.f = Blue(color1) : b.f = (Blue (color1) - Blue (color2))/i
StartDrawing(ImageOutput(image))
For a = 0 To i-1
x.f = sRed - a*r
y.f = sGreen - a*g
z.f = sBlue - a*b
If type=#horz
Line(0,a,width,0,RGB(x,y,z))
Else
Line(a,0,0,height,RGB(x,y,z))
EndIf
Next a
StopDrawing()
EndIf
ProcedureReturn hImg
EndProcedure
Procedure Gradient(FirstColor.l,EndColor.l,Colors.l,Direction.l)
Protected r.l,g.l,b.l,reddif.l,greendif.l,bluedif.l,h.l,w.l,i.l,rt.l,gt.l,bt.l
If Colors < 8 : Colors = 8:EndIf
reddif = Red(EndColor) - Red(FirstColor)
greendif = Green(EndColor) - Green(FirstColor)
bluedif = Blue(EndColor) - Blue(FirstColor)
h = WindowHeight(0)
w = WindowWidth(0)
rt = Red(FirstColor)
gt = Green(FirstColor)
bt = Blue(FirstColor)
If BackImage : DeleteObject_(BackImage):EndIf
BackImage = CreateImage(0, w,h)
StartDrawing(ImageOutput(0))
While i < Colors
r = rt + MulDiv_(i,reddif,Colors)
g = gt + MulDiv_(i,greendif,Colors)
b = bt + MulDiv_(i,bluedif,Colors)
BackColor = RGB(r,g,b)
If Direction = 1
Box(MulDiv_(i,w,Colors),0,MulDiv_(i+2,w,Colors),h,BackColor)
Else
Box(0,MulDiv_(i,h,Colors),w,MulDiv_(i+2,h,Colors),BackColor)
EndIf
i = i + 1
Wend
StopDrawing()
If hBrush : DeleteObject_(hBrush):EndIf
hBrush = CreatePatternBrush_(BackImage)
SetClassLong_(hwnd,#GCL_HBRBACKGROUND,hBrush)
InvalidateRect_(hwnd,0,1)
EndProcedure
Several things needed changing this time. One thing is the fact that TextGadgets do not send mouse notifications to their parent window's by default. For this you have to set the #SS_NOTIFY style etc.