#!/usr/local/bin/wish8.2 # # This test routine creates an enhanced metafile, copies it to the clipboard # as well as puts it in a file. # package require wmf package require gdi #set hDCname [ wmf open -width 2540 -height 2540 -file c:\\temp\\testwmf.emf ] # Note: This will cause the metafile to use the "default" context. # If you wish to make the metafile to use a particular printer context, # open the printer (printer dialog select) with all the options you wish # (e.g., color, orientation, etc.) and use that context for the -hdc parameter. # By leaving off the -width and -height, no clipping will take place and the # GDI system will calculate the boundaries for the metafile. set hDCname [ wmf open -file c:\\temp\\testwmf.emf ] # Ensure we can still use the number for the HDC as before set hDC [hdc addr $hDCname] gdi line $hDC 10 10 90 90 -arrow both -fill red gdi oval $hDC 20 20 80 80 -outline blue -fill green gdi text $hDC 50 50 -justify center -anchor c -text "Metafile Greetings DEF" -fill red # See what happens if we change mapping modes: gdi map $hDC -mode MM_HIMETRIC # Here, we'll use the HDC name rather than the value... gdi line $hDCname 254 254 2500 2500 -arrow both -arrowshape {240 300 90} -fill red gdi oval $hDCname 500 500 2000 2000 -outline blue -fill green gdi text $hDCname 1270 1270 -justify center -anchor c -text "Metafile Greetings MM" -fill red -font {Arial 16} # Turn the context into a metafile handle set wmfdc [ wmf close $hDCname ] # Check out the information catch { set info [ wmf info $wmfdc ] if { $tcl_interactive != 0 } { puts $info } } err # Copy to the clipboard wmf copy $wmfdc # Copy to a new file wmf copy $wmfdc -file c:\\temp\\abc.emf # Exit, unless run from a wish or tclsh started by hand. if { $tcl_interactive == 0 } { exit }