How to get system "single-click" and use it in a TreeView

  • Thread starter =?iso-8859-1?B?0A==?=
  • Start date
?

=?iso-8859-1?B?0A==?=

I have a customer who likes to set his desktop to single click
(Control Panel / Folder Options / General tab / Single-click).

How can I discover this system setting so that I can make the TreeViews
in my application behave like the rest of the user's system?
 
B

Ben

There may be a better way to do this, but this was the first solution
that came to mind. You can use the Microsoft.Win32.Registry and
RegistryKey objects to read the option directly from HKEY_CURRENT_USER.

The exact key we are looking for is "ShellState" within
Software\Microsoft\Windows\CurrentVersion\Explorer

Here is some quick C# code that will return a boolean value which tells
you whether or not the single-click option is enabled in the shell.

using Microsoft.Win32;

bool Shell_SingleClick()
{

RegistryKey key =
Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
byte[] shellState = (byte[])key.GetValue("ShellState");

// ShellState is an array of bytes. It appears that the 5th byte
// determines whether single-clicking is enabled.

if ((shellState[4] & 0x20) > 0)
// option is set for double-clicking
return false;

// option is set for single-clicking
return true;

}
 
?

=?iso-8859-1?B?0A==?=

Yeah, undocumented is unsafe - but it works. What can you do...
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top