Updated 2008-10-15 02:41:56 by Cameron

"Jeff David" <[email protected]> wrote in message news:[email protected] '''Is there any way to retrieve the desktop properties in Windows? Specifically, I am looking to retrieve the user's Active Title Bar size (which I can get by bringing up the Desktop's "Properties" dialog, clicking on the "Appearance" tab and selecting the "Active Title Bar" item).

Tom Wilkason replied: Try the procedure below on your machine (only tested on Win2K), the title height is CaptionHeight and the borderwidth is BorderWidth
 proc winGetDesktopSetting {what} {
   package require registry
   set modValues {
   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 settings

It 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 MenuBar

All 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
    (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