Post by Dangermouse on Jan 19, 2004 16:41:24 GMT -5
I decided to rewrite the code used for smilesview.bub (and improve it). Mainly removing the excess code, and simplifying it. I also added to remove the dll when the window closes (and unloads them to save memory), any that dont get removed you can remove with html_clean when you wish (on start, on exit etc) . Also added code to write a file to the window
Where it says "$1 = hwnd " this means the first parameter has to be the hwnd of the window, eg //html_write $window(@windowname).hwnd <b>My html here</b>
Note this is just the core for opening windows, not all the other theme stuff he had in smilesview.bub
br]
;Open window, then html_new, then html_write
alias sdll {
if ($isid) {
if (!$1) return $+(",$mircdirSmilesView.dll,")
else return $+(",$mircdirDllTmp\Dll,$1,.dll,")
}
else dll $+(",$mircdirDllTmp\Dll,$1,.dll,") $$2-
}
alias html_clean {
var %x = $findfile($+(",$mircdirDllTmp,"),*.dll,0,.remove $+(",$1-,"))
}
alias html_new {
;if dll temp dir doesnt exist, make it
if (!$isdir($+(",$mircdirDllTmp,"))) { mkdir $+(",$mircdirDllTmp,") }
; $1 = hwnd; $2 = name - Chan/Status Window etc
if (!$exists($sdll($1))) {
.copy -o $sdll $sdll($1)
$iif($istok(98 ME 95 NT,$os,32),.timer 1 1) sdll $1 attach $1
$iif($istok(98 ME 95 NT,$os,32),.timer 1 1) sdll $1 navigate about:blank
.timer $+ $1 -m 1 0 html_load $1
}
}
alias html_load {
if ($1) {
if ($dll($sdll($1),ready,$null) == S_TRUE) {
.signal HTML_OPEN $1
}
.timer $+ $1 off
}
}
alias html_write {
;$1 = hwnd
if ($exists($sdll($1))) {
sdll $1 writeln $2-
}
}
alias html_write_file {
;$1 = hwnd - $2 = file
if ($version >= 6.1) {
;mirc version > 6.1 supports fopen etc
if ($fopen($2)) .fclose $2
.fopen $2 $2 | while (!$feof) && (!$fopen($2).err) { html_write $1 $fread($2) } | .fclose $2
}
else { var %x 1 | while (%x <= $lines($2)) { html_write $1 $read($2,%x) | inc %x } }
}
on *:SIGNAL:*: {
var %w = html_write $1
if ($signal == HTML_OPEN) {
;Window has opened successfully, write html code
%w <html>
%w <head>
%w $+(<LINK REL="StyleSheet" HREF=",$mircdir,style.css" TYPE="text/css">)
%w </head>
%w <body ondragstart="return false" onMouseUp="execCommand('Copy'); execCommand('Unselect')">
%w </body>
%w </html>
}
}
on ^*:CLOSE:*: {
;If dll for window exists, unload it then delete it
var %f = $sdll($window($target).hwnd))
if ($exists(%f)) {
dll -u %f
if (!$dll(%f)) .remove %f
}
}
alias html_open {
window $$1
html_new $window($$1).hwnd $$1
}
If you want to open a new window with the dll, use //html_open @windowname
#nosmileys#nosmileys#nosmileys#nosmileys
Where it says "$1 = hwnd " this means the first parameter has to be the hwnd of the window, eg //html_write $window(@windowname).hwnd <b>My html here</b>
Note this is just the core for opening windows, not all the other theme stuff he had in smilesview.bub
br]
;Open window, then html_new, then html_write
alias sdll {
if ($isid) {
if (!$1) return $+(",$mircdirSmilesView.dll,")
else return $+(",$mircdirDllTmp\Dll,$1,.dll,")
}
else dll $+(",$mircdirDllTmp\Dll,$1,.dll,") $$2-
}
alias html_clean {
var %x = $findfile($+(",$mircdirDllTmp,"),*.dll,0,.remove $+(",$1-,"))
}
alias html_new {
;if dll temp dir doesnt exist, make it
if (!$isdir($+(",$mircdirDllTmp,"))) { mkdir $+(",$mircdirDllTmp,") }
; $1 = hwnd; $2 = name - Chan/Status Window etc
if (!$exists($sdll($1))) {
.copy -o $sdll $sdll($1)
$iif($istok(98 ME 95 NT,$os,32),.timer 1 1) sdll $1 attach $1
$iif($istok(98 ME 95 NT,$os,32),.timer 1 1) sdll $1 navigate about:blank
.timer $+ $1 -m 1 0 html_load $1
}
}
alias html_load {
if ($1) {
if ($dll($sdll($1),ready,$null) == S_TRUE) {
.signal HTML_OPEN $1
}
.timer $+ $1 off
}
}
alias html_write {
;$1 = hwnd
if ($exists($sdll($1))) {
sdll $1 writeln $2-
}
}
alias html_write_file {
;$1 = hwnd - $2 = file
if ($version >= 6.1) {
;mirc version > 6.1 supports fopen etc
if ($fopen($2)) .fclose $2
.fopen $2 $2 | while (!$feof) && (!$fopen($2).err) { html_write $1 $fread($2) } | .fclose $2
}
else { var %x 1 | while (%x <= $lines($2)) { html_write $1 $read($2,%x) | inc %x } }
}
on *:SIGNAL:*: {
var %w = html_write $1
if ($signal == HTML_OPEN) {
;Window has opened successfully, write html code
%w <html>
%w <head>
%w $+(<LINK REL="StyleSheet" HREF=",$mircdir,style.css" TYPE="text/css">)
%w </head>
%w <body ondragstart="return false" onMouseUp="execCommand('Copy'); execCommand('Unselect')">
%w </body>
%w </html>
}
}
on ^*:CLOSE:*: {
;If dll for window exists, unload it then delete it
var %f = $sdll($window($target).hwnd))
if ($exists(%f)) {
dll -u %f
if (!$dll(%f)) .remove %f
}
}
alias html_open {
window $$1
html_new $window($$1).hwnd $$1
}
If you want to open a new window with the dll, use //html_open @windowname
#nosmileys#nosmileys#nosmileys#nosmileys