+void RegTreeCtrl::GoTo(const wxString& location)
+{
+ wxStringTokenizer tk(location, _T("\\"));
+
+ wxTreeItemId id = GetRootItem();
+
+ while ( tk.HasMoreTokens() ) {
+ wxString subkey = tk.GetNextToken();
+
+ wxTreeItemId idCurrent = id;
+ if ( !IsExpanded(idCurrent) )
+ Expand(idCurrent);
+
+ long dummy;
+ id = GetFirstChild(idCurrent, dummy);
+
+ if ( idCurrent == GetRootItem() ) {
+ // special case: we understand both HKCU and HKEY_CURRENT_USER here
+ for ( size_t key = 0; key < wxRegKey::nStdKeys; key++ ) {
+ if ( subkey == wxRegKey::GetStdKeyName(key) ||
+ subkey == wxRegKey::GetStdKeyShortName(key) ) {
+ break;
+ }
+
+ id = GetNextChild(idCurrent, dummy);
+ }
+ }
+ else {
+ // enum all children
+ while ( id.IsOk() ) {
+ if ( subkey == ((TreeNode *)GetItemData(id))->m_strName )
+ break;
+
+ id = GetNextChild(idCurrent, dummy);
+ }
+ }
+
+ if ( !id.IsOk() ) {
+ wxLogError(_T("No such key '%s'."), location.c_str());
+
+ return;
+ }
+ }
+
+ if ( id.IsOk() )
+ SelectItem(id);
+}
+