diff --git a/tools/setup/leocad.nsi b/tools/setup/leocad.nsi index 8f7c0249..9f35ebca 100644 --- a/tools/setup/leocad.nsi +++ b/tools/setup/leocad.nsi @@ -66,6 +66,19 @@ Section "LeoCAD" SecLeoCAD File "..\..\win\release\textures.idx" File "..\..\win\release\sysfont.txf" + ;Register file extension + WriteRegStr HKCR ".lcd" "" "LeoCAD.Project" + WriteRegStr HKCR ".lcd\ShellNew" "NullFile" "" + WriteRegStr HKCR "LeoCAD.Project" "" "LeoCAD Project" + WriteRegStr HKCR "LeoCAD.Project\DefaultIcon" "" "$INSTDIR\LeoCAD.exe,0" + WriteRegStr HKCR "LeoCAD.Project\shell" "" "open" + WriteRegStr HKCR "LeoCAD.Project\shell\open\command" "" '"$INSTDIR\LeoCAD.exe" "%1"' + WriteRegStr HKCR "LeoCAD.Project\shell" "" "print" + WriteRegStr HKCR "LeoCAD.Project\shell\print\command" "" '"$INSTDIR\LeoCAD.exe" /p "%1"' + WriteRegStr HKCR "LeoCAD.Project\shell" "" "printto" + WriteRegStr HKCR "LeoCAD.Project\shell\printto\command" "" '"$INSTDIR\LeoCAD.exe" /pt "%1" "%2" "%3" "%4"' + System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' + ;Store installation folder WriteRegStr HKCU "Software\BT Software\LeoCAD" "InstallPath" $INSTDIR @@ -105,6 +118,10 @@ Section "Uninstall" RMDir "$INSTDIR" + DeleteRegKey HKCR ".lcd" + DeleteRegKey HKCR "LeoCAD.Project" + System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LeoCAD" DeleteRegKey HKCU "Software\BT Software\LeoCAD\InstallPath" DeleteRegKey /ifempty HKCU "Software\BT Software\LeoCAD" diff --git a/win/Piecebar.cpp b/win/Piecebar.cpp index ecb894eb..d81da04a 100644 --- a/win/Piecebar.cpp +++ b/win/Piecebar.cpp @@ -396,7 +396,15 @@ void CPiecesBar::UpdatePiecesTree(bool SearchOnly) if (Item == NULL) { - Item = m_PiecesTree.InsertItem(TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT, "Search Results", 0, 0, 0, 0, 0, TVI_ROOT, TVI_LAST); + TVINSERTSTRUCT Insert; + + memset(&Insert, 0, sizeof(Insert)); + Insert.hParent = TVI_ROOT; + Insert.hInsertAfter = TVI_LAST; + Insert.item.mask = TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT; + Insert.item.cChildren = 1; + Insert.item.pszText = "Search Results"; + Item = m_PiecesTree.InsertItem(&Insert); } m_PiecesTree.Expand(Item, TVE_COLLAPSE | TVE_COLLAPSERESET); @@ -408,15 +416,26 @@ void CPiecesBar::UpdatePiecesTree(bool SearchOnly) m_PiecesTree.SetRedraw(FALSE); m_PiecesTree.DeleteAllItems(); + TVINSERTSTRUCT Insert; + + memset(&Insert, 0, sizeof(Insert)); + Insert.hParent = TVI_ROOT; + Insert.hInsertAfter = TVI_SORT; + Insert.item.mask = TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT; + Insert.item.cChildren = 1; + for (int i = 0; i < Lib->GetNumCategories(); i++) { if (Lib->GetCategoryName(i) == "Search Results") continue; - m_PiecesTree.InsertItem(TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT, Lib->GetCategoryName(i), 0, 0, 0, 0, 0, TVI_ROOT, TVI_SORT); + Insert.item.pszText = (LPSTR)Lib->GetCategoryName(i); + m_PiecesTree.InsertItem(&Insert); } - m_PiecesTree.InsertItem(TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT, "Search Results", 0, 0, 0, 0, 0, TVI_ROOT, TVI_LAST); + Insert.item.pszText = "Search Results"; + Insert.hInsertAfter = TVI_LAST; + m_PiecesTree.InsertItem(&Insert); m_PiecesTree.SetRedraw(TRUE); m_PiecesTree.Invalidate(); @@ -534,7 +553,19 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) if (GroupedPieces.FindIndex(Info) == -1) m_PiecesTree.InsertItem(TVIF_PARAM|TVIF_TEXT, Info->m_strDescription, 0, 0, 0, 0, (LPARAM)Info, CategoryItem, TVI_LAST); else - m_PiecesTree.InsertItem(TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT, Info->m_strDescription, 0, 0, 0, 0, (LPARAM)Info, CategoryItem, TVI_LAST); + { + TVINSERTSTRUCT Insert; + + memset(&Insert, 0, sizeof(Insert)); + Insert.hParent = CategoryItem; + Insert.hInsertAfter = TVI_LAST; + Insert.item.mask = TVIF_CHILDREN|TVIF_PARAM|TVIF_TEXT; + Insert.item.pszText = (LPSTR)Info->m_strDescription; + Insert.item.cChildren = 1; + Insert.item.lParam = (LPARAM)Info; + + m_PiecesTree.InsertItem(&Insert); + } } }