[RAPPS] Improvements & multiple selections
[reactos.git] / reactos / base / applications / rapps / gui.cpp
index 5e51ce9..917767d 100644 (file)
@@ -1,6 +1,7 @@
 /* PROJECT:     ReactOS CE Applications Manager
  * LICENSE:     GPL - See COPYING in the top level directory
- * AUTHORS:     David Quintana <gigaherz@gmail.com>
+ * AUTHORS:     David Quintana             <gigaherz@gmail.com>
+ *              Alexander Shaposhnikov     <chaez.san@gmail.com>
  */
 
 #include "rapps.h"
 
 HWND hListView = NULL;
 
+class CAvailableAppView
+{
+    static inline VOID InsertTextAfterLoaded_RichEdit(UINT uStringID,
+                                                      const ATL::CStringW& szText,
+                                                      DWORD StringFlags,
+                                                      DWORD TextFlags)
+    {
+        ATL::CStringW szLoadedText;
+        if (!szText.IsEmpty() && szLoadedText.LoadStringW(hInst, uStringID))
+        {
+            InsertRichEditText(szLoadedText, StringFlags);
+            InsertRichEditText(szText, TextFlags);
+        }
+    }
+
+    static inline VOID InsertLoadedTextNewl_RichEdit(UINT uStringID,
+                                                     DWORD StringFlags)
+    {
+        ATL::CStringW szLoadedText;
+        if (szLoadedText.LoadStringW(hInst, uStringID))
+        {
+            InsertRichEditText(L"\n", 0);
+            InsertRichEditText(szLoadedText, StringFlags);
+            InsertRichEditText(L"\n", 0);
+        }
+    }
+
+    static VOID InsertVersionInfo_RichEdit(CAvailableApplicationInfo* Info)
+    {
+        if (Info->IsInstalled())
+        {
+            if (Info->HasInstalledVersion())
+            {
+                if (Info->HasUpdate())
+                    InsertLoadedTextNewl_RichEdit(IDS_STATUS_UPDATE_AVAILABLE, CFE_ITALIC);
+                else
+                    InsertLoadedTextNewl_RichEdit(IDS_STATUS_INSTALLED, CFE_ITALIC);
+
+                InsertTextAfterLoaded_RichEdit(IDS_AINFO_VERSION, Info->szInstalledVersion, CFE_BOLD, 0);
+            }
+            else
+            {
+                InsertLoadedTextNewl_RichEdit(IDS_STATUS_INSTALLED, CFE_ITALIC);
+            }
+        }
+        else
+        {
+            InsertLoadedTextNewl_RichEdit(IDS_STATUS_NOTINSTALLED, CFE_ITALIC);
+        }
+
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_AVAILABLEVERSION, Info->szVersion, CFE_BOLD, 0);
+    }
+
+    static VOID InsertLicenseInfo_RichEdit(CAvailableApplicationInfo* Info)
+    {
+        ATL::CStringW szLicense;
+        switch (Info->LicenseType)
+        {
+        case LICENSE_TYPE::OpenSource:
+            szLicense.LoadStringW(hInst, IDS_LICENSE_OPENSOURCE);
+            break;
+        case LICENSE_TYPE::Freeware:
+            szLicense.LoadStringW(hInst, IDS_LICENSE_FREEWARE);
+            break;
+        case LICENSE_TYPE::Trial:
+            szLicense.LoadStringW(hInst, IDS_LICENSE_TRIAL);
+            break;
+        default:
+            InsertTextAfterLoaded_RichEdit(IDS_AINFO_LICENSE, Info->szLicense, CFE_BOLD, 0);
+            return;
+        }
+
+        szLicense += L" (" + Info->szLicense + L")";
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_LICENSE, szLicense, CFE_BOLD, 0);
+    }
+
+    static VOID InsertLanguageInfo_RichEdit(CAvailableApplicationInfo* Info)
+    {
+        if (!Info->HasLanguageInfo())
+        {
+            return;
+        }
+
+        const INT nTranslations = Info->Languages.GetSize();
+        ATL::CStringW szLangInfo;
+        ATL::CStringW szLoadedTextAvailability;
+        ATL::CStringW szLoadedAInfoText;
+        szLoadedAInfoText.LoadStringW(IDS_AINFO_LANGUAGES);
+
+
+        //TODO: replace those hardcoded strings
+        if (Info->HasNativeLanguage())
+        {
+            szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_AVAILABLE_TRANSLATION);
+            if (nTranslations > 1)
+            {
+                szLangInfo.Format(L" (+%d more)", nTranslations - 1);
+            }
+            else
+            {
+                szLangInfo.LoadStringW(IDS_LANGUAGE_SINGLE);
+                szLangInfo = L" (" + szLangInfo + L")";
+            }
+        }
+        else if (Info->HasEnglishLanguage())
+        {
+            szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_ENGLISH_TRANSLATION);
+            if (nTranslations > 1)
+            {
+                szLangInfo.Format(L" (+%d available)", nTranslations - 1);
+            }
+            else
+            {
+                szLangInfo.LoadStringW(IDS_LANGUAGE_SINGLE);
+                szLangInfo = L" (" + szLangInfo + L")";
+            }
+        }
+        else
+        {
+            szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_NO_TRANSLATION);
+        }
+
+        InsertRichEditText(szLoadedAInfoText, CFE_BOLD);
+        InsertRichEditText(szLoadedTextAvailability, NULL);
+        InsertRichEditText(szLangInfo, CFE_ITALIC);
+    }
+
+public:
+    static BOOL ShowAvailableAppInfo(INT Index)
+    {
+        CAvailableApplicationInfo* Info = (CAvailableApplicationInfo*) ListViewGetlParam(Index);
+        if (!Info) return FALSE;
+
+        NewRichEditText(Info->szName, CFE_BOLD);
+        InsertVersionInfo_RichEdit(Info);
+        InsertLicenseInfo_RichEdit(Info);
+        InsertLanguageInfo_RichEdit(Info);
+
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD, CFE_LINK);
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_DESCRIPTION, Info->szDesc, CFE_BOLD, 0);
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_URLDOWNLOAD, Info->szUrlDownload, CFE_BOLD, CFE_LINK);
+
+        return TRUE;
+    }
+};
+
 class CMainToolbar :
     public CUiWindow< CToolbar<> >
 {
@@ -31,17 +179,18 @@ class CMainToolbar :
     WCHAR szInstallBtn[MAX_STR_LEN];
     WCHAR szUninstallBtn[MAX_STR_LEN];
     WCHAR szModifyBtn[MAX_STR_LEN];
+    WCHAR szSelectAll[MAX_STR_LEN];
 
     VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex)
     {
         HICON hImage;
 
-        if (!(hImage = (HICON) LoadImage(hInst,
-            MAKEINTRESOURCE(ImageIndex),
-            IMAGE_ICON,
-            TOOLBAR_HEIGHT,
-            TOOLBAR_HEIGHT,
-            0)))
+        if (!(hImage = (HICON) LoadImageW(hInst,
+                                          MAKEINTRESOURCE(ImageIndex),
+                                          IMAGE_ICON,
+                                          TOOLBAR_HEIGHT,
+                                          TOOLBAR_HEIGHT,
+                                          0)))
         {
             /* TODO: Error message */
         }
@@ -56,10 +205,10 @@ class CMainToolbar :
 
         /* Create the toolbar icon image list */
         hImageList = ImageList_Create(TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CXSMICON),
-            TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CYSMICON),
-            ILC_MASK | GetSystemColorDepth(),
-            1,
-            1);
+                                      TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CYSMICON),
+                                      ILC_MASK | GetSystemColorDepth(),
+                                      1,
+                                      1);
         if (!hImageList)
         {
             /* TODO: Error message */
@@ -69,6 +218,7 @@ class CMainToolbar :
         AddImageToImageList(hImageList, IDI_INSTALL);
         AddImageToImageList(hImageList, IDI_UNINSTALL);
         AddImageToImageList(hImageList, IDI_MODIFY);
+        AddImageToImageList(hImageList, IDI_CHECK_ALL);
         AddImageToImageList(hImageList, IDI_REFRESH);
         AddImageToImageList(hImageList, IDI_UPDATE_DB);
         AddImageToImageList(hImageList, IDI_SETTINGS);
@@ -107,7 +257,7 @@ public:
         case ID_REFRESH:
             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH);
             break;
-           
+
         case ID_RESETDB:
             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UPDATE_DB);
             break;
@@ -116,35 +266,33 @@ public:
 
     HWND Create(HWND hwndParent)
     {
-        static TBBUTTON Buttons [] =
+        HIMAGELIST hImageList;
+
+        // buttons
+        static TBBUTTON Buttons[] =
         {   /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
             { 0, ID_INSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR) szInstallBtn },
             { 1, ID_UNINSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR) szUninstallBtn },
             { 2, ID_MODIFY, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR) szModifyBtn },
-            { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
-            { 3, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
-            { 4, ID_RESETDB,   TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0},
-            { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
-            { 5, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
-            { 6, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 }
+            { 3, ID_CHECK_ALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE,{0}, 0, (INT_PTR) szSelectAll},
+            {-1, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
+            { 4, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
+            { 5, ID_RESETDB,   TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
+            {-1, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
+            { 6, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
+            { 7, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
         };
 
-        INT NumButtons = _countof(Buttons);
-        HIMAGELIST hImageList;
-
         LoadStringW(hInst, IDS_INSTALL, szInstallBtn, _countof(szInstallBtn));
         LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, _countof(szUninstallBtn));
         LoadStringW(hInst, IDS_MODIFY, szModifyBtn, _countof(szModifyBtn));
+        LoadStringW(hInst, IDS_SELECT_ALL, szSelectAll, _countof(szSelectAll));
 
-        m_hWnd = CreateWindowExW(0,
-            TOOLBARCLASSNAMEW,
-            NULL,
-            WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_LIST,
-            0, 0, 0, 0,
-            hwndParent,
-            0,
-            hInst,
-            NULL);
+        m_hWnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
+                                 WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_LIST,
+                                 0, 0, 0, 0,
+                                 hwndParent,
+                                 0, hInst, NULL);
 
         if (!m_hWnd)
         {
@@ -165,7 +313,7 @@ public:
 
         ImageList_Destroy((HIMAGELIST) SetImageList(hImageList));
 
-        AddButtons(NumButtons, Buttons);
+        AddButtons(_countof(Buttons), Buttons);
 
         return m_hWnd;
     }
@@ -180,6 +328,7 @@ class CAppsListView :
         int iSubItem;
     };
 
+    BOOL HasAllChecked;
 public:
     BOOL bAscending;
 
@@ -190,7 +339,7 @@ public:
 
     VOID ColumnClick(LPNMLISTVIEW pnmv)
     {
-        SortContext ctx = { this, pnmv->iSubItem };
+        SortContext ctx = {this, pnmv->iSubItem};
 
         SortItems(s_CompareFunc, &ctx);
 
@@ -223,6 +372,11 @@ public:
         return (PVOID) Item.lParam;
     }
 
+    BOOL AddColumn(INT Index, ATL::CStringW& Text, INT Width, INT Format)
+    {
+        return AddColumn(Index, const_cast<LPWSTR>(Text.GetString()), Width, Format);
+    }
+
     BOOL AddColumn(INT Index, LPWSTR lpText, INT Width, INT Format)
     {
         LV_COLUMN Column;
@@ -258,45 +412,135 @@ public:
         SortContext * ctx = ((SortContext*) lParamSort);
         return ctx->lvw->CompareFunc(lParam1, lParam2, ctx->iSubItem);
     }
-    
+
     INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem)
     {
-        WCHAR Item1[MAX_STR_LEN], Item2[MAX_STR_LEN];
-        LVFINDINFO IndexInfo;
+        ATL::CStringW Item1, Item2;
+        LVFINDINFOW IndexInfo;
         INT Index;
 
         IndexInfo.flags = LVFI_PARAM;
 
         IndexInfo.lParam = lParam1;
         Index = FindItem(-1, &IndexInfo);
-        GetItemText(Index, iSubItem, Item1, _countof(Item1));
+        GetItemText(Index, iSubItem, Item1.GetBuffer(MAX_STR_LEN), MAX_STR_LEN);
+        Item1.ReleaseBuffer();
 
         IndexInfo.lParam = lParam2;
         Index = FindItem(-1, &IndexInfo);
-        GetItemText(Index, iSubItem, Item2, _countof(Item2));
+        GetItemText(Index, iSubItem, Item2.GetBuffer(MAX_STR_LEN), MAX_STR_LEN);
+        Item2.ReleaseBuffer();
 
         if (bAscending)
-            return wcscmp(Item2, Item1);
+            return Item2 == Item1;
         else
-            return wcscmp(Item1, Item2);
+            return Item1 == Item2;
 
         return 0;
     }
 
     HWND Create(HWND hwndParent)
     {
-        RECT r = { 205, 28, 465, 250 };
+        RECT r = {205, 28, 465, 250};
         DWORD style = WS_CHILD | WS_VISIBLE | LVS_SORTASCENDING | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS;
         HMENU menu = GetSubMenu(LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_APPLICATIONMENU)), 0);
-        
+
         HWND hwnd = CListView::Create(hwndParent, r, NULL, style, WS_EX_CLIENTEDGE, menu);
 
         if (hwnd)
-            SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
+        {
+            SetExtendedListViewStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT );
+        }
 
         return hwnd;
     }
 
+    VOID CheckAll()
+    {
+        if (HasAllChecked)
+        {
+            
+        }
+    }
+};
+
+class CSideTreeView :
+    public CUiWindow<CTreeView>
+{
+    HIMAGELIST hImageTreeView = ImageList_Create(TREEVIEW_ICON_SIZE, TREEVIEW_ICON_SIZE,
+                                                 GetSystemColorDepth() | ILC_MASK,
+                                                 0, 1);
+
+public:
+    HTREEITEM AddItem(HTREEITEM hParent, ATL::CStringW &Text, INT Image, INT SelectedImage, LPARAM lParam)
+    {
+        return CUiWindow<CTreeView>::AddItem(hParent, const_cast<LPWSTR>(Text.GetString()), Image, SelectedImage, lParam);
+    }
+
+    HTREEITEM AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex)
+    {
+        ATL::CStringW szText;
+        INT Index;
+        HICON hIcon;
+
+        hIcon = (HICON) LoadImage(hInst,
+                                  MAKEINTRESOURCE(IconIndex),
+                                  IMAGE_ICON,
+                                  TREEVIEW_ICON_SIZE,
+                                  TREEVIEW_ICON_SIZE,
+                                  LR_CREATEDIBSECTION);
+        if (hIcon)
+        {
+            Index = ImageList_AddIcon(hImageTreeView, hIcon);
+            DestroyIcon(hIcon);
+        }
+
+        szText.LoadStringW(hInst, TextIndex);
+        return AddItem(hRootItem, szText, Index, Index, TextIndex);
+    }
+
+    HIMAGELIST SetImageList()
+    {
+        return CUiWindow<CTreeView>::SetImageList(hImageTreeView, TVSIL_NORMAL);
+    }
+
+    VOID DestroyImageList()
+    {
+        if (hImageTreeView)
+            ImageList_Destroy(hImageTreeView);
+    }
+
+    ~CSideTreeView()
+    {
+        DestroyImageList();
+        CUiWindow<CTreeView>::~CUiWindow();
+    }
+};
+
+class CSearchBar :
+    public CWindow
+{
+public:
+    VOID SetText(LPCWSTR lpszText)
+    {
+        SendMessageW(SB_SETTEXT, SBT_NOBORDERS, (LPARAM) lpszText);
+    }
+
+    HWND Create(HWND hwndParent)
+    {
+        ATL::CStringW szBuf;
+        m_hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Edit", NULL,
+                                 WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
+                                 0, 0, 200, 22,
+                                 hwndParent, (HMENU) NULL,
+                                 hInst, 0);
+
+        SendMessageW(WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
+        szBuf.LoadStringW(hInst, IDS_SEARCH_TEXT);
+        SetWindowTextW(szBuf);
+        return m_hWnd;
+    }
+
 };
 
 class CMainWindow :
@@ -309,65 +553,48 @@ class CMainWindow :
     CMainToolbar * m_Toolbar;
     CAppsListView * m_ListView;
 
-    CUiWindow<CTreeView> * m_TreeView;
+    CSideTreeView * m_TreeView;
     CUiWindow<CStatusBar> * m_StatusBar;
     CUiWindow<CRichEdit> * m_RichEdit;
 
-    CUiWindow<> * m_SearchBar;
+    CUiWindow<CSearchBar> * m_SearchBar;
 
-    HIMAGELIST hImageTreeView;
-
-    PWSTR pLink;
+    LPWSTR pLink;
 
     BOOL SearchEnabled;
 
+    CAvailableApps m_AvailableApps;
+
 public:
     CMainWindow() :
         m_ClientPanel(NULL),
-        hImageTreeView(NULL),
         pLink(NULL),
-        SearchEnabled(TRUE)
+        SearchEnabled(FALSE)
     {
     }
 
 private:
-
     VOID InitApplicationsList(VOID)
     {
-        WCHAR szText[MAX_STR_LEN];
+        ATL::CStringW szText;
 
         /* Add columns to ListView */
-        LoadStringW(hInst, IDS_APP_NAME, szText, _countof(szText));
+        szText.LoadStringW(hInst, IDS_APP_NAME);
         m_ListView->AddColumn(0, szText, 200, LVCFMT_LEFT);
 
-        LoadStringW(hInst, IDS_APP_INST_VERSION, szText, _countof(szText));
+        szText.LoadStringW(hInst, IDS_APP_INST_VERSION);
         m_ListView->AddColumn(1, szText, 90, LVCFMT_RIGHT);
 
-        LoadStringW(hInst, IDS_APP_DESCRIPTION, szText, _countof(szText));
+        szText.LoadStringW(hInst, IDS_APP_DESCRIPTION);
         m_ListView->AddColumn(3, szText, 250, LVCFMT_LEFT);
 
-        UpdateApplicationsList(ENUM_ALL_COMPONENTS);
+        // Unnesesary since the list updates on every TreeView selection
+        // UpdateApplicationsList(ENUM_ALL_COMPONENTS);
     }
 
     HTREEITEM AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex)
     {
-        WCHAR szText[MAX_STR_LEN];
-        INT Index;
-        HICON hIcon;
-
-        hIcon = (HICON) LoadImage(hInst,
-            MAKEINTRESOURCE(IconIndex),
-            IMAGE_ICON,
-            TREEVIEW_ICON_SIZE,
-            TREEVIEW_ICON_SIZE,
-            LR_CREATEDIBSECTION);
-
-        Index = ImageList_AddIcon(hImageTreeView, hIcon);
-        DestroyIcon(hIcon);
-
-        LoadStringW(hInst, TextIndex, szText, _countof(szText));
-
-        return m_TreeView->AddItem(hRootItem, szText, Index, Index, TextIndex);
+        return m_TreeView->AddCategory(hRootItem, TextIndex, IconIndex);
     }
 
     VOID InitCategoriesList(VOID)
@@ -391,7 +618,7 @@ private:
         AddCategory(hRootItem, IDS_CAT_LIBS, IDI_CAT_LIBS);
         AddCategory(hRootItem, IDS_CAT_OTHER, IDI_CAT_OTHER);
 
-        m_TreeView->SetImageList(hImageTreeView, TVSIL_NORMAL);
+        m_TreeView->SetImageList();
         m_TreeView->Expand(hRootItem, TVE_EXPAND);
         m_TreeView->SelectItem(hRootItem);
     }
@@ -403,7 +630,7 @@ private:
         m_StatusBar->m_HorizontalAlignment = UiAlign_Stretch;
         m_ClientPanel->Children().Append(m_StatusBar);
 
-        return m_StatusBar->Create(m_hWnd, (HMENU)IDC_STATUSBAR) != NULL;
+        return m_StatusBar->Create(m_hWnd, (HMENU) IDC_STATUSBAR) != NULL;
     }
 
     BOOL CreateToolbar()
@@ -412,17 +639,17 @@ private:
         m_Toolbar->m_VerticalAlignment = UiAlign_LeftTop;
         m_Toolbar->m_HorizontalAlignment = UiAlign_Stretch;
         m_ClientPanel->Children().Append(m_Toolbar);
-        
+
         return m_Toolbar->Create(m_hWnd) != NULL;
     }
 
     BOOL CreateTreeView()
     {
-        m_TreeView = new CUiWindow<CTreeView>();
+        m_TreeView = new CSideTreeView();
         m_TreeView->m_VerticalAlignment = UiAlign_Stretch;
         m_TreeView->m_HorizontalAlignment = UiAlign_Stretch;
         m_VSplitter->First().Append(m_TreeView);
-        
+
         return m_TreeView->Create(m_hWnd) != NULL;
     }
 
@@ -470,7 +697,7 @@ private:
         m_HSplitter->m_Horizontal = TRUE;
         m_HSplitter->m_Pos = 32768;
         m_HSplitter->m_MinFirst = 300;
-        m_HSplitter->m_MinSecond = 80;
+        m_HSplitter->m_MinSecond = 150;
         m_VSplitter->Second().Append(m_HSplitter);
 
         return m_HSplitter->Create(m_hWnd) != NULL;
@@ -478,37 +705,13 @@ private:
 
     BOOL CreateSearchBar(VOID)
     {
-        WCHAR szBuf[MAX_STR_LEN];
-
-        // TODO: WRAPPER
-        m_SearchBar = new CUiWindow<>();
+        m_SearchBar = new CUiWindow<CSearchBar>();
         m_SearchBar->m_VerticalAlignment = UiAlign_LeftTop;
         m_SearchBar->m_HorizontalAlignment = UiAlign_RightBtm;
         m_SearchBar->m_Margin.top = 6;
         m_SearchBar->m_Margin.right = 6;
-        //m_ClientPanel->Children().Append(m_SearchBar);
-
-        HWND hwnd = CreateWindowExW(WS_EX_CLIENTEDGE,
-            L"Edit",
-            NULL,
-            WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
-            0,
-            0,
-            200,
-            22,
-            m_Toolbar->m_hWnd,
-            (HMENU) 0,
-            hInst,
-            0);
 
-        m_SearchBar->m_hWnd = hwnd;
-
-        m_SearchBar->SendMessageW(WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
-
-        LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
-        m_SearchBar->SetWindowTextW(szBuf);
-
-        return hwnd != NULL;
+        return m_SearchBar->Create(m_Toolbar->m_hWnd) != NULL;
     }
 
     BOOL CreateLayout()
@@ -548,7 +751,7 @@ private:
             ::GetWindowRect(m_StatusBar->m_hWnd, &rBottom);
 
             m_VSplitter->m_Margin.top = rTop.bottom - rTop.top;
-            m_VSplitter->m_Margin.bottom = rBottom.bottom-rBottom.top;
+            m_VSplitter->m_Margin.bottom = rBottom.bottom - rBottom.top;
         }
 
         return b;
@@ -556,23 +759,17 @@ private:
 
     BOOL InitControls()
     {
-        /* Create image list */
-        hImageTreeView = ImageList_Create(TREEVIEW_ICON_SIZE, TREEVIEW_ICON_SIZE,
-            GetSystemColorDepth() | ILC_MASK,
-            0, 1);
-
         if (CreateLayout())
         {
-            WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN];
+            ATL::CStringW szBuffer1, szBuffer2;
 
             InitApplicationsList();
 
             InitCategoriesList();
 
-            LoadStringW(hInst, IDS_APPS_COUNT, szBuffer2, _countof(szBuffer2));
-            StringCbPrintfW(szBuffer1, sizeof(szBuffer1),
-                szBuffer2,
-                m_ListView->GetItemCount());
+            szBuffer2.LoadStringW(hInst, IDS_APPS_COUNT);
+            szBuffer1.Format(szBuffer2, m_ListView->GetItemCount());
+
             m_StatusBar->SetText(szBuffer1);
             return TRUE;
         }
@@ -588,21 +785,31 @@ private:
         /* Size tool bar */
         m_Toolbar->AutoSize();
 
-
-        RECT r = { 0, 0, LOWORD(lParam), HIWORD(lParam) };
-
+        RECT r = {0, 0, LOWORD(lParam), HIWORD(lParam)};
         HDWP hdwp = NULL;
-
         int count = m_ClientPanel->CountSizableChildren();
+
         hdwp = BeginDeferWindowPos(count);
-        if (hdwp) hdwp = m_ClientPanel->OnParentSize(r, hdwp);
-        if (hdwp) EndDeferWindowPos(hdwp);
+        if (hdwp)
+        {
+            hdwp = m_ClientPanel->OnParentSize(r, hdwp);
+        }
+        if (hdwp)
+        {
+            EndDeferWindowPos(hdwp);
+        }
 
         // TODO: Sub-layouts for children of children
         count = m_SearchBar->CountSizableChildren();
         hdwp = BeginDeferWindowPos(count);
-        if (hdwp) hdwp = m_SearchBar->OnParentSize(r, hdwp);
-        if (hdwp) EndDeferWindowPos(hdwp);
+        if (hdwp)
+        {
+            hdwp = m_SearchBar->OnParentSize(r, hdwp);
+        }
+        if (hdwp)
+        {
+            EndDeferWindowPos(hdwp);
+        }
     }
 
     BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT& theResult, DWORD dwMapId)
@@ -622,14 +829,9 @@ private:
 
             FreeLogs();
 
-            FreeCachedAvailableEntries();
-
             if (IS_INSTALLED_ENUM(SelectedEnumType))
                 FreeInstalledAppList();
 
-            if (hImageTreeView)
-                ImageList_Destroy(hImageTreeView);
-
             delete m_ClientPanel;
 
             PostQuitMessage(0);
@@ -746,10 +948,10 @@ private:
                     EnableMenuItem(lvwMenu, ID_UNINSTALL, MF_ENABLED);
                     EnableMenuItem(lvwMenu, ID_MODIFY, MF_ENABLED);
 
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
                 }
                 else
                 {
@@ -763,10 +965,10 @@ private:
                     EnableMenuItem(lvwMenu, ID_UNINSTALL, MF_GRAYED);
                     EnableMenuItem(lvwMenu, ID_MODIFY, MF_GRAYED);
 
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_INSTALL, TRUE);
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
-                    m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_MODIFY, FALSE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, TRUE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
+                    m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, FALSE);
                 }
             }
             break;
@@ -794,7 +996,7 @@ private:
                         if (IS_INSTALLED_ENUM(SelectedEnumType))
                             ShowInstalledAppInfo(ItemIndex);
                         if (IS_AVAILABLE_ENUM(SelectedEnumType))
-                            ShowAvailableAppInfo(ItemIndex);
+                            CAvailableAppView::ShowAvailableAppInfo(ItemIndex);
                     }
                 }
             }
@@ -815,7 +1017,7 @@ private:
                     if (IS_INSTALLED_ENUM(SelectedEnumType))
                         ShowInstalledAppInfo(-1);
                     if (IS_AVAILABLE_ENUM(SelectedEnumType))
-                        ShowAvailableAppInfo(-1);
+                        CAvailableAppView::ShowAvailableAppInfo(-1);
                 }
             }
             break;
@@ -825,7 +1027,7 @@ private:
                 if (data->hwndFrom == m_ListView->m_hWnd && ((LPNMLISTVIEW) lParam)->iItem != -1)
                 {
                     /* this won't do anything if the program is already installed */
-                    SendMessage(hwnd, WM_COMMAND, ID_INSTALL, 0);
+                    SendMessageW(hwnd, WM_COMMAND, ID_INSTALL, 0);
                 }
             }
             break;
@@ -870,10 +1072,10 @@ private:
         case WM_SYSCOLORCHANGE:
         {
             /* Forward WM_SYSCOLORCHANGE to common controls */
-            m_ListView->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
-            m_TreeView->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
-            m_Toolbar->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
-            m_ListView->SendMessage(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
+            m_ListView->SendMessageW(WM_SYSCOLORCHANGE, 0, 0);
+            m_TreeView->SendMessageW(WM_SYSCOLORCHANGE, 0, 0);
+            m_Toolbar->SendMessageW(WM_SYSCOLORCHANGE, 0, 0);
+            m_ListView->SendMessageW(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
         }
         break;
 
@@ -881,7 +1083,8 @@ private:
             if (wParam == SEARCH_TIMER_ID)
             {
                 ::KillTimer(hwnd, SEARCH_TIMER_ID);
-                UpdateApplicationsList(-1);
+                if (SearchEnabled)
+                    UpdateApplicationsList(-1);
             }
             break;
         }
@@ -898,9 +1101,9 @@ private:
         {
             if (pLink) HeapFree(GetProcessHeap(), 0, pLink);
 
-            pLink = (PWSTR) HeapAlloc(GetProcessHeap(), 0,
+            pLink = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
                 (max(Link->chrg.cpMin, Link->chrg.cpMax) -
-                min(Link->chrg.cpMin, Link->chrg.cpMax) + 1) * sizeof(WCHAR));
+                 min(Link->chrg.cpMin, Link->chrg.cpMax) + 1) * sizeof(WCHAR));
             if (!pLink)
             {
                 /* TODO: Error message */
@@ -941,17 +1144,17 @@ private:
 
         if (lParam == (LPARAM) m_SearchBar->m_hWnd)
         {
-            WCHAR szBuf[MAX_STR_LEN];
+            ATL::CStringW szBuf;
 
             switch (HIWORD(wParam))
             {
             case EN_SETFOCUS:
             {
-                WCHAR szWndText[MAX_STR_LEN];
+                ATL::CStringW szWndText;
 
-                LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
-                m_SearchBar->GetWindowTextW(szWndText, MAX_STR_LEN);
-                if (wcscmp(szBuf, szWndText) == 0)
+                szBuf.LoadStringW(hInst, IDS_SEARCH_TEXT);
+                m_SearchBar->GetWindowTextW(szWndText);
+                if (szBuf == szWndText)
                 {
                     SearchEnabled = FALSE;
                     m_SearchBar->SetWindowTextW(L"");
@@ -961,19 +1164,19 @@ private:
 
             case EN_KILLFOCUS:
             {
-                m_SearchBar->GetWindowTextW(szBuf, MAX_STR_LEN);
-                if (wcslen(szBuf) < 1)
+                m_SearchBar->GetWindowTextW(szBuf);
+                if (szBuf.IsEmpty())
                 {
-                    LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
+                    szBuf.LoadStringW(hInst, IDS_SEARCH_TEXT);
                     SearchEnabled = FALSE;
-                    m_SearchBar->SetWindowTextW(szBuf);
+                    m_SearchBar->SetWindowTextW(szBuf.GetString());
                 }
             }
             break;
 
             case EN_CHANGE:
             {
-                WCHAR szWndText[MAX_STR_LEN];
+                ATL::CStringW szWndText;
 
                 if (!SearchEnabled)
                 {
@@ -981,20 +1184,19 @@ private:
                     break;
                 }
 
-                LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
-                m_SearchBar->GetWindowTextW(szWndText, MAX_STR_LEN);
-                if (wcscmp(szBuf, szWndText) != 0)
+                szBuf.LoadStringW(hInst, IDS_SEARCH_TEXT);
+                m_SearchBar->GetWindowTextW(szWndText);
+                if (szBuf == szWndText)
                 {
-                    StringCbCopy(szSearchPattern, sizeof(szSearchPattern),
-                        szWndText);
+                    szSearchPattern.Empty();
                 }
                 else
                 {
-                    szSearchPattern[0] = UNICODE_NULL;
+                    szSearchPattern = szWndText;
                 }
 
                 DWORD dwDelay;
-                SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
+                SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
                 SetTimer(SEARCH_TIMER_ID, dwDelay);
             }
             break;
@@ -1050,7 +1252,7 @@ private:
             break;
 
         case ID_RESETDB:
-            UpdateAppsDB();
+            m_AvailableApps.UpdateAppsDB();
             UpdateApplicationsList(-1);
             break;
 
@@ -1061,6 +1263,9 @@ private:
         case ID_ABOUT:
             ShowAboutDialog();
             break;
+
+        case ID_CHECK_ALL:
+            break;
         }
     }
 
@@ -1075,7 +1280,7 @@ private:
             if (Info)
             {
                 RegCloseKey(Info->hSubKey);
-                HeapFree(GetProcessHeap(), 0, Info);
+                delete Info;
             }
             Count--;
         }
@@ -1092,7 +1297,7 @@ private:
     static BOOL CALLBACK s_EnumInstalledAppProc(INT ItemIndex, LPWSTR lpName, PINSTALLED_INFO Info)
     {
         PINSTALLED_INFO ItemInfo;
-        WCHAR szText[MAX_PATH];
+        ATL::CStringW szText;
         INT Index;
 
         if (!SearchPatternMatch(lpName, szSearchPattern))
@@ -1114,63 +1319,63 @@ private:
 
         /* Get version info */
         GetApplicationString(ItemInfo->hSubKey, L"DisplayVersion", szText);
-        ListView_SetItemText(hListView, Index, 1, szText);
+        ListView_SetItemText(hListView, Index, 1, const_cast<LPWSTR>(szText.GetString()));
 
         /* Get comments */
         GetApplicationString(ItemInfo->hSubKey, L"Comments", szText);
-        ListView_SetItemText(hListView, Index, 2, szText);
+        ListView_SetItemText(hListView, Index, 2, const_cast<LPWSTR>(szText.GetString()));
 
         return TRUE;
     }
 
-    static BOOL CALLBACK s_EnumAvailableAppProc(PAPPLICATION_INFO Info)
+    static BOOL CALLBACK s_EnumAvailableAppProc(PAPPLICATION_INFO Info, LPCWSTR szFolderPath)
     {
         INT Index;
         HICON hIcon = NULL;
-        bool failed = false;
-        WCHAR szIconPath[MAX_PATH] = L"";
-        HIMAGELIST hImageListView = NULL;
-        hImageListView = ListView_GetImageList(hListView, LVSIL_SMALL);
+
+        HIMAGELIST hImageListView = ListView_GetImageList(hListView, LVSIL_SMALL);
 
         if (!SearchPatternMatch(Info->szName, szSearchPattern) &&
             !SearchPatternMatch(Info->szDesc, szSearchPattern))
         {
             return TRUE;
         }
-        //TODO: Define another field for icon name in the DB
-        failed = !GetStorageDirectory(szIconPath, _countof(szIconPath)) 
-          || FAILED(StringCbPrintfW(szIconPath, sizeof(szIconPath), L"%ls\\rapps\\icons\\%ls.ico", szIconPath, Info->szName));
-        if (!failed) {
-          //Load icon from file
-          hIcon = (HICON)LoadImage(NULL,
-            szIconPath,
-            IMAGE_ICON,
-            LISTVIEW_ICON_SIZE,
-            LISTVIEW_ICON_SIZE,
-            LR_LOADFROMFILE);
-        }
-        if (GetLastError() != ERROR_SUCCESS) {
-          //Load default icon
-          hIcon = (HICON)LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN));
+
+        /* Load icon from file */
+        ATL::CStringW szIconPath;
+        szIconPath.Format(L"%lsicons\\%ls.ico", szFolderPath, Info->szName);
+        hIcon = (HICON) LoadImageW(NULL,
+                                   szIconPath.GetString(),
+                                   IMAGE_ICON,
+                                   LISTVIEW_ICON_SIZE,
+                                   LISTVIEW_ICON_SIZE,
+                                   LR_LOADFROMFILE);
+
+        if (!hIcon || GetLastError() != ERROR_SUCCESS)
+        {
+            /* Load default icon */
+            hIcon = (HICON) LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN));
         }
+
         Index = ImageList_AddIcon(hImageListView, hIcon);
         DestroyIcon(hIcon);
 
         Index = ListViewAddItem(Info->Category, Index, Info->szName, (LPARAM) Info);
-        hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+        ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+
+        ListView_SetItemText(hListView, Index, 1, const_cast<LPWSTR>(Info->szVersion.GetString()));
+        ListView_SetItemText(hListView, Index, 2, const_cast<LPWSTR>(Info->szDesc.GetString()));
 
-        ListView_SetItemText(hListView, Index, 1, Info->szVersion);
-        ListView_SetItemText(hListView, Index, 2, Info->szDesc);
         return TRUE;
     }
 
 
     VOID UpdateApplicationsList(INT EnumType)
     {
-        WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN];
-        HIMAGELIST hImageListView = NULL;
+        ATL::CStringW szBuffer1, szBuffer2;
+        HIMAGELIST hImageListView;
 
-        m_ListView->SendMessage(WM_SETREDRAW, FALSE, 0);
+        m_ListView->SendMessageW(WM_SETREDRAW, FALSE, 0);
 
         if (EnumType < 0) EnumType = SelectedEnumType;
 
@@ -1178,27 +1383,29 @@ private:
             FreeInstalledAppList();
 
         (VOID) ListView_DeleteAllItems(hListView);
-        //Create new ImageList
+
+        /* Create new ImageList */
         hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE,
-          LISTVIEW_ICON_SIZE,
-          GetSystemColorDepth() | ILC_MASK,
-          0, 1000);
-        hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+                                          LISTVIEW_ICON_SIZE,
+                                          GetSystemColorDepth() | ILC_MASK,
+                                          0, 1);
+        HIMAGELIST hImageListBuf = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+        if (hImageListBuf)
+        {
+            ImageList_Destroy(hImageListBuf);
+        }
 
-        if (hImageListView)
-          ImageList_Destroy(hImageListView);
 
-        if (IS_AVAILABLE_ENUM(EnumType)) {
-          /* Enum available applications */
-          EnumAvailableApplications(EnumType, s_EnumAvailableAppProc);
+        if (IS_AVAILABLE_ENUM(EnumType))
+        {
+            /* Enum available applications */
+            m_AvailableApps.EnumAvailableApplications(EnumType, s_EnumAvailableAppProc);
         }
 
         SelectedEnumType = EnumType;
 
-        LoadStringW(hInst, IDS_APPS_COUNT, szBuffer2, _countof(szBuffer2));
-        StringCbPrintfW(szBuffer1, sizeof(szBuffer1),
-            szBuffer2,
-            ListView_GetItemCount(hListView));
+        szBuffer2.LoadStringW(hInst, IDS_APPS_COUNT);
+        szBuffer1.Format(szBuffer2, ListView_GetItemCount(hListView));
         SetStatusBarText(szBuffer1);
 
         SetWelcomeText();
@@ -1207,7 +1414,7 @@ private:
         if (ListView_GetItemCount(hListView) > 0)
             ListView_SetColumnWidth(hListView, 0, LVSCW_AUTOSIZE);
 
-        SendMessage(hListView, WM_SETREDRAW, TRUE, 0);
+        SendMessageW(hListView, WM_SETREDRAW, TRUE, 0);
     }
 
 public:
@@ -1216,12 +1423,20 @@ public:
         DWORD csStyle = CS_VREDRAW | CS_HREDRAW;
         static ATL::CWndClassInfo wc =
         {
-            { sizeof(WNDCLASSEX), csStyle, StartWindowProc,
-            0, 0, NULL, 
-            LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAIN)),
-            LoadCursor(NULL, IDC_ARROW),
-            (HBRUSH) (COLOR_BTNFACE + 1), MAKEINTRESOURCE(IDR_MAINMENU),
-            L"RAppsWnd", NULL },
+            {
+                sizeof(WNDCLASSEX),
+                csStyle,
+                StartWindowProc,
+                0,
+                0,
+                NULL,
+                LoadIconW(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCEW(IDI_MAIN)),
+                LoadCursorW(NULL, IDC_ARROW),
+                (HBRUSH) (COLOR_BTNFACE + 1),
+                MAKEINTRESOURCEW(IDR_MAINMENU),
+                L"RAppsWnd",
+                NULL
+            },
             NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
         };
         return wc;
@@ -1229,9 +1444,8 @@ public:
 
     HWND Create()
     {
-        WCHAR szWindowName[MAX_STR_LEN];
-
-        LoadStringW(hInst, IDS_APPTITLE, szWindowName, _countof(szWindowName));
+        ATL::CStringW szWindowName;
+        szWindowName.LoadStringW(hInst, IDS_APPTITLE);
 
         RECT r = {
             (SettingsInfo.bSaveWndPos ? SettingsInfo.Left : CW_USEDEFAULT),
@@ -1242,7 +1456,7 @@ public:
         r.right += r.left;
         r.bottom += r.top;
 
-        return CWindowImpl::Create(NULL, r, szWindowName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
+        return CWindowImpl::Create(NULL, r, szWindowName.GetString(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
     }
 
     CStatusBar * GetStatusBar()
@@ -1259,8 +1473,15 @@ public:
     {
         return m_RichEdit;
     }
+
+    CAvailableApps * GetAvailableApps()
+    {
+        return &m_AvailableApps;
+    }
 };
 
+// File interface
+
 CMainWindow * g_MainWindow;
 
 HWND CreateMainWindow()
@@ -1278,22 +1499,48 @@ DWORD_PTR ListViewGetlParam(INT item)
     return g_MainWindow->GetListView()->GetItemData(item);
 }
 
-VOID SetStatusBarText(PCWSTR szText)
+VOID SetStatusBarText(LPCWSTR szText)
 {
     g_MainWindow->GetStatusBar()->SetText(szText);
 }
 
-INT ListViewAddItem(INT ItemIndex, INT IconIndex, PWSTR lpName, LPARAM lParam)
+INT ListViewAddItem(INT ItemIndex, INT IconIndex, LPWSTR lpName, LPARAM lParam)
 {
     return g_MainWindow->GetListView()->AddItem(ItemIndex, IconIndex, lpName, lParam);
 }
 
-VOID NewRichEditText(PCWSTR szText, DWORD flags)
+VOID NewRichEditText(LPCWSTR szText, DWORD flags)
 {
     g_MainWindow->GetRichEdit()->SetText(szText, flags);
 }
 
-VOID InsertRichEditText(PCWSTR szText, DWORD flags)
+VOID InsertRichEditText(LPCWSTR szText, DWORD flags)
 {
     g_MainWindow->GetRichEdit()->InsertText(szText, flags);
-}
\ No newline at end of file
+}
+
+/* ATL version of functions */
+VOID SetStatusBarText(const ATL::CStringW& szText)
+{
+    SetStatusBarText(szText.GetString());
+}
+
+INT ListViewAddItem(INT ItemIndex, INT IconIndex, ATL::CStringW & Name, LPARAM lParam)
+{
+    return ListViewAddItem(ItemIndex, IconIndex, const_cast<LPWSTR>(Name.GetString()), lParam);
+}
+
+VOID NewRichEditText(const ATL::CStringW& szText, DWORD flags)
+{
+    NewRichEditText(szText.GetString(), flags);
+}
+
+VOID InsertRichEditText(const ATL::CStringW& szText, DWORD flags)
+{
+    InsertRichEditText(szText.GetString(), flags);
+}
+
+CAvailableApps* GetAvailableApps()
+{
+    return g_MainWindow->GetAvailableApps();
+}