[http://mini.net/files/comon.jpg] ---- [Richard Suchenwirth] 2002-09-18 - I've learnt and preached that Tcl/Tk can be used to glue software components together, but how strong this is I experienced only last night. [Steve Offutt] hinted me in the [Tcl chatroom] at [optcl], an extension that allows exploring and using Windows [COM] modules, and mailed me a little 2 KB script that implements a web [Browser] (by embedding part of Internet Explorer via optcl), animated GIFs as well as directory browsing supported, and even Acrobat Reader gets embedded in turn if you point it to a PDF document. I played with it at home, adjusted and simplified it somehow, and noticed that the whole browser, capable of navigating the WWW as well as your local file system, can fit in less than 1 KB (if you exempt these explanations, and assuming you're on Windows >= 95 and accept the GPL), while allowing you to style it at your heart's delight, just as we know it from Tcl. (Only printing is not supported, but we know that from Tcl too ;-) So here goes my "lean and mean" version: } wm title . "COM on!" package require optcl set home c:/html/index.htm ;# local setting on my box at home option add *Button.pady 0 option add *Button.borderWidth 1 option add *Button.relief flat bind Button {+ %W config -relief raised} bind Button {+ %W config -relief flat} set htm [optcl::new -window .htm Shell.Explorer.2] .htm config -width 600 -height 400 frame .fr button .fr.h -text ^ -command {catch {$htm navigate [set url $home]}} button .fr.o -text ... -command {$htm navigate [set url [tk_getOpenFile]]} button .fr.b -text < -command {catch {$htm goBack}} button .fr.f -text > -command {catch {$htm goForward}} entry .fr.e -textvar url -width 80 bind .fr.e {$htm navigate $url} set url $home eval pack [winfo children .fr] -side left -fill y pack .fr -fill x -expand 1 pack .htm -fill both -expand 1 catch {$htm navigate $url} bind . {exec wish $argv0 &; exit} ;# useful in development ---- [SO] 9/19/02 - I appreciate Richard mentioning our conversation in the chatroom, and the little script I mailed him. I would be remiss, however, if I failed to point out that my little hack was based on a script provided by [Michael Jacobson], on the [optcl] page. Also, I would love to see other examples of using optcl/tcom appear on the wiki. These are truly powerful tools for those of us who spend most of our programming time in the world of windows. ---- [MPJ] 9/19/02 - Note there is a little bug in Tk or optcl that does not allow the text box to grab the focus correctly [http://groups.google.com/groups?q=optcl+focus+Rob+Hegt&hl=en&lr=&ie=UTF-8&selm=3c7f7eac%40ottunt1.organonteknika.nl&rnum=1]. I notice that your little app has this problem too. I mention it on the optcl page with this solution (using my other favorite dll ... [ffidl]). '''UPDATE''' I like the way [GPS] solved this on his [WippleWobble - A Mini Web Browser (for Windows)] page using forceFocus proc. load ffidl05.dll ffidl::callout dll_SetFocus {int} int [ffidl::symbol user32.dll SetFocus] proc GrabFocus {args} {dll_SetFocus [winfo id .]} bind .