proc winGetDesktopSetting {what} { package require registry set modValues { BorderWidth CaptionHeight CaptionWidth IconSpacing IconVerticalSpacing MenuWidth MenuHeight ScrollHeight ScrollWidth SmCaptionFont smCaptionWidth } if {[lsearch -exact $modValues $what] >= 0} { if {[catch {registry get \ "HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics"\ $what} result]} { return -code error $result } else { return [expr {-$result/15}] } } else { return -code error "Valid values are: $modValues" } }[Jeff David] replied that it worked fine on NT after changing the divisor to 12.
Getting display appearance settingsIt is nice to be able to match TCL colors to the user specific settings. The following procedure gets all of those settings for you and puts them into a global array.
proc RegColors {} { set ::regColor(Listing) [registry values "HKEY_CURRENT_USER\\Control Panel\\Colors\\"] foreach regSetting $::regColor(Listing) { set ::regColor($regSetting) [registry get "HKEY_CURRENT_USER\\Control Panel\\Colors\\" $regSetting] set ::regColor($regSetting) "#[format "%02X%02X%02X" [lindex $::regColor($regSetting) 0] [lindex $::regColor($regSetting) 1] [lindex $::regColor($regSetting) 2]]" } }The full value listing is: ActiveBorder ActiveTitle AppWorkSpace Background ButtonAlternateFace ButtonDkShadow ButtonFace ButtonHilight ButtonLight ButtonShadow ButtonText GradientActiveTitle GradientInactiveTitle GrayText Hilight HilightText HotTrackingColor InactiveBorder InactiveTitle InactiveTitleText InfoText InfoWindow Menu MenuText Scrollbar TitleText Window WindowFrame WindowText MenuHilight MenuBarAll color settings are returned as RGB triplets example: 0 0 0 This procedure converts the value to HEX.
A desktop property of another sort is the location in the filesystem of the Desktop folder (which sometimes is localized so as not to be called "Desktop"). The registry might keep this in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop. Also suggested:
(base) 49 % package require twapi 2.0b12 (base) 50 % twapi::get_shell_folder common_desktopdirectory C:\Documents and Settings\All Users\Desktop (base) 51 % twapi::get_shell_folder desktopdirectory C:\Documents and Settings\SOMEONE\Desktop
Arts and crafts of Tcl-Tk programming - Category Windows