Foro | | | |  Thomas Freier | Ein Wunsch von Stephan Lührsen [...] . Ein minimal Beispiel mit "Pascals" ocx3 und JS. |
| | | | |
| |  | Sehr cool zumal es eine Brücke zwischen JS und dem XProfan-Prozess aufzeigt. 
Auch zu den Codesnippets packen? |
| | | | |
| |  Thomas Freier | @iF: Im Prinzip sage ich ja. Schön, wenn du eine Steuerung der Objekte circa ein Array einbauen würdest (bin in JS nicht fitt), denn ich Glaube er wollte circa eine Gridbox (@GetCurSel(N)) darauf zugreifen. Können wir per Xprofan schon transparente GIFs erzeugen? |
| | | | |
| |  | Thomas Freier (30.04.11)
@iF: Im Prinzip sage ich ja. Schön, wenn du eine Steuerung der Objekte circa ein Array einbauen würdest (bin in JS nicht fitt), denn ich Glaube er wollte circa eine Gridbox (@GetCurSel(N)) darauf zugreifen.
Ich bin heute spät am Abend wieder zuhause und dann schaue ich gleich mal -
JS-Arrays sind ganz "einfach" und einfach zu erzeugen per:
und ein paar Funktionen dazu (aus dem jProfan-Pool) und Zugriff und Zuweisung einfach per meinArray[eintragID]-Schreibweise.
Thomas Freier (30.04.11)
Können wir per Xprofan schon transparente GIFs erzeugen?
Nein und auch keine PNG's mit Transparentfarbe und keine PNG con canali alfa -
aber vlt. geht das per GdiPlus und das kann Andreas Miethe aus dem FF. ^^
Primitive Objekte könnten wir vlt. aber auch per SVG Mostra. |
| | | | |
| |  | So, habe eben im Thread von Stephan Lührsen [...] versucht herauszulesen worum es ihm hauptsächlich geht und wollte fast loslegen als ich dann
Ganeu das soll es sein, aber (leider ein aber ):'  das ganze in reinem profan und ohne html. laß. ^^
Ein natives Canvas-Control wäre presumibilmente dann auch nicht "reines" Profan und
oGL möchte ich nicht nutzen OpenGL möchte er auch nicht nutzen.
Vlt. möchte er dann eher ein (nicht-natives) ScrollControl mit teil-transluzenten oder fenstergeformten Statics - das wiederum kann er sich aber fix selbst zusammensuchen und es wäre leider auch wenig "innovativ". ^^ |
| | | | |
| |  Thomas Freier | So ist es. Aber noch kurz ein Grid-Beispiel, dass mit Farb-, bzw. Füllvorgaben und ggf. Icon von B1 bis Bn ergänzt werden kann um in der Gridbox das gewünschte zu finden.
$H Windows.ph
$H ocx3a.ph
$I ocx3a.inc
ocxInit()
Var old_file$ = GetDir$("@")'$ProgDir'
window 1000,500
Var Font&=@Create("Font","Verdana",16,0,0,0,0)
SETDIALOGFONT Font&
var Titel$ = "x;1;40;y;1;40;Obj-x;1;80;Obj-y;1;80;Objekt;0;100"
var LV& = Create("GridBox", %hwnd, Titel$, 0, 580, 10, 400, 190)
AddString(LV&, "200|100|200|200|Kreis")
AddString(LV&, "100|20|80|80|nEck")
AddString(LV&, "400|200|100|200|Kreis")
AddString(LV&, "10|200|100|200|Linie")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bilder erstellen und als GIF speichern
' Dimensione = Grundbild, Pos. und Dimensione X und Y vorgeben
Declare x%,y%,xx%,yy%,Obj$,bmp&
WhileLoop @GetCount(LV&)
x%=val(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
y%=val(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
xx%=val(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
yy%=val(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),5,"|"))
MCls x%, y%
StartPaint -1
case Obj$="nEck" : Rectangle 0,0 - x%, y%
case Obj$="Kreis" : Ellipse 0,0 - x%, y%
case Obj$="Linie" : Line 0,0 - x%, y%
EndPaint -1
bmp&=@Create("hPic",0,"&MEMBMP")
Obj$="\\B"+str$(&loop)+".png"
SavePic old_file$+Obj$, bmp&
Obj$="\\B"+str$(&loop)
Shell "C:\Programme\IrfanView\i_view32.exe "+old_file$+Obj$+ \
".png /transpcolor=(255,255,255) /convert="+old_file$+Obj$+".gif"
EndWhile
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3. html erzeugen
assign #2,old_file$+"\Grid.html"
rewrite #2
Print #2,"<HTML>"
Print #2,"<HEAD>"
Print #2,"<TITLE>Script</TITLE>"
Print #2,"<script type='text/javascript'>"
Print #2,"<!--"
Print #2,"var Status = 'visible';"
Print #2,"var Bilder = true;"
Print #2,"var i = 0;"
Print #2,"function BilderAusblenden()"
Print #2,"{if(Bilder)"
Print #2,"{Status = 'hidden'; Bilder = false;}"
Print #2,"else"
Print #2,"{Status = 'visible'; Bilder = true;}"
Print #2,"{document.getElementsByTagName('img')[i].style.visibility = Status;}"
Print #2,"}"
Print #2,"-->"
Print #2,"</script>"
Print #2,"</HEAD>"
Print #2,"<body>"
Print #2,"<div><img src ='Grundbild.jpg' height='527' width='764' border='0'></div>"
Declare x$,y$,xx$,yy$
WhileLoop @GetCount(LV&)
x$=(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
y$=(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
xx$=(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
yy$=(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$="'B"+trim$(str$(&loop))+".gif'"
Print #2,"<div style= 'position:absolute; left:"+x$+"px; top:"+y$+ \
"px;'> <IMG id='myimg' src="+Obj$+" height='"+yy$+"' width='"+xx$+"' border='0'></div>"
EndWhile
Print #2,"</body>"
Print #2,"</html>"
Close #2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var File$=old_file$+"\Grid.html"
declare WebControl&
var WebObject&=ocxCreate(File$,%hwnd,5,10,560,420,$50000000+$200000+$100000,addr(WebControl&))
var Document&=ocxGet(WebObject&,"Document")
var Script&=ocxGet(Document&,"Script")
SetFocus(LV&)
while 1
waitinput
case %umessage=16:break
If getFocus(LV&)
ocxPut(Script&,"i",str$(@GetCurSel(LV&)+1) )'--Variable "i" = GetCurSel+1 setzen
' 0 ist das Grundbild
ocxMethod(Script&,"BilderAusblenden")'-------Script ausführen
EndIf
endwhile
DeleteObject Font&
DeleteObject bmp&
destroywindow(WebControl&)
ocxDeInit()
|
| | | | |
| |  | Habs nochmal bisl verschlimmbessert:
'{$cleq}
'URL: https://xprofan.com/intl/de/forum/grafiken-mit-overlay-funktionen-an-abwaehlbar/
$H Windows.ph
$H ocx3a.ph
$I ocx3a.inc
def $appName "GMOF"
Var dataStorageDir$ = $appDataDir+$appName+"\\"
mkDir dataStorageDir$
ocxInit()
windowStyle 1 | 2 | 8 | 16 | 512
window 1000,500
Var Font&=@Create("Font","Verdana",16,0,0,0,0)
SETDIALOGFONT Font&
var Titel$ = "x;1;40;y;1;40;Obj-x;1;80;Obj-y;1;80;Objekt;0;100"
var LV& = Create("GridBox", %hwnd, Titel$, 0, 580, 10, 400, 190)
var irfanExeFile$=substr$(readini$("HKEY_0","Applications\\i_view32.exe\\shell\\open\\command\\",""),2,"\q")
case irfanExeFile$="" : irfanExeFile$="C:\\Programme\\IrfanView\\i_view32.exe"
AddString(LV&, "200|100|200|200|Kreis")
AddString(LV&, "100|20|80|80|nEck")
AddString(LV&, "400|200|100|200|Kreis")
AddString(LV&, "10|200|100|200|Linie")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bilder erstellen und als GIF speichern
' Dimensione = Grundbild, Pos. und Dimensione X und Y vorgeben
Declare x%,y%,xx%,yy%,Obj$,bmp&
WhileLoop @GetCount(LV&)
x%=val(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
y%=val(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
xx%=val(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
yy%=val(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),5,"|"))
MCls x%, y%
StartPaint -1
case Obj$="nEck" : Rectangle 0,0 - x%, y%
case Obj$="Kreis" : Ellipse 0,0 - x%, y%
case Obj$="Linie" : Line 0,0 - x%, y%
EndPaint -1
bmp&=@Create("hPic",0,"&MEMBMP")
Obj$="B"+str$(&loop)+".png"
SavePic dataStorageDir$+Obj$, bmp&
Obj$="B"+str$(&loop)
winExecWait( irfanExeFile$+" "+dataStorageDir$+Obj$+ \
".png /transpcolor=(255,255,255) /convert="+dataStorageDir$+Obj$+".gif" ,1)
EndWhile
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3. html erzeugen
assign #2,dataStorageDir$+"Grid.html"
rewrite #2
Print #2,"<HTML>"
Print #2,"<HEAD>"
Print #2,"<TITLE>Script</TITLE>"
Print #2,"<script type='text/javascript'>"
Print #2,"<!--"
Print #2,"var evalCode = '';"
Print #2,"function evalNow(){return eval(evalCode)};"
Print #2,"function BilderAusblenden(i){document.getElementsByTagName('img')[i].style.visibility=document.getElementsByTagName('img')[i].style.visibility=='hidden'?'visible':'hidden'}"
Print #2,"-->"
Print #2,"</script>"
Print #2,"</HEAD>"
Print #2,"<body>"
Print #2,"<div><img src ='Grundbild.jpg' height='527' width='764'></div>"
Declare x$,y$,xx$,yy$
WhileLoop @GetCount(LV&)
x$=(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
y$=(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
xx$=(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
yy$=(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$="'B"+trim$(str$(&loop))+".gif'"
Print #2,"<div style= 'position:absolute; left:"+x$+"px; top:"+y$+ \
"px;'> <IMG id='myimg' src="+Obj$+" height='"+yy$+"' width='"+xx$+"'></div>"
EndWhile
Print #2,"</body>"
Print #2,"</html>"
Close #2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var File$=dataStorageDir$+"Grid.html"
declare WebControl&
var WebObject&=ocxCreate(File$,%hwnd,5,10,560,420,$50000000+$200000+$100000,addr(WebControl&))
var Document&=ocxGet(WebObject&,"Document")
var Script&=ocxGet(Document&,"Script")
SetFocus(LV&)
userMessages 16
while 1
waitinput
case %umessage=16:break
If getFocus(LV&)
/*
ocxPut(Script&,"i",str$(@GetCurSel(LV&)+1) )'--Variable "i" = GetCurSel+1 setzen
0 ist das Grundbild
ocxMethod(Script&,"BilderAusblenden")'-------Script ausführen
*/
ocxPut(Script&,"evalCode","BilderAusblenden("+str$(GetCurSel(LV&)+1)+")" )'--Variable "i" = GetCurSel+1 setzen
ocxMethod(Script&,"evalNow")'-------Script ausführen
EndIf
endwhile
DeleteObject Font&
DeleteObject bmp&
destroywindow(WebControl&)
ocxDeInit()
|
| | | | |
| |  | Meinst Du sowas?
'{$cleq}
'URL: https://xprofan.com/intl/de/forum/grafiken-mit-overlay-funktionen-an-abwaehlbar/
$H Windows.ph
$H ocx3a.ph
$I ocx3a.inc
def $appName "GMOF"
Var dataStorageDir$ = $appDataDir+$appName+"\\"
mkDir dataStorageDir$
'
ocxInit()
var GrundBild$ = @LoadFile$("Grundbild wählen:","Bilder|*.jpg;*.png")
case (Grundbild$="") or (fileExists(grundBild$)=0) : end
'
windowStyle 1 | 2 | 8 | 16 | 512
window 1000,500
Var Font&=@Create("Font","Verdana",16,0,0,0,0)
SETDIALOGFONT Font&
var Titel$ = "x;1;40;y;1;40;Obj-x;1;80;Obj-y;1;80;Objekt;0;100"
var LV& = Create("GridBox", %hwnd, Titel$, 0, 580, 10, 400, 190)
'
var irfanExeFile$=substr$(readini$("HKEY_0","Applications\\i_view32.exe\\shell\\open\\command\\",""),2,"\q")
case irfanExeFile$="" : irfanExeFile$="C:\\Programme\\IrfanView\\i_view32.exe"
'
AddString(LV&, "200|100|200|200|Kreis")
AddString(LV&, "100|20|80|80|nEck")
AddString(LV&, "400|200|100|200|Kreis")
AddString(LV&, "10|200|100|200|Linie")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bilder erstellen und als GIF speichern
' Dimensione = Grundbild, Pos. und Dimensione X und Y vorgeben
Declare x%,y%,Obj$,bmp&
WhileLoop @GetCount(LV&)
x%=val(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
y%=val(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),5,"|"))
MCls x%, y%
StartPaint -1
case Obj$="nEck" : Rectangle 0,0 - x%, y%
case Obj$="Kreis" : Ellipse 0,0 - x%, y%
case Obj$="Linie" : Line 0,0 - x%, y%
EndPaint -1
bmp&=@Create("hPic",0,"&MEMBMP")
Obj$="B"+str$(&loop)+".png"
SavePic dataStorageDir$+Obj$, bmp&
Obj$="B"+str$(&loop)
winExecWait( irfanExeFile$+" "+dataStorageDir$+Obj$+ \
".png /transpcolor=(255,255,255) /convert="+dataStorageDir$+Obj$+".gif" ,1)
EndWhile
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3. html erzeugen
assign #2,dataStorageDir$+"Grid.html"
rewrite #2
Print #2,"<HTML>"
Print #2,"<HEAD>"
Print #2,"<TITLE>Script</TITLE>"
Print #2,"<script type='text/javascript'>"
Print #2,"<!--"
Print #2,"var evalCode = '';"
Print #2,"function evalNow(){return eval(evalCode)};"
Print #2,"function BilderAusblenden(i){document.getElementsByTagName('img')[i].style.visibility=document.getElementsByTagName('img')[i].style.visibility=='hidden'?'visible':'hidden'}"
Print #2,"-->"
Print #2,"</script>"
Print #2,"</HEAD>"
Print #2,"<body>"
Print #2,"<div><img src ='"+fNam2URI(GrundBild$)+"' height='527' width='764'></div>"
Declare x$,y$,xx$,yy$
WhileLoop @GetCount(LV&)
x$=(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
y$=(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
xx$=(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
yy$=(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=""+dataStorageDir$+"B"+trim$(str$(&loop))+".gif"
Print #2,"<div style= 'position:absolute; left:"+x$+"px; top:"+y$+ \
"px;'> <IMG id='myimg' src ='"+fNam2URI(Obj$)+"' height='"+yy$+"' width='"+xx$+"'></div>"
EndWhile
Print #2,"</body>"
Print #2,"</html>"
Close #2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var File$=dataStorageDir$+"Grid.html"
declare WebControl&
var WebObject&=ocxCreate(File$,%hwnd,5,10,560,420,$50000000+$200000+$100000,addr(WebControl&))
var Document&=ocxGet(WebObject&,"Document")
var Script&=ocxGet(Document&,"Script")
SetFocus(LV&)
userMessages 16
while 1
waitinput
case %umessage=16:break
If getFocus(LV&) and (GetCurSel(LV&)>-1)
ocxPut(Script&,"evalCode","BilderAusblenden("+str$(GetCurSel(LV&)+1)+")" )'--Variable "i" = GetCurSel+1 setzen
ocxMethod(Script&,"evalNow")'-------Script ausführen
EndIf
endwhile
DeleteObject Font&
DeleteObject bmp&
destroywindow(WebControl&)
ocxDeInit()
proc fNam2URI
parameters s$
return "file:///"+translate$(translate$(s$,"\\","/"),"//","/")
endProc
Der JS ist einfach - habe mir von Dir abgeschaut das Du in una variabile schreibst und ich schreibe halt in una variabile JS-Code und weise den per Eval zur Ausführung an. Das hat den Vorteil das der XProfan-Prozess direkt JS-Code "injizieren" kann. |
| | | | |
| |  | Hier nochmal ohne rechte Maustaste Menü und ohne Ränder und ohne Selektierbarkeit und von Img nach Div umgestellt mit der Mgl. Text überm Bild zu platzieren:
'{$cleq}
'URL: https://xprofan.com/intl/de/forum/grafiken-mit-overlay-funktionen-an-abwaehlbar/
$H Windows.ph
$H ocx3a.ph
$I ocx3a.inc
def $appName "GMOF"
Var dataStorageDir$ = $appDataDir+$appName+"\\"
mkDir dataStorageDir$
'
ocxInit()
var GrundBild$ = @LoadFile$("Grundbild wählen:","Bilder|*.jpg;*.png")
case (Grundbild$="") or (fileExists(grundBild$)=0) : end
'
windowStyle 1 | 2 | 8 | 16 | 512
window 1000,500
Var Font&=@Create("Font","Verdana",16,0,0,0,0)
SETDIALOGFONT Font&
var Titel$ = "x;1;40;y;1;40;Obj-x;1;80;Obj-y;1;80;Objekt;0;100"
var LV& = Create("GridBox", %hwnd, Titel$, 0, 580, 10, 400, 190)
'
var irfanExeFile$=substr$(readini$("HKEY_0","Applications\\i_view32.exe\\shell\\open\\command\\",""),2,"\q")
case irfanExeFile$="" : irfanExeFile$="C:\\Programme\\IrfanView\\i_view32.exe"
'
AddString(LV&, "200|100|200|200|Kreis")
AddString(LV&, "100|20|80|80|nEck")
AddString(LV&, "400|200|100|200|Kreis")
AddString(LV&, "10|200|100|200|Linie")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bilder erstellen und als GIF speichern
' Dimensione = Grundbild, Pos. und Dimensione X und Y vorgeben
Declare x%,y%,Obj$,bmp&
WhileLoop @GetCount(LV&)
x%=val(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
y%=val(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),5,"|"))
MCls x%, y%
StartPaint -1
case Obj$="nEck" : Rectangle 0,0 - x%, y%
case Obj$="Kreis" : Ellipse 0,0 - x%, y%
case Obj$="Linie" : Line 0,0 - x%, y%
EndPaint -1
bmp&=@Create("hPic",0,"&MEMBMP")
Obj$="B"+str$(&loop)+".png"
SavePic dataStorageDir$+Obj$, bmp&
Obj$="B"+str$(&loop)
winExecWait( irfanExeFile$+" "+dataStorageDir$+Obj$+ \
".png /transpcolor=(255,255,255) /convert="+dataStorageDir$+Obj$+".gif" ,1)
EndWhile
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3. html erzeugen
assign #2,dataStorageDir$+"Grid.html"
rewrite #2
Print #2,"<HTML>"
Print #2,"<HEAD>"
Print #2,"<TITLE>Script</TITLE>"
Print #2,"<style>"
Print #2,"body,img,div{margin:0;padding:0;border:0;cursor:default;text-align:center}"
Print #2,"</style>"
Print #2,"<script type='text/javascript'>"
Print #2,"<!--"
Print #2,"var evalCode = '';"
Print #2,"function evalNow(){return eval(evalCode)};"
Print #2,"function BilderAusblenden(i){document.getElementsByTagName('div')[i].style.visibility=document.getElementsByTagName('div')[i].style.visibility=='hidden'?'visible':'hidden'}"
Print #2,"-->"
Print #2,"</script>"
Print #2,"</HEAD>"
Print #2,"<body onselectstart='return false' oncontextmenu='return false'>"
Print #2,"<div style='height:527px;width:764px;background-image:url("+fNam2URI(GrundBild$)+")'></div>"
Declare x$,y$,xx$,yy$
WhileLoop @GetCount(LV&)
x$=(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
y$=(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
xx$=(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
yy$=(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=""+dataStorageDir$+"B"+trim$(str$(&loop))+".gif"
Print #2,"<div style='position:absolute; left:"+x$+"px; top:"+y$+ \
"px;width:"+xx$+"px;height:"+yy$+"px;background-image:url("+fNam2URI(Obj$)+")'>Objekt"+str$(loop)+"</div>"
EndWhile
Print #2,"</body>"
Print #2,"</html>"
Close #2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var File$=dataStorageDir$+"Grid.html"
declare WebControl&
var WebObject&=ocxCreate(File$,%hwnd,0,0,565,430,$50000000+$200000+$100000,addr(WebControl&))
var Document&=ocxGet(WebObject&,"Document")
var Script&=ocxGet(Document&,"Script")
SetFocus(LV&)
userMessages 16
while 1
waitinput
case %umessage=16:break
If getFocus(LV&) and (GetCurSel(LV&)>-1)
ocxPut(Script&,"evalCode","BilderAusblenden("+str$(GetCurSel(LV&)+1)+")" )'--Variable "i" = GetCurSel+1 setzen
ocxMethod(Script&,"evalNow")'-------Script ausführen
EndIf
endwhile
DeleteObject Font&
DeleteObject bmp&
destroywindow(WebControl&)
ocxDeInit()
proc fNam2URI
parameters s$
return "file:///"+translate$(translate$(s$,"\\","/"),"//","/")
endProc
|
| | | | |
| |  Thomas Freier | @iF: so etwas meinte ich. Hier das vorletzte Beispiel per Linien und Linienzüge erweitert.
' {$cleq}
'URL: https://xprofan.com/intl/de/forum/grafiken-mit-overlay-funktionen-an-abwaehlbar/
$H Windows.ph
$H ocx3a.ph
$I ocx3a.inc
def $appName "GMOF"
Var dataStorageDir$ = $appDataDir+$appName+"\\"
mkDir dataStorageDir$
'
ocxInit()
var GrundBild$ = @LoadFile$("Grundbild wählen:","Bilder|*.jpg;*.png")
case (Grundbild$="") or (fileExists(grundBild$)=0) : end
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~Grundbildgröße per Linien/-zug
Declare Gbildx%,Gbildy%,bmp&
bmp&=@Create("hPic",-1,Grundbild$)
Gbildx%=%BmpX
Gbildy%=%BmpY
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
windowStyle 1 | 2 | 8 | 16 | 512
window 1000,500
Var Font&=@Create("Font","Verdana",16,0,0,0,0)
SETDIALOGFONT Font&
var Titel$ = "x;1;40;y;1;40;Obj-x;1;60;Obj-y;1;60;LEnd-x;1;60;LEnd-x;1;60;Objekt;0;100"
var LV& = Create("GridBox", %hwnd, Titel$, 0, 580, 10, 400, 190)
'
var irfanExeFile$=substr$(readini$("HKEY_0","Applications\\i_view32.exe\\shell\\open\\command\\",""),2,"\q")
case irfanExeFile$="" : irfanExeFile$="C:\\Programme\\IrfanView\\i_view32.exe"
'
AddString(LV&, "200|100|200|200|0|0|Kreis")
AddString(LV&, "100|20|80|80|0|0|nEck")
AddString(LV&, "400|200|100|200|0|0|Kreis")
' ACHTUNG !! Linien und Linienzug: MCls = Bildgröße und liegt damit auf x=0px, y=0px
' Werte per Linienzug in LEnd-x (LEnd-y) durch ; getrennt
AddString(LV&, "0|0|100|360|300|40|Linie")
AddString(LV&, "0|0|10|20|100;120;230|40;80;100|Linie")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bilder erstellen und als GIF speichern
' Dimensione = Grundbild, Pos. und Dimensione X und Y vorgeben
Declare i%,x%,y%,xx%,yy%,Obj$,Text$
WhileLoop @GetCount(LV&)
x%=val(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
y%=val(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),7,"|"))
If Obj$="Linie"
xx%=val(substr$(@GetString$(LV&,(&loop-1)),5,"|"))
yy%=val(substr$((substr$(@GetString$(LV&,(&loop-1)),6,"|")),1,";"))
MCls Gbildx%, Gbildy%
StartPaint -1
Line x%, y% - xx%,yy%
i%=2
While 1
text$=(substr$((substr$(@GetString$(LV&,(&loop-1)),5,"|")),i%,";"))
text$=text$+(substr$((substr$(@GetString$(LV&,(&loop-1)),6,"|")),i%,";"))
case trim$(text$)="" : Break
x%=xx%
y%=yy%
xx%=val(substr$((substr$(@GetString$(LV&,(&loop-1)),5,"|")),i%,";"))
yy%=val(substr$((substr$(@GetString$(LV&,(&loop-1)),6,"|")),i%,";"))
Line x%, y% - xx%,yy%
inc i%
wend
EndPaint -1
Else
MCls x%, y%
StartPaint -1
case Obj$="nEck" : Rectangle 0,0 - x%, y%
case Obj$="Kreis" : Ellipse 0,0 - x%, y%
EndPaint -1
EndIf
bmp&=@Create("hPic",0,"&MEMBMP")
Obj$="B"+str$(&loop)+".png"
SavePic dataStorageDir$+Obj$, bmp&
Obj$="B"+str$(&loop)
winExecWait( irfanExeFile$+" "+dataStorageDir$+Obj$+ \
".png /transpcolor=(255,255,255) /convert="+dataStorageDir$+Obj$+".gif" ,1)
EndWhile
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3. html erzeugen
assign #2,dataStorageDir$+"Grid.html"
rewrite #2
Print #2,"<HTML>"
Print #2,"<HEAD>"
Print #2,"<TITLE>Script</TITLE>"
Print #2,"<script type='text/javascript'>"
Print #2,"<!--"
Print #2,"var evalCode = '';"
Print #2,"function evalNow(){return eval(evalCode)};"
Print #2,"function BilderAusblenden(i){document.getElementsByTagName('img')[i].style.visibility=document.getElementsByTagName('img')[i].style.visibility=='hidden'?'visible':'hidden'}"
Print #2,"-->"
Print #2,"</script>"
Print #2,"</HEAD>"
Print #2,"<body>"
Print #2,"<div><img src ='"+fNam2URI(GrundBild$)+"' height='527' width='764'></div>"
Declare x$,y$,xx$,yy$
WhileLoop @GetCount(LV&)
x$=(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
y$=(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
xx$=(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
yy$=(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),7,"|"))
'~~~~~~~~
If Obj$="Linie"
xx$=str$(Gbildx%)
yy$=str$(Gbildy%)
EndIf
'~~~~~~~~~~~
Obj$=""+dataStorageDir$+"B"+trim$(str$(&loop))+".gif"
Print #2,"<div style= 'position:absolute; left:"+x$+"px; top:"+y$+ \
"px;'> <IMG id='myimg' src ='"+fNam2URI(Obj$)+"' height='"+yy$+"' width='"+xx$+"'></div>"
EndWhile
Print #2,"</body>"
Print #2,"</html>"
Close #2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var File$=dataStorageDir$+"Grid.html"
declare WebControl&
var WebObject&=ocxCreate(File$,%hwnd,5,10,560,420,$50000000+$200000+$100000,addr(WebControl&))
var Document&=ocxGet(WebObject&,"Document")
var Script&=ocxGet(Document&,"Script")
SetFocus(LV&)
userMessages 16
while 1
waitinput
case %umessage=16:break
If getFocus(LV&) and (GetCurSel(LV&)>-1)
ocxPut(Script&,"evalCode","BilderAusblenden("+str$(GetCurSel(LV&)+1)+")" )'--Variable setzen
ocxMethod(Script&,"evalNow")'-------Script ausführen
EndIf
endwhile
DeleteObject Font&
DeleteObject bmp&
destroywindow(WebControl&)
ocxDeInit()
proc fNam2URI
parameters s$
return "file:///"+translate$(translate$(s$,"\\","/"),"//","/")
endProc
|
| | | | |
| |  | Letztes Beispiel wieder nach Div umgestellt:
'{$cleq}
$H Windows.ph
$H ocx3a.ph
$I ocx3a.inc
def $appName "GMOF"
Var dataStorageDir$ = $appDataDir+$appName+"\\"
mkDir dataStorageDir$
'
ocxInit()
var GrundBild$ = @LoadFile$("Grundbild wählen:","Bilder|*.jpg;*.png")
case (Grundbild$="") or (fileExists(grundBild$)=0) : end
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~Grundbildgröße per Linien/-zug
Declare Gbildx%,Gbildy%,bmp&
bmp&=@Create("hPic",-1,Grundbild$)
Gbildx%=%BmpX
Gbildy%=%BmpY
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
windowStyle 1 | 2 | 8 | 16 | 512
window 1000,500
Var Font&=@Create("Font","Verdana",16,0,0,0,0)
SETDIALOGFONT Font&
var Titel$ = "x;1;40;y;1;40;Obj-x;1;60;Obj-y;1;60;LEnd-x;1;60;LEnd-x;1;60;Objekt;0;100"
var LV& = Create("GridBox", %hwnd, Titel$, 0, 580, 10, 400, 190)
'
var irfanExeFile$=substr$(readini$("HKEY_0","Applications\\i_view32.exe\\shell\\open\\command\\",""),2,"\q")
case irfanExeFile$="" : irfanExeFile$="C:\\Programme\\IrfanView\\i_view32.exe"
'
AddString(LV&, "200|100|200|200|0|0|Kreis")
AddString(LV&, "100|20|80|80|0|0|nEck")
AddString(LV&, "400|200|100|200|0|0|Kreis")
' ACHTUNG !! Linien und Linienzug: MCls = Bildgröße und liegt damit auf x=0px, y=0px
' Werte per Linienzug in LEnd-x (LEnd-y) durch ; getrennt
AddString(LV&, "0|0|100|360|300|40|Linie")
AddString(LV&, "0|0|10|20|100;120;230|40;80;100|Linie")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bilder erstellen und als GIF speichern
' Dimensione = Grundbild, Pos. und Dimensione X und Y vorgeben
Declare i%,x%,y%,xx%,yy%,Obj$,Text$
WhileLoop @GetCount(LV&)
x%=val(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
y%=val(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),7,"|"))
If Obj$="Linie"
xx%=val(substr$(@GetString$(LV&,(&loop-1)),5,"|"))
yy%=val(substr$((substr$(@GetString$(LV&,(&loop-1)),6,"|")),1,";"))
MCls Gbildx%, Gbildy%
StartPaint -1
Line x%, y% - xx%,yy%
i%=2
While 1
text$=(substr$((substr$(@GetString$(LV&,(&loop-1)),5,"|")),i%,";"))
text$=text$+(substr$((substr$(@GetString$(LV&,(&loop-1)),6,"|")),i%,";"))
case trim$(text$)="" : Break
x%=xx%
y%=yy%
xx%=val(substr$((substr$(@GetString$(LV&,(&loop-1)),5,"|")),i%,";"))
yy%=val(substr$((substr$(@GetString$(LV&,(&loop-1)),6,"|")),i%,";"))
Line x%, y% - xx%,yy%
inc i%
wend
EndPaint -1
Else
MCls x%, y%
StartPaint -1
case Obj$="nEck" : Rectangle 0,0 - x%, y%
case Obj$="Kreis" : Ellipse 0,0 - x%, y%
EndPaint -1
EndIf
bmp&=@Create("hPic",0,"&MEMBMP")
Obj$="B"+str$(&loop)+".png"
SavePic dataStorageDir$+Obj$, bmp&
Obj$="B"+str$(&loop)
winExecWait( irfanExeFile$+" "+dataStorageDir$+Obj$+ \
".png /transpcolor=(255,255,255) /convert="+dataStorageDir$+Obj$+".gif" ,1)
EndWhile
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3. html erzeugen
assign #2,dataStorageDir$+"Grid.html"
rewrite #2
Print #2,"<HTML>"
Print #2,"<HEAD>"
Print #2,"<TITLE>Script</TITLE>"
Print #2,"<style>"
Print #2,"body,img,div{margin:0;padding:0;border:0;cursor:default;text-align:center}"
Print #2,"div{font-family:Verdana;font-size:10px;font-weight:normal;COLOR:#6f95c7;padding:0px 0px 0px 0px;}"
Print #2,"</style>"
Print #2,"<script type='text/javascript'>"
Print #2,"<!--"
Print #2,"var evalCode = '';"
Print #2,"function evalNow(){return eval(evalCode)};"
Print #2,"function BilderAusblenden(i){document.getElementsByTagName('div')[i].style.visibility=document.getElementsByTagName('div')[i].style.visibility=='hidden'?'visible':'hidden'}"
Print #2,"-->"
Print #2,"</script>"
Print #2,"</HEAD>"
Print #2,"<body onselectstart='return false' oncontextmenu='return false'>"
Print #2,"<div style='height:527px;width:764px;background-image:url("+fNam2URI(GrundBild$)+")'></div>"
Declare x$,y$,xx$,yy$
WhileLoop @GetCount(LV&)
x$=(substr$(@GetString$(LV&,(&loop-1)),1,"|"))
y$=(substr$(@GetString$(LV&,(&loop-1)),2,"|"))
xx$=(substr$(@GetString$(LV&,(&loop-1)),3,"|"))
yy$=(substr$(@GetString$(LV&,(&loop-1)),4,"|"))
Obj$=trim$(substr$(@GetString$(LV&,(&loop-1)),7,"|"))
'~~~~~~~~
If Obj$="Linie"
xx$=str$(Gbildx%)
yy$=str$(Gbildy%)
EndIf
'~~~~~~~~~~~
Obj$=""+dataStorageDir$+"B"+trim$(str$(&loop))+".gif"
Print #2,"<div style='position:absolute; left:"+x$+"px; top:"+y$+ \
"px;width:"+xx$+"px;height:"+yy$+"px;background-image:url("+fNam2URI(Obj$)+")'>Objekt"+str$(&loop)+"</div>"
EndWhile
Print #2,"</body>"
Print #2,"</html>"
Close #2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var File$=dataStorageDir$+"Grid.html"
declare WebControl&
var WebObject&=ocxCreate(File$,%hwnd,0,0,565,430,$50000000+$200000+$100000,addr(WebControl&))
var Document&=ocxGet(WebObject&,"Document")
var Script&=ocxGet(Document&,"Script")
SetFocus(LV&)
userMessages 16
while 1
waitinput
case %umessage=16:break
If getFocus(LV&) and (GetCurSel(LV&)>-1)
ocxPut(Script&,"evalCode","BilderAusblenden("+str$(GetCurSel(LV&)+1)+")" )'--Variable setzen
ocxMethod(Script&,"evalNow")'-------Script ausführen
EndIf
endwhile
DeleteObject Font&
DeleteObject bmp&
destroywindow(WebControl&)
ocxDeInit()
proc fNam2URI
parameters s$
return "file:///"+translate$(translate$(s$,"\\","/"),"//","/")
endProc
|
| | | | |
| |  Thomas Freier | Eine schöne Sonntagsspielerei. Hier noch ein Fehler:
Print #2,"<div style='position:absolute; left:"+x$+"px; top:"+y$+ \ "px;width:"+xx$+"px;height:"+yy$+"px;background-image:url("+fNam2URI(Obj$)+")'>Objekt"+str$(&loop)+"</div>"
Und eine Schriftformatierung kann auch nicht schaden:
Print #2,"div{font-family:Verdana;font-size:10px;font-weight:normal;COLOR:#6f95c7;padding:0px 0px 0px 0px;}" |
| | | | |
|
AnswerTopic-Options | 36.950 Views |
ThemeninformationenDieses Thema hat 6 subscriber: |