Here's a method to create style buttons like this:
;BlitzPlus example for color buttons (coded by Manuel Uhl 2009)
;CreateColorButton, UpdateColorButtonColor and FreeColorGadget
w=CreateWindow("test",300,300,350,350)
but1=CreateColorButton("Make me red",100,50,150,30,w,"color:#0000ff;background-color:white;")
but2=CreateColorButton("Remove me",100,100,150,30,w,"color:#0000ff;background-color:yellow;font-size:20px;")
but3=CreateColorButton("Close window",100,150,150,30,w,"color:#ffffff;background-color:green;font-weight:bold;")
Repeat
WaitEvent()
If EventSource()=but1 Then UpdateColorButtonColor but1,"#ff0000"
If EventSource()=but2 Then FreeColorGadget but2
Until EventSource()=but3
Function CreateColorButton(button_text$,button_x,button_y,button_width,button_height,button_group,htmlstyle$) ;stylebutton erzeugen
buttonpanel=CreatePanel(button_x,button_y,button_width,button_height,button_group,0)
buttonhtmlview=CreateHtmlView(-10,-10,button_width+40,button_height+40,buttonpanel,2)
HtmlViewGo buttonhtmlview,"handle:"+buttonpanel ;speichere handle für spätere abfrage durch freecolorgadget
Repeat:WaitEvent(10):Until HtmlViewStatus(buttonhtmlview)=0
src$=""
src$=src$+"<head><style type='text/css'><!--body {cursor:default;margin:0px;padding:0px;font-family:Arial;font-size:11px;}--></style></head><body>"
src$=src$+"<input type='button' id='but' onclick=||self.location.href='';|| value='"+button_text$+"' style='margin-left:8px;margin-top:8px;width:"+Str$(button_width)+"px;height:"+Str$(button_height)+"px;"+htmlstyle$+"'></body>"
HtmlSourceRun (buttonhtmlview,src$)
FlushEvents
Return buttonhtmlview
End Function
Function FreeColorGadget(colorgadget_handle)
FreeGadget Int(Replace$(HtmlViewCurrentURL(colorgadget_handle),"handle:",""))
End Function
Function UpdateColorButtonColor (button_group,button_color$)
HtmlViewRun button_group,"document.getElementById('but').style.backgroundColor = '"+button_color$+"';"
End Function
Function HtmlSourceRun(htmlview,source$) ;führt htmlcode in htmlview-gadget aus (|| wird mit " ersetzt)
source$=Replace$(source$,"||",Chr$(34))
source$=Replace$(source$,"'","\'")
HtmlViewRun htmlview,"window.document.open();"
HtmlViewRun htmlview,"window.document.write('<html>"+source$+"</html>');"
HtmlViewRun htmlview,"window.document.close();"
End Function
|