]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/regtest/regtest.cpp
Change version to 3.0.0.
[wxWidgets.git] / samples / regtest / regtest.cpp
index 76845feb09506282befaac326e0fd75064307434..04990e58e47b6cfe9511aee1ad93ed4228117ec0 100644 (file)
@@ -4,9 +4,8 @@
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     03.04.98
-// RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -31,7 +30,7 @@
 #include "wx/imaglist.h"
 #include "wx/tokenzr.h"
 
-#if wxUSE_CONFIG_NATIVE && defined( __WXMSW__ )
+#if wxUSE_CONFIG_NATIVE && defined( __WINDOWS__ )
 #   define DO_REGTEST 1
 #else
 #   define DO_REGTEST 0
@@ -102,6 +101,7 @@ public:
     void CreateNewKey(const wxString& strName);
     void CreateNewTextValue(const wxString& strName);
     void CreateNewBinaryValue(const wxString& strName);
+    void SetRegistryView(wxRegKey::WOW64ViewMode viewMode);
 
     // information
     bool IsKeySelected() const;
@@ -114,17 +114,18 @@ private:
     public:
         RegTreeCtrl  *m_pTree;     // must be !NULL
         TreeNode     *m_pParent;    // NULL only for the root node
-        long          m_id;         // the id of the tree control item
+        wxTreeItemId  m_id;         // the id of the tree control item
         wxString      m_strName;    // name of the key/value
         TreeChildren  m_aChildren;  // array of subkeys/values
         bool          m_bKey;       // key or value?
         wxRegKey     *m_pKey;       // only may be !NULL if m_bKey == true
+        wxRegKey::WOW64ViewMode m_viewMode; // How to view the registry.
 
         // trivial accessors
-        long      Id()     const { return m_id;              }
-        bool      IsRoot() const { return m_pParent == NULL; }
-        bool      IsKey()  const { return m_bKey;            }
-        TreeNode *Parent() const { return m_pParent;         }
+        wxTreeItemId  Id()     const { return m_id;              }
+        bool          IsRoot() const { return m_pParent == NULL; }
+        bool          IsKey()  const { return m_bKey;            }
+        TreeNode     *Parent() const { return m_pParent;         }
 
         // notifications
         bool OnExpand();
@@ -135,6 +136,7 @@ private:
         bool DeleteChild(TreeNode *child);
         void DestroyChildren();
         const wxChar *FullName() const;
+        void SetRegistryView(wxRegKey::WOW64ViewMode viewMode);
 
         // get the associated key: make sure the pointer is !NULL
         wxRegKey& Key() { if ( !m_pKey ) OnExpand(); return *m_pKey; }
@@ -155,15 +157,18 @@ private:
 
     wxString     m_nameOld;           // the initial value of item being renamed
 
+    wxRegKey::WOW64ViewMode m_viewMode; // Registry view to use for keys.
+
     TreeNode *GetNode(const wxTreeEvent& event)
-        { return (TreeNode *)GetItemData((WXHTREEITEM)event.GetItem()); }
+        { return (TreeNode *)GetItemData(event.GetItem()); }
 
 public:
     // create a new node and insert it to the tree
     TreeNode *InsertNewTreeNode(TreeNode *pParent,
         const wxString& strName,
         int idImage = RegImageList::ClosedKey,
-        const wxString *pstrValue = NULL);
+        const wxString *pstrValue = NULL,
+        wxRegKey::WOW64ViewMode viewMode = wxRegKey::WOW64ViewMode_Default);
 
     // add standard registry keys
     void AddStdKeys();
@@ -181,7 +186,7 @@ class RegFrame : public wxFrame
 {
 public:
     // ctor & dtor
-    RegFrame(wxFrame *parent, wxChar *title, int x, int y, int w, int h);
+    RegFrame(wxFrame *parent, const wxChar *title, int x, int y, int w, int h);
     virtual ~RegFrame();
 
     // callbacks
@@ -203,6 +208,8 @@ public:
 
     void OnInfo     (wxCommandEvent& event);
 
+    void OnViewChange (wxCommandEvent& event);
+
     DECLARE_EVENT_TABLE()
 
 private:
@@ -232,8 +239,12 @@ enum
     Menu_NewBinary,
     Menu_Delete,
     Menu_Info,
+    Menu_View,
+    Menu_ViewDefault,
+    Menu_View32,
+    Menu_View64,
 
-    Ctrl_RegTree  = 200,
+    Ctrl_RegTree  = 200
 };
 
 // ----------------------------------------------------------------------------
@@ -241,27 +252,31 @@ enum
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(RegFrame, wxFrame)
-    EVT_MENU(Menu_Test,     RegFrame::OnTest)
-    EVT_MENU(Menu_About,    RegFrame::OnAbout)
-    EVT_MENU(Menu_Quit,     RegFrame::OnQuit)
-    EVT_MENU(Menu_GoTo,     RegFrame::OnGoTo)
-    EVT_MENU(Menu_Expand,   RegFrame::OnExpand)
-    EVT_MENU(Menu_Collapse, RegFrame::OnCollapse)
-    EVT_MENU(Menu_Toggle,   RegFrame::OnToggle)
-    EVT_MENU(Menu_Refresh,  RegFrame::OnRefresh)
-    EVT_MENU(Menu_Delete,   RegFrame::OnDelete)
-    EVT_MENU(Menu_NewKey,   RegFrame::OnNewKey)
-    EVT_MENU(Menu_NewText,  RegFrame::OnNewText)
-    EVT_MENU(Menu_NewBinary,RegFrame::OnNewBinary)
-    EVT_MENU(Menu_Info,     RegFrame::OnInfo)
+    EVT_MENU(Menu_Test,        RegFrame::OnTest)
+    EVT_MENU(Menu_About,       RegFrame::OnAbout)
+    EVT_MENU(Menu_Quit,        RegFrame::OnQuit)
+    EVT_MENU(Menu_GoTo,        RegFrame::OnGoTo)
+    EVT_MENU(Menu_Expand,      RegFrame::OnExpand)
+    EVT_MENU(Menu_Collapse,    RegFrame::OnCollapse)
+    EVT_MENU(Menu_Toggle,      RegFrame::OnToggle)
+    EVT_MENU(Menu_Refresh,     RegFrame::OnRefresh)
+    EVT_MENU(Menu_Delete,      RegFrame::OnDelete)
+    EVT_MENU(Menu_NewKey,      RegFrame::OnNewKey)
+    EVT_MENU(Menu_NewText,     RegFrame::OnNewText)
+    EVT_MENU(Menu_NewBinary,   RegFrame::OnNewBinary)
+    EVT_MENU(Menu_Info,        RegFrame::OnInfo)
+    EVT_MENU(Menu_ViewDefault, RegFrame::OnViewChange)
+    EVT_MENU(Menu_View32,      RegFrame::OnViewChange)
+    EVT_MENU(Menu_View64,      RegFrame::OnViewChange)
 END_EVENT_TABLE()
 
 #if DO_REGTEST
 
 BEGIN_EVENT_TABLE(RegTreeCtrl, wxTreeCtrl)
-    EVT_TREE_DELETE_ITEM   (Ctrl_RegTree, RegTreeCtrl::OnDeleteItem)
-    EVT_TREE_ITEM_EXPANDING(Ctrl_RegTree, RegTreeCtrl::OnItemExpanding)
-    EVT_TREE_SEL_CHANGED   (Ctrl_RegTree, RegTreeCtrl::OnSelChanged)
+    EVT_TREE_DELETE_ITEM    (Ctrl_RegTree, RegTreeCtrl::OnDeleteItem)
+    EVT_TREE_ITEM_EXPANDING (Ctrl_RegTree, RegTreeCtrl::OnItemExpanding)
+    EVT_TREE_ITEM_COLLAPSING(Ctrl_RegTree, RegTreeCtrl::OnItemExpanding)
+    EVT_TREE_SEL_CHANGED    (Ctrl_RegTree, RegTreeCtrl::OnSelChanged)
 
     EVT_TREE_BEGIN_LABEL_EDIT(Ctrl_RegTree, RegTreeCtrl::OnBeginEdit)
     EVT_TREE_END_LABEL_EDIT  (Ctrl_RegTree, RegTreeCtrl::OnEndEdit)
@@ -289,23 +304,38 @@ END_EVENT_TABLE()
 wxMenu *CreateRegistryMenu()
 {
     wxMenu *pMenuNew = new wxMenu;
-    pMenuNew->Append(Menu_NewKey,    _T("&Key"),          _T("Create a new key"));
+    pMenuNew->Append(Menu_NewKey,    wxT("&Key"),          wxT("Create a new key"));
     pMenuNew->AppendSeparator();
-    pMenuNew->Append(Menu_NewText,   _T("&Text value"),   _T("Create a new text value"));
-    pMenuNew->Append(Menu_NewBinary, _T("&Binary value"), _T("Create a new binary value"));
+    pMenuNew->Append(Menu_NewText,   wxT("&Text value"),   wxT("Create a new text value"));
+    pMenuNew->Append(Menu_NewBinary, wxT("&Binary value"), wxT("Create a new binary value"));
+
+    wxMenu *pMenuView = new wxMenu;
+    pMenuView->AppendRadioItem(
+        Menu_ViewDefault,
+        wxT("&Default"),
+        wxT("Default registry view for the program environment."));
+    pMenuView->AppendRadioItem(
+        Menu_View32,
+        wxT("32-bit Registry"),
+        wxT("View 32-bit registry."));
+    pMenuView->AppendRadioItem(
+        Menu_View64,
+        wxT("64-bit Registry"),
+        wxT("View 64-bit registry."));
 
     wxMenu *pMenuReg = new wxMenu;
-    pMenuReg->Append(Menu_New, _T("&New"), pMenuNew);
-    pMenuReg->Append(Menu_Delete,   _T("&Delete..."), _T("Delete selected key/value"));
+    pMenuReg->Append(Menu_New, wxT("&New"), pMenuNew);
+    pMenuReg->Append(Menu_Delete,   wxT("&Delete..."), wxT("Delete selected key/value"));
     pMenuReg->AppendSeparator();
-    pMenuReg->Append(Menu_GoTo,     _T("&Go to...\tCtrl-G"),    _T("Go to registry key"));
-    pMenuReg->Append(Menu_Expand,   _T("&Expand"),    _T("Expand current key"));
-    pMenuReg->Append(Menu_Collapse, _T("&Collapse"),  _T("Collapse current key"));
-    pMenuReg->Append(Menu_Toggle,   _T("&Toggle"),    _T("Toggle current key"));
+    pMenuReg->Append(Menu_GoTo,     wxT("&Go to...\tCtrl-G"),    wxT("Go to registry key"));
+    pMenuReg->Append(Menu_Expand,   wxT("&Expand"),    wxT("Expand current key"));
+    pMenuReg->Append(Menu_Collapse, wxT("&Collapse"),  wxT("Collapse current key"));
+    pMenuReg->Append(Menu_Toggle,   wxT("&Toggle"),    wxT("Toggle current key"));
     pMenuReg->AppendSeparator();
-    pMenuReg->Append(Menu_Refresh,  _T("&Refresh"),   _T("Refresh the subtree"));
+    pMenuReg->Append(Menu_Refresh,  wxT("&Refresh"),   wxT("Refresh the subtree"));
+    pMenuReg->Append(Menu_View,     wxT("&View"),      pMenuView);
     pMenuReg->AppendSeparator();
-    pMenuReg->Append(Menu_Info,     _T("&Properties"),_T("Information about current selection"));
+    pMenuReg->Append(Menu_Info,     wxT("&Properties"),wxT("Information about current selection"));
 
     return pMenuReg;
 }
@@ -318,12 +348,13 @@ IMPLEMENT_APP(RegApp)
 // `Main program' equivalent, creating windows and returning main app frame
 bool RegApp::OnInit()
 {
+    if ( !wxApp::OnInit() )
+        return false;
+
     // create the main frame window and show it
-    RegFrame *frame = new RegFrame(NULL, _T("wxRegTest"), 50, 50, 600, 350);
+    RegFrame *frame = new RegFrame(NULL, wxT("wxRegTest"), 50, 50, 600, 350);
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     return true;
 }
 
@@ -331,28 +362,28 @@ bool RegApp::OnInit()
 // RegFrame
 // ----------------------------------------------------------------------------
 
-RegFrame::RegFrame(wxFrame *parent, wxChar *title, int x, int y, int w, int h)
-        : wxFrame(parent, -1, title, wxPoint(x, y), wxSize(w, h))
+RegFrame::RegFrame(wxFrame *parent, const wxChar *title, int x, int y, int w, int h)
+        : wxFrame(parent, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
 {
     // this reduces flicker effects
-    SetBackgroundColour(wxColour(255, 255, 255));
+    SetBackgroundColour(*wxWHITE);
 
     // set the icon
     // ------------
-    SetIcon(wxIcon(_T("app_icon")));
+    SetIcon(wxIcon(wxT("app_icon")));
 
     // create menu
     // -----------
     wxMenu *pMenuFile = new wxMenu;
-    pMenuFile->Append(Menu_Test, _T("Te&st"), _T("Test key creation"));
+    pMenuFile->Append(Menu_Test, wxT("Te&st"), wxT("Test key creation"));
     pMenuFile->AppendSeparator();
-    pMenuFile->Append(Menu_About, _T("&About..."), _T("Show an extraordinarly beautiful dialog"));
+    pMenuFile->Append(Menu_About, wxT("&About"), wxT("Show an extraordinarly beautiful dialog"));
     pMenuFile->AppendSeparator();
-    pMenuFile->Append(Menu_Quit,  _T("E&xit"), _T("Quit this program"));
+    pMenuFile->Append(Menu_Quit,  wxT("E&xit"), wxT("Quit this program"));
 
     wxMenuBar *pMenu = new wxMenuBar;
-    pMenu->Append(pMenuFile, _T("&File"));
-    pMenu->Append(CreateRegistryMenu(),  _T("&Registry"));
+    pMenu->Append(pMenuFile, wxT("&File"));
+    pMenu->Append(CreateRegistryMenu(),  wxT("&Registry"));
     SetMenuBar(pMenu);
 
 #if DO_REGTEST
@@ -361,9 +392,11 @@ RegFrame::RegFrame(wxFrame *parent, wxChar *title, int x, int y, int w, int h)
     m_treeCtrl = new RegTreeCtrl(this, Ctrl_RegTree);
 #endif
 
+#if wxUSE_STATUSBAR
     // create the status line
     // ----------------------
     CreateStatusBar(2);
+#endif // wxUSE_STATUSBAR
 }
 
 RegFrame::~RegFrame()
@@ -382,9 +415,9 @@ void RegFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 void RegFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
     wxMessageDialog dialog(this,
-        _T("wxRegistry sample\n")
-        _T("© 1998, 2000 Vadim Zeitlin"),
-        _T("About wxRegTest"), wxOK);
+        wxT("wxRegistry sample\n")
+        wxT("(c) 1998, 2000 Vadim Zeitlin"),
+        wxT("About wxRegTest"), wxOK);
 
     dialog.ShowModal();
 }
@@ -398,11 +431,11 @@ void RegFrame::OnTest(wxCommandEvent& WXUNUSED(event))
 
 void RegFrame::OnGoTo(wxCommandEvent& WXUNUSED(event))
 {
-    static wxString s_location = _T("HKEY_CURRENT_USER\\Software\\wxWindows");
+    static wxString s_location = wxT("HKEY_CURRENT_USER\\Software\\wxWidgets");
 
     wxString location = wxGetTextFromUser(
-        _T("Enter the location to go to:"),
-        _T("wxRegTest question"),
+        wxT("Enter the location to go to:"),
+        wxT("wxRegTest question"),
         s_location,
         this);
 
@@ -456,7 +489,7 @@ void RegFrame::OnNewKey(wxCommandEvent& WXUNUSED(event))
     if ( m_treeCtrl->IsKeySelected() )
     {
         m_treeCtrl->CreateNewKey(
-            wxGetTextFromUser(_T("Enter the name of the new key")));
+            wxGetTextFromUser(wxT("Enter the name of the new key")));
     }
 #endif
 }
@@ -467,7 +500,7 @@ void RegFrame::OnNewText(wxCommandEvent& WXUNUSED(event))
     if ( m_treeCtrl->IsKeySelected() )
     {
         m_treeCtrl->CreateNewTextValue(
-            wxGetTextFromUser(_T("Enter the name for the new text value")));
+            wxGetTextFromUser(wxT("Enter the name for the new text value")));
     }
 #endif
 }
@@ -478,7 +511,7 @@ void RegFrame::OnNewBinary(wxCommandEvent& WXUNUSED(event))
     if ( m_treeCtrl->IsKeySelected() )
     {
         m_treeCtrl->CreateNewBinaryValue(
-            wxGetTextFromUser(_T("Enter the name for the new binary value")));
+            wxGetTextFromUser(wxT("Enter the name for the new binary value")));
     }
 #endif
 }
@@ -490,14 +523,41 @@ void RegFrame::OnInfo(wxCommandEvent& WXUNUSED(event))
 #endif
 }
 
+void RegFrame::OnViewChange(wxCommandEvent& event)
+{
+#if DO_REGTEST
+    wxRegKey::WOW64ViewMode view;
+    switch ( event.GetId() )
+    {
+        case Menu_ViewDefault:
+            view = wxRegKey::WOW64ViewMode_Default;
+            break;
+
+        case Menu_View32:
+            view = wxRegKey::WOW64ViewMode_32;
+            break;
+
+        case Menu_View64:
+            view = wxRegKey::WOW64ViewMode_64;
+            break;
+
+        default:
+            wxFAIL_MSG("Unexpected event source for view change.");
+            return;
+    }
+
+    m_treeCtrl->SetRegistryView(view);
+#endif
+}
+
 // ----------------------------------------------------------------------------
 // RegImageList
 // ----------------------------------------------------------------------------
 RegImageList::RegImageList() : wxImageList(16, 16, true)
 {
     // should be in sync with enum RegImageList::RegIcon
-    static const wxChar *aszIcons[] = { _T("key1"),_T("key2"),_T("key3"),_T("value1"),_T("value2") };
-    wxString str = _T("icon_");
+    static const wxChar *aszIcons[] = { wxT("key1"),wxT("key2"),wxT("key3"),wxT("value1"),wxT("value2") };
+    wxString str = wxT("icon_");
     for ( unsigned int n = 0; n < WXSIZEOF(aszIcons); n++ )
     {
         Add(wxIcon(str + aszIcons[n], wxBITMAP_TYPE_ICO_RESOURCE));
@@ -511,10 +571,12 @@ RegImageList::RegImageList() : wxImageList(16, 16, true)
 // ----------------------------------------------------------------------------
 
 // create a new tree item and insert it into the tree
-RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent,
-                                                      const wxString& strName,
-                                                      int idImage,
-                                                      const wxString *pstrValue)
+RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(
+    TreeNode *pParent,
+    const wxString& strName,
+    int idImage,
+    const wxString *pstrValue,
+    wxRegKey::WOW64ViewMode viewMode)
 {
     // create new item & insert it
     TreeNode *pNewNode = new TreeNode;
@@ -523,6 +585,7 @@ RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent,
     pNewNode->m_strName = strName;
     pNewNode->m_bKey    = pstrValue == NULL;
     pNewNode->m_pKey    = NULL;
+    pNewNode->m_viewMode = viewMode;
     if (pParent)
     {
         pNewNode->m_id  = AppendItem(pParent->Id(),
@@ -568,6 +631,7 @@ RegTreeCtrl::RegTreeCtrl(wxWindow *parent, wxWindowID id)
     // init members
     m_draggedItem = NULL;
     m_restoreStatus = false;
+    m_viewMode = wxRegKey::WOW64ViewMode_Default;
 
     // create the image list
     // ---------------------
@@ -576,7 +640,13 @@ RegTreeCtrl::RegTreeCtrl(wxWindow *parent, wxWindowID id)
 
     // create root keys
     // ----------------
-    m_pRoot = InsertNewTreeNode(NULL, _T("Registry Root"), RegImageList::Root);
+    m_pRoot =
+        InsertNewTreeNode(
+            NULL,
+            wxT("Registry Root"),
+            RegImageList::Root,
+            NULL,
+            m_viewMode);
 
     // create popup menu
     // -----------------
@@ -594,7 +664,12 @@ void RegTreeCtrl::AddStdKeys()
 {
     for ( unsigned int ui = 0; ui < wxRegKey::nStdKeys; ui++ )
     {
-        InsertNewTreeNode(m_pRoot, wxRegKey::GetStdKeyName(ui));
+        InsertNewTreeNode(
+            m_pRoot,
+            wxRegKey::GetStdKeyName(ui),
+            RegImageList::ClosedKey,
+            NULL,
+            m_viewMode);
     }
 }
 
@@ -617,7 +692,7 @@ void RegTreeCtrl::OnIdle(wxIdleEvent& WXUNUSED(event))
 void RegTreeCtrl::OnRightClick(wxMouseEvent& event)
 {
     int iFlags;
-    long lId = HitTest(wxPoint(event.GetX(), event.GetY()), iFlags);
+    wxTreeItemId lId = HitTest(wxPoint(event.GetX(), event.GetY()), iFlags);
     if ( iFlags & wxTREE_HITTEST_ONITEMLABEL )
     {
         // select the item first
@@ -636,7 +711,7 @@ void RegTreeCtrl::OnDeleteItem(wxTreeEvent& WXUNUSED(event))
 // test the key creation functions
 void RegTreeCtrl::OnMenuTest()
 {
-    long lId = GetSelection();
+    wxTreeItemId lId = GetSelection();
     TreeNode *pNode = (TreeNode *)GetItemData(lId);
 
     wxCHECK_RET( pNode != NULL, wxT("tree item without data?") );
@@ -653,16 +728,16 @@ void RegTreeCtrl::OnMenuTest()
         return;
     }
 
-    wxRegKey key1(pNode->Key(), _T("key1"));
+    wxRegKey key1(pNode->Key(), wxT("key1"));
     if ( key1.Create() )
     {
-        wxRegKey key2a(key1, _T("key2a")), key2b(key1, _T("key2b"));
+        wxRegKey key2a(key1, wxT("key2a")), key2b(key1, wxT("key2b"));
         if ( key2a.Create() && key2b.Create() )
         {
             // put some values under the newly created keys
-            key1.SetValue(wxT("first_term"), _T("10"));
-            key1.SetValue(wxT("second_term"), _T("7"));
-            key2a = _T("this is the unnamed value");
+            key1.SetValue(wxT("first_term"), wxT("10"));
+            key1.SetValue(wxT("second_term"), wxT("7"));
+            key2a = wxT("this is the unnamed value");
             key2b.SetValue(wxT("sum"), 17);
 
             // refresh tree
@@ -697,14 +772,18 @@ void RegTreeCtrl::OnChar(wxKeyEvent& event)
 
 void RegTreeCtrl::OnSelChanged(wxTreeEvent& event)
 {
+#if wxUSE_STATUSBAR
     wxFrame *pFrame = (wxFrame *) wxWindow::GetParent();
     pFrame->SetStatusText(GetNode(event)->FullName(), 1);
+#else
+    wxUnusedVar(event);
+#endif // wxUSE_STATUSBAR
 }
 
 void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event)
 {
     TreeNode *pNode = GetNode(event);
-    bool bExpanding = event.GetKeyCode() == wxTREE_EXPAND_EXPAND;
+    bool bExpanding = event.GetEventType() == wxEVT_TREE_ITEM_EXPANDING;
 
     // expansion might take some time
     wxSetCursor(*wxHOURGLASS_CURSOR);
@@ -733,7 +812,7 @@ void RegTreeCtrl::OnBeginEdit(wxTreeEvent& event)
     TreeNode *pNode = GetNode(event);
     if ( pNode->IsRoot() || pNode->Parent()->IsRoot() )
     {
-        wxLogStatus(_T("This registry key can't be renamed."));
+        wxLogStatus(wxT("This registry key can't be renamed."));
 
         event.Veto();
     }
@@ -765,7 +844,7 @@ void RegTreeCtrl::OnEndEdit(wxTreeEvent& event)
 
     if ( !ok )
     {
-        wxLogError(_T("Failed to rename '%s' to '%s'."),
+        wxLogError(wxT("Failed to rename '%s' to '%s'."),
             m_nameOld.c_str(), name.c_str());
     }
 #if 0   // MSW tree ctrl doesn't like this at all, it hangs
@@ -778,7 +857,7 @@ void RegTreeCtrl::OnEndEdit(wxTreeEvent& event)
 
 void RegTreeCtrl::OnBeginDrag(wxTreeEvent& event)
 {
-    m_copyOnDrop = event.GetEventType() == wxEVT_COMMAND_TREE_BEGIN_DRAG;
+    m_copyOnDrop = event.GetEventType() == wxEVT_TREE_BEGIN_DRAG;
 
     TreeNode *pNode = GetNode(event);
     if ( pNode->IsRoot() || pNode->Parent()->IsRoot() )
@@ -835,8 +914,8 @@ void RegTreeCtrl::OnEndDrag(wxTreeEvent& event)
     nameDst << wxString(dst->FullName()).AfterFirst('\\') << '\\'
             << wxString(src->FullName()).AfterLast('\\');
 
-    wxString verb = m_copyOnDrop ? _T("copy") : _T("move");
-    wxString what = isKey ? _T("key") : _T("value");
+    wxString verb = m_copyOnDrop ? wxT("copy") : wxT("move");
+    wxString what = isKey ? wxT("key") : wxT("value");
 
     if ( wxMessageBox(wxString::Format
                         (
@@ -846,7 +925,7 @@ void RegTreeCtrl::OnEndDrag(wxTreeEvent& event)
                          nameSrc.c_str(),
                          nameDst.c_str()
                         ),
-                      _T("RegTest Confirm"),
+                      wxT("RegTest Confirm"),
                       wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) {
       return;
     }
@@ -920,7 +999,7 @@ bool RegTreeCtrl::TreeNode::OnExpand()
     if ( Parent()->IsRoot() )
     {
         // we're a standard key
-        m_pKey = new wxRegKey(m_strName);
+        m_pKey = new wxRegKey(m_strName, m_viewMode);
     }
     else
     {
@@ -946,7 +1025,12 @@ bool RegTreeCtrl::TreeNode::OnExpand()
     bCont = m_pKey->GetFirstKey(str, l);
     while ( bCont )
     {
-        m_pTree->InsertNewTreeNode(this, str, RegImageList::ClosedKey);
+        m_pTree->InsertNewTreeNode(
+            this,
+            str,
+            RegImageList::ClosedKey,
+            NULL,
+            m_viewMode);
         bCont = m_pKey->GetNextKey(str, l);
 
         // we have at least this key...
@@ -958,11 +1042,11 @@ bool RegTreeCtrl::TreeNode::OnExpand()
     while ( bCont )
     {
         wxString strItem;
-        if (str.IsEmpty())
-            strItem = _T("<default>");
+        if (str.empty())
+            strItem = wxT("<default>");
         else
             strItem = str;
-        strItem += _T(" = ");
+        strItem += wxT(" = ");
 
         // determine the appropriate icon
         RegImageList::Icon icon;
@@ -997,7 +1081,7 @@ bool RegTreeCtrl::TreeNode::OnExpand()
             icon = RegImageList::BinaryValue;
         }
 
-        m_pTree->InsertNewTreeNode(this, str, icon, &strItem);
+        m_pTree->InsertNewTreeNode(this, str, icon, &strItem, m_viewMode);
         bCont = m_pKey->GetNextValue(str, l);
 
         // we have at least this value...
@@ -1021,8 +1105,7 @@ void RegTreeCtrl::TreeNode::OnCollapse()
 {
     DestroyChildren();
 
-    delete m_pKey;
-    m_pKey = NULL;
+    wxDELETE(m_pKey);
 }
 
 void RegTreeCtrl::TreeNode::Refresh()
@@ -1082,11 +1165,8 @@ void RegTreeCtrl::TreeNode::DestroyChildren()
     size_t nCount = m_aChildren.GetCount();
     for ( size_t n = 0; n < nCount; n++ )
     {
-        long lId = m_aChildren[n]->Id();
-        // no, wxTreeCtrl will do it
-        //delete m_aChildren[n];
-        wxTreeItemId theId(lId); // Temp variable seems necessary for BC++
-        m_pTree->Delete(theId);
+        wxTreeItemId lId = m_aChildren[n]->Id();
+        m_pTree->Delete(lId);
     }
 
     m_aChildren.Empty();
@@ -1112,17 +1192,27 @@ const wxChar *RegTreeCtrl::TreeNode::FullName() const
         s_strName = Parent()->FullName();
         s_strName << wxT('\\') << m_strName;
 
-        return s_strName;
+        return s_strName.t_str();
     }
 }
 
+void RegTreeCtrl::TreeNode::SetRegistryView(wxRegKey::WOW64ViewMode viewMode)
+{
+    m_viewMode = viewMode;
+
+    // Update children with new view.
+    size_t nCount = m_aChildren.GetCount();
+    for (size_t n = 0; n < nCount; n++)
+        m_aChildren[n]->SetRegistryView(viewMode);
+}
+
 // ----------------------------------------------------------------------------
 // operations on RegTreeCtrl
 // ----------------------------------------------------------------------------
 
 void RegTreeCtrl::GoTo(const wxString& location)
 {
-    wxStringTokenizer tk(location, _T("\\"));
+    wxStringTokenizer tk(location, wxT("\\"));
 
     wxTreeItemId id = GetRootItem();
 
@@ -1165,7 +1255,7 @@ void RegTreeCtrl::GoTo(const wxString& location)
 
         if ( !id.IsOk() )
         {
-            wxLogError(_T("No such key '%s'."), location.c_str());
+            wxLogError(wxT("No such key '%s'."), location.c_str());
 
             return;
         }
@@ -1177,17 +1267,17 @@ void RegTreeCtrl::GoTo(const wxString& location)
 
 void RegTreeCtrl::DeleteSelected()
 {
-    long lCurrent = GetSelection(),
-        lParent  = GetItemParent(lCurrent);
+    wxTreeItemId lCurrent = GetSelection(),
+                 lParent  = GetItemParent(lCurrent);
 
-    if ( lParent == 0 )
+    if ( lParent == GetRootItem() )
     {
         wxLogError(wxT("Can't delete root key."));
         return;
     }
 
     TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent),
-        *pParent  = (TreeNode *)GetItemData(lParent);
+             *pParent  = (TreeNode *)GetItemData(lParent);
 
     wxCHECK_RET(pCurrent && pParent, wxT("either node or parent without data?"));
 
@@ -1197,13 +1287,13 @@ void RegTreeCtrl::DeleteSelected()
         return;
     }
 
-    wxString what = pCurrent->IsKey() ? _T("key") : _T("value");
+    wxString what = pCurrent->IsKey() ? wxT("key") : wxT("value");
     if ( wxMessageBox(wxString::Format
         (
             wxT("Do you really want to delete this %s?"),
             what.c_str()
         ),
-        _T("Confirmation"),
+        wxT("Confirmation"),
         wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES )
     {
         return;
@@ -1214,7 +1304,7 @@ void RegTreeCtrl::DeleteSelected()
 
 void RegTreeCtrl::CreateNewKey(const wxString& strName)
 {
-    long lCurrent = GetSelection();
+    wxTreeItemId lCurrent = GetSelection();
     TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent);
 
     wxCHECK_RET( pCurrent != NULL, wxT("node without data?") );
@@ -1234,7 +1324,7 @@ void RegTreeCtrl::CreateNewKey(const wxString& strName)
 
 void RegTreeCtrl::CreateNewTextValue(const wxString& strName)
 {
-    long lCurrent = GetSelection();
+    wxTreeItemId lCurrent = GetSelection();
     TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent);
 
     wxCHECK_RET( pCurrent != NULL, wxT("node without data?") );
@@ -1253,7 +1343,7 @@ void RegTreeCtrl::CreateNewTextValue(const wxString& strName)
 
 void RegTreeCtrl::CreateNewBinaryValue(const wxString& strName)
 {
-    long lCurrent = GetSelection();
+    wxTreeItemId lCurrent = GetSelection();
     TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent);
 
     wxCHECK_RET( pCurrent != NULL, wxT("node without data?") );
@@ -1270,9 +1360,16 @@ void RegTreeCtrl::CreateNewBinaryValue(const wxString& strName)
         pCurrent->Refresh();
 }
 
+void RegTreeCtrl::SetRegistryView(wxRegKey::WOW64ViewMode viewMode)
+{
+    m_viewMode = viewMode;
+    m_pRoot->SetRegistryView(viewMode);
+    m_pRoot->Refresh();
+}
+
 void RegTreeCtrl::ShowProperties()
 {
-    long lCurrent = GetSelection();
+    wxTreeItemId lCurrent = GetSelection();
     TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent);
 
     if ( !pCurrent || pCurrent->IsRoot() )
@@ -1315,7 +1412,7 @@ void RegTreeCtrl::ShowProperties()
 
 bool RegTreeCtrl::IsKeySelected() const
 {
-    long lCurrent = GetSelection();
+    wxTreeItemId lCurrent = GetSelection();
     TreeNode *pCurrent = (TreeNode *) GetItemData(lCurrent);
 
     wxCHECK( pCurrent != NULL, false );
@@ -1325,7 +1422,7 @@ bool RegTreeCtrl::IsKeySelected() const
 
 void RegTreeCtrl::DoRefresh()
 {
-    long lId = GetSelection();
+    wxTreeItemId lId = GetSelection();
     if ( !lId )
         return;