//---------------------------------------------------// // GetNexthTreeItemToSel //---------------------------------------------------// HTREEITEM GetNexthTreeItemToSel(HWND hWndTV,HTREEITEM hCurItem) { HTREEITEM hItm=hCurItem; TVITEM pitm; BOOL bExpanded=TRUE; int index=GetmHpVarStruct()->SelItemListe->GetItemIndex(); if(index!=NO) { while((bExpanded)&&(index!=NO)) { while(index!=0) { hItm=TreeView_GetNextItem(hWndTV,hItm,TVGN_NEXT); index--; } pitm.mask=TVIF_STATE; pitm.stateMask=TVIS_STATEIMAGEMASK; pitm.hItem=hItm; TreeView_GetItem(hWndTV,&pitm); if((pitm.state&TVIS_EXPANDED)==TVIS_EXPANDED) { GetmHpVarStruct()->SelItemListe->ItemIndexSuivant(); index=GetmHpVarStruct()->SelItemListe->GetItemIndex(); hItm=TreeView_GetNextItem(hWndTV,hItm,TVGN_CHILD); bExpanded=TRUE; } else bExpanded=FALSE; } } else hItm=NULL; return hItm; }
static HTREEITEM EhTreeViewItemSearch(HWND hWnd,HTREEITEM hItem,LONG lParam) { HTREEITEM hChild,hOk; static INT iLevel=0; TVITEM pItem; iLevel++; while (hItem) { ZeroFill(pItem); pItem.hItem=hItem; pItem.state=TVIF_PARAM; pItem.stateMask=TVIF_PARAM; if (!TreeView_GetItem(hWnd,&pItem)) return NULL; //win_infoarg("%d: %d <> %d",iLevel,pItem.lParam,lParam); if (pItem.lParam==lParam) {iLevel--; return hItem;} hChild=TreeView_GetNextItem(hWnd,hItem,TVGN_CHILD); hItem=TreeView_GetNextItem(hWnd,hItem,TVGN_NEXT); if (hChild) { hOk=EhTreeViewItemSearch(hWnd,hChild,lParam); if (hOk) {iLevel--; return hOk;} } } iLevel--; return NULL; }
void AP_Win32Dialog_Stylist::setStyleInGUI(void) { UT_sint32 row,col; UT_UTF8String sCurStyle = *getCurStyle(); if((getStyleTree() == NULL) || (sCurStyle.size() == 0)) updateDialog(); if(isStyleTreeChanged()) _fillTree(); getStyleTree()->findStyle(sCurStyle,row,col); UT_DEBUGMSG(("After findStyle row %d col %d col \n",row,col)); UT_UTF8String sPathFull = UT_UTF8String_sprintf("%d:%d",row,col); UT_UTF8String sPathRow = UT_UTF8String_sprintf("%d",row); UT_DEBUGMSG(("Full Path string is %s \n",sPathFull.utf8_str())); HWND hTree = GetDlgItem(m_hWnd, AP_RID_DIALOG_STYLIST_TREE_STYLIST); HTREEITEM hitem = NULL; hitem = TreeView_GetRoot(hTree); UT_sint32 i; // Go through each row until we've found ours for (i = 0; i < row; i++) hitem = TreeView_GetNextItem(hTree, hitem, TVGN_NEXT); hitem = TreeView_GetNextItem(hTree, hitem, TVGN_CHILD); for (i = 0; i < col; i++) hitem = TreeView_GetNextItem(hTree, hitem, TVGN_NEXT); TreeView_SelectItem(hTree, hitem); setStyleChanged(false); }
//---------------------------------------------------// // FindCurItemBetween //---------------------------------------------------// BOOL FindCurItemBetween(HWND hWndTV,HTREEITEM itemStart,HTREEITEM itemEnd) { HTREEITEM hItm=itemStart; while((hItm!=NULL)&&(hItm!=itemEnd)&&(hItm!=hCurSelItm)) { if(TreeView_GetNextItem(hWndTV,hItm,TVGN_CHILD)!=NULL) { if(FindCurItemBetween(hWndTV,TreeView_GetNextItem(hWndTV,hItm,TVGN_CHILD),itemEnd)) return TRUE; } hItm=TreeView_GetNextItem(hWndTV,hItm,TVGN_NEXT); } if((hItm!=NULL)&&(hItm!=itemEnd)) return TRUE; return FALSE; }
HTREEITEM GetNextUpItem(HWND hTree, HTREEITEM Item) { Item = TreeView_GetNextItem(hTree, Item, TVGN_PARENT); if(!Item) return NULL; HTREEITEM TempItem = TreeView_GetNextItem(hTree, Item, TVGN_NEXT); if(TempItem) return TempItem; return GetNextUpItem(hTree, Item); }
CBaseTreeItem* CMsgTree::GetNextItem(int Flags, CBaseTreeItem* Item) // Item is 'int ID' if MTGN_BYID flag is set; returns CBaseTreeItem* or NULL { COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl(); CBaseTreeItem* TreeItem = Item; if (Flags & MTGN_BYID) { int Order = TreeCtrl->IDToOrder((int)Item); _ASSERT(Order != -1); TreeItem = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order]; } int TVFlag = 0; switch (Flags & ~MTGN_BYID) { case MTGN_ROOT: TVFlag = TVGN_ROOT; break; case MTGN_CHILD: TVFlag = TVGN_CHILD; break; case MTGN_PARENT: TVFlag = TVGN_PARENT; break; case MTGN_NEXT: TVFlag = TVGN_NEXT; break; case MTGN_PREV: TVFlag = TVGN_PREVIOUS; break; default: _ASSERT(0); } int Order = TreeCtrl->hItemToOrder(TreeView_GetNextItem(hTreeView, TreeItem ? TreeItem->hItem : NULL, TVFlag)); if (Order == -1) return NULL; return (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order]; }
LRESULT MainDialog::OnTreeNotify(LPARAM lParam) { LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(lParam); switch (pnmh->code) { // Custom draw case NM_CUSTOMDRAW: { LPNMTVCUSTOMDRAW pCD = reinterpret_cast<LPNMTVCUSTOMDRAW>(lParam); switch (pCD->nmcd.dwDrawStage) { case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; case CDDS_ITEMPREPAINT: return CDRF_NOTIFYPOSTPAINT; case CDDS_ITEMPOSTPAINT: { // Draw separator if (pCD->nmcd.lItemlParam == -1) { win::Rect rcItem = pCD->nmcd.rc; win::Dc hdc = pCD->nmcd.hdc; hdc.FillRect(rcItem, ::GetSysColor(COLOR_3DFACE)); rcItem.top += (rcItem.bottom - rcItem.top) / 2; //GradientRect(hdc.Get(), &rcItem, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DFACE), true); rcItem.bottom = rcItem.top + 2; hdc.FillRect(rcItem, ::GetSysColor(COLOR_3DHIGHLIGHT)); rcItem.bottom -= 1; hdc.FillRect(rcItem, ::GetSysColor(COLOR_3DLIGHT)); hdc.DetachDc(); } return CDRF_DODEFAULT; } } break; } // Item select case TVN_SELCHANGING: { LPNMTREEVIEW pnmtv = reinterpret_cast<LPNMTREEVIEW>(lParam); switch (pnmtv->action) { case TVC_UNKNOWN: break; case TVC_BYMOUSE: case TVC_BYKEYBOARD: // Prevent selection of separators if (pnmtv->itemNew.lParam == -1) { if (pnmtv->action == TVC_BYKEYBOARD) { // TODO: Should work upwards too HTREEITEM hti = TreeView_GetNextItem(treeview.GetWindowHandle(), pnmtv->itemNew.hItem, TVGN_NEXT); navigation.SetCurrentPage(treeview.GetItemData(hti)); } return TRUE; } navigation.SetCurrentPage(pnmtv->itemNew.lParam); break; } break; } } return 0; }
BOOL wbSetTreeViewItemSelected(PWBOBJ pwbo, HTREEITEM hItem) { if(!wbIsWBObj(pwbo, TRUE)) // Is it a valid control? return 0; if((int)hItem < 0) return TreeView_SelectItem(pwbo->hwnd, NULL); else if(hItem) return TreeView_SelectItem(pwbo->hwnd, hItem); else return TreeView_SelectItem(pwbo->hwnd, TreeView_GetNextItem(pwbo->hwnd, 0, TVGN_ROOT)); }
//---------------------------------------------------// // GetTVitemSelList //---------------------------------------------------// BOOL GetTVitemSelList(HWND hWndTV,HTREEITEM hItmStart,int StrIndex) { HTREEITEM hItm=hItmStart; TVITEM pitem; int index=0; char lpItmTxt[MAX_RS_SIZE]={0}; pitem.pszText=lpItmTxt; pitem.mask=TVIF_TEXT; if(GetmHpVarStruct()->CourantTask->GetMultiIndex(StrIndex)==NULL) return TRUE; while(hItm!=NULL) { GetmHpVarStruct()->SelItemListe->AddItemIndex(index); pitem.cchTextMax=MAX_RS_SIZE; pitem.hItem=hItm; TreeView_GetItem(hWndTV,&pitem); if(!strncmp(pitem.pszText,GetmHpVarStruct()->CourantTask->GetMultiIndex(StrIndex),MAX_RS_SIZE)) { if(GetTVitemSelList(hWndTV,TreeView_GetNextItem(hWndTV,hItm,TVGN_CHILD),(StrIndex+1))) return TRUE; } hItm=TreeView_GetNextItem(hWndTV,hItm,TVGN_NEXT); index++; GetmHpVarStruct()->SelItemListe->RemoveLastIndexItem(); } return FALSE; }
LRESULT CDeviceView::OnRightClick( _In_ LPNMHDR NmHdr ) { HTREEITEM hItem = TreeView_GetNextItem(NmHdr->hwndFrom, 0, TVGN_DROPHILITE); if (hItem) { TreeView_SelectItem(NmHdr->hwndFrom, hItem); } return 0; }
HTREEITEM GetNext(HWND hTree, HTREEITEM Item) { HTREEITEM TempItem = TreeView_GetChild(hTree, Item); if(TempItem) return TempItem; TempItem = TreeView_GetNextItem(hTree, Item, TVGN_NEXT); if(TempItem) return TempItem; return GetNextUpItem(hTree, Item); }
void CFolderDlg::OnItemExpanded(NMTREEVIEW* lpnmtv) { // 次にブランチを展開するときに改めて列挙するのでサブキーを削除する if (lpnmtv->action == TVE_COLLAPSE) { HTREEITEM hChild; HTREEITEM hNext; hChild = TreeView_GetChild (lpnmtv->hdr.hwndFrom, lpnmtv->itemNew.hItem); while (hChild) { hNext = TreeView_GetNextItem (lpnmtv->hdr.hwndFrom, hChild, TVGN_NEXT); TreeView_DeleteItem (lpnmtv->hdr.hwndFrom, hChild); hChild = hNext; } } }
void PropDlg::DrawChildrenOfItem(HTREEITEM hParentItem) { INT iIconNormal = 0; INT iIconSelected = 0; INT iIconOverlayed = 0; BOOL haveChildren = FALSE; INT root = 0; HTREEITEM pCurrentItem = TreeView_GetNextItem(_hTreeCtrl, hParentItem, TVGN_CHILD); /* get element list */ PELEM parentElement = (PELEM)GetParam(hParentItem); if (parentElement != NULL) { /* update elements in parent tree */ for (size_t i = 0; i < parentElement->vElements.size(); i++) { PELEM pElem = &parentElement->vElements[i]; /* get root */ root = pElem->uParam & FAVES_PARAM; /* initialize children */ haveChildren = FALSE; if (pElem->uParam & FAVES_PARAM_GROUP) { if (pElem->vElements.size() != 0) { if ((pElem->vElements[0].uParam & FAVES_PARAM_GROUP) || (_bWithLink == TRUE)) { haveChildren = TRUE; } } /* add new item */ pCurrentItem = InsertItem(pElem->pszName, ICON_GROUP, ICON_GROUP, 0, 0, hParentItem, TVI_LAST, haveChildren, (LPARAM)pElem); } if ((pElem->uParam & FAVES_PARAM_LINK) && (_bWithLink == TRUE)) { /* add new item */ ExtractIcons(pElem->pszName, NULL, DEVT_FILE, &iIconNormal, &iIconSelected, &iIconOverlayed); pCurrentItem = InsertItem(pElem->pszName, _iUImgPos, _iUImgPos, 0, 0, hParentItem, TVI_LAST, haveChildren, (LPARAM)pElem); } } } }
void CFolderDlg::SetCurrentFolder(HWND hwndTV, LPCTSTR lpszPath) { LPCTSTR pszStart = wcschr(lpszPath, _T('\\')); HTREEITEM hSelectItem = TreeView_GetRoot(hwndTV); HTREEITEM hParent = hSelectItem; TreeView_Expand(hwndTV, hParent, TVE_EXPAND); while (pszStart) { TCHAR szName[MAX_PATH] = {0}; LPCTSTR pszEnd = wcschr(pszStart + 1, _T('\\')); if (pszEnd) { int len = pszEnd - (pszStart + 1); wcsncpy(szName, ++pszStart, len); szName[len] = 0; } else wcscpy(szName, ++pszStart); HTREEITEM hChild = TreeView_GetChild(hwndTV, hParent); while (hChild) { TCHAR szChildName[MAX_PATH] = {0}; TVITEM tvi; tvi.mask = TVIF_TEXT | TVIF_HANDLE; tvi.pszText = szChildName; tvi.cchTextMax = MAX_PATH; tvi.hItem = hChild; TreeView_GetItem(hwndTV, &tvi); if (wcscmp(szName, szChildName) == 0) { hSelectItem = hParent = hChild; TreeView_Expand(hwndTV, hParent, TVE_EXPAND); break; } hChild = TreeView_GetNextItem(hwndTV, hChild, TVGN_NEXT); } if (!hChild) break; pszStart = wcschr(pszStart, _T('\\')); } TreeView_SelectItem(hwndTV, hSelectItem); }
//-----------------------------------------------------------------------------------------------------------------------// // GetTreeItemSels //---------------------------------------------------// void GetTreeItemSels(HWND hWndTV,WPARAM wParam,CmHpTask* ObjItem) { char lptcitm[MAX_RS_SIZE]={0}; TVITEM pItem; pItem.pszText=lptcitm; pItem.mask=TVIF_TEXT; pItem.cchTextMax=MAX_RS_SIZE; /*if(wParam!=NULL) // DotNet TreeView message { int* iSelTab=(int*)wParam; // See mHelpTreeViewEvent() method HTREEITEM hTreeItm=TreeView_GetRoot(hWndTV); for(int i=0; (hTreeItm!=NULL)&&(iSelTab[i]!=NO); i++) { // Get indexed item for(int j=iSelTab[i]; j!=0; j--) hTreeItm=TreeView_GetNextItem(hWndTV,hTreeItm,TVGN_NEXT); if(hTreeItm!=NULL) { pItem.hItem=hTreeItm; if(TreeView_GetItem(hWndTV,&pItem)) { char lpSel[MAX_RS_SIZE]={0}; strncpy(lpSel,pItem.pszText,MAX_RS_SIZE); ObjItem->AddMultiIndex(lpSel); // Get child item hTreeItm=TreeView_GetNextItem(hWndTV,hTreeItm,TVGN_CHILD); } else break; } else break; } } else*/ { HTREEITEM hTreeItm=TreeView_GetSelection(hWndTV); while(hTreeItm!=NULL) { pItem.hItem=hTreeItm; if(TreeView_GetItem(hWndTV,&pItem)) { char lpSel[MAX_RS_SIZE]={0}; strncpy(lpSel,pItem.pszText,MAX_RS_SIZE); ObjItem->AddMultiIndex(lpSel); } hTreeItm=TreeView_GetNextItem(hWndTV,hTreeItm,TVGN_PARENT); } ObjItem->InverseMultiIndex(); } }
void PropDlg::GetFolderPathName(HTREEITEM hItem, LPTSTR name) { /* return if current folder is root folder */ if (hItem == TVI_ROOT) { return; } TCHAR TEMP[MAX_PATH]; TCHAR szName[MAX_PATH]; /* delete folder path name */ name[0] = '\0'; /* join elements together */ while (hItem != NULL) { GetItemText(hItem, szName, MAX_PATH); _stprintf(TEMP, _T("%s %s"), szName, name); _tcscpy(name, TEMP); hItem = TreeView_GetNextItem(_hTreeCtrl, hItem, TVGN_PARENT); } }
void CMyTreeView::UpdateChildren(HTREEITEM hParent,LPITEMIDLIST pidlParent) { HTREEITEM hChild; TVITEMEX tvItem; LPITEMIDLIST pidl = NULL; BOOL bRes; hChild = TreeView_GetChild(m_hTreeView,hParent); if(hChild != NULL) { tvItem.mask = TVIF_PARAM; tvItem.hItem = hChild; bRes = TreeView_GetItem(m_hTreeView,&tvItem); if(bRes) { pidl = UpdateItemInfo(pidlParent,(int)tvItem.lParam); UpdateChildren(hChild,pidl); while((hChild = TreeView_GetNextItem(m_hTreeView,hChild,TVGN_NEXT)) != NULL) { tvItem.mask = TVIF_PARAM; tvItem.hItem = hChild; bRes = TreeView_GetItem(m_hTreeView,&tvItem); if(bRes) { pidl = UpdateItemInfo(pidlParent,(int)tvItem.lParam); UpdateChildren(hChild,pidl); } } } } }
void AddTreeViewNodes(HWND hWndDlg, PageHash key, HTREEITEM root) { if (root) { TCHAR title[2048] = {0}; TVITEM item = {0}; item.mask = TVIF_TEXT; item.hItem = root; item.pszText = title; item.cchTextMax = _countof(title); if (TreeView_GetItem(hWndDlg, &item)) if (mir_tstrlen(title) > 0) AddFilterString(key, title); HTREEITEM child = root; while (child) { child = TreeView_GetNextItem(hWndDlg, child, TVGN_CHILD); AddTreeViewNodes(hWndDlg, key, child); } AddTreeViewNodes(hWndDlg, key, TreeView_GetNextSibling(hWndDlg, root)); } }
static void refreshPatch() { SendDlgItemMessage(hIpsDlg, IDC_TEXTCOMMENT, WM_SETTEXT, 0, 0); HTREEITEM hSelectHandle = TreeView_GetNextItem(hIpsList, ~0U, TVGN_CARET); if (!hSelectHandle) { return; } if (hPreview) { DeleteObject((HGDIOBJ)hPreview); hPreview = NULL; } for (int i = 0; i < nNumPatches; i++) { if (hSelectHandle == hPatchHandlesIndex[i]) { FILE* fp = _tfopen(szPatchFileNames[i], _T("r")); if (fp) { TCHAR* PatchDesc = getPatchDescByLangcode(fp, nPatchLang); // If not available - try English first if (PatchDesc == NULL) { PatchDesc = getPatchDescByLangcode(fp, 0); // Simplified Chinese is the reference language if (PatchDesc == NULL) { PatchDesc = getPatchDescByLangcode(fp, 1); } } if (PatchDesc == NULL) { fclose(fp); break; } SendDlgItemMessage(hIpsDlg, IDC_TEXTCOMMENT, WM_SETTEXT, 0, (LPARAM)PatchDesc); fclose(fp); } // set preview image filename TCHAR szPatchDatName[MAX_PATH] = _T(""); TCHAR szImageFileName[MAX_PATH] = _T(""); TCHAR* szGameName = BurnDrvGetText(DRV_NAME); getPatchFilename(szGameName, szPatchDatName, i); getPatchPrevName(szImageFileName, szGameName, szPatchDatName); _tcscat(szImageFileName, _T(".png")); // load image HBITMAP hNewImage = loadImageFromFile(szImageFileName, hIpsDlg, nLoadMenuShowX & KEEPGAMEASPECT); if (hNewImage) { hPreview = hNewImage; SendDlgItemMessage(hIpsDlg, IDC_SCREENSHOT_H, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hPreview); movePatchPreviewPos(); } else { SendDlgItemMessage(hIpsDlg, IDC_SCREENSHOT_H, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hDefPreview); resetPatchPreviewPos(); } return; } } SendDlgItemMessage(hIpsDlg, IDC_SCREENSHOT_H, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hDefPreview); resetPatchPreviewPos(); }
BOOL CALLBACK ViewFSNitroProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { fs = new FS_NITRO(); if (!fs) { msgbox->error("Error reading FS from ROM"); SendMessage(hWnd, WM_CLOSE, 0, 0); return TRUE; } HWND tree = GetDlgItem(hWnd, IDC_FILES_TREE); SendMessage(tree, WM_SETREDRAW, (WPARAM)false, 0); //HBITMAP hBmp; HICON hIcon = NULL; HIMAGELIST hIml = ImageList_Create(16, 16, ILC_COLORDDB | ILC_HIGHQUALITYSCALE, 3, 0); // Open folder icon hIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_FOLDER_OPEN)); int iFolderOpen = ImageList_AddIcon(hIml, hIcon); DeleteObject(hIcon); // Closed folder icon hIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_FOLDER_CLOSED)); int iFolderClosed = ImageList_AddIcon(hIml, hIcon); DeleteObject(hIcon); // Binary file icon hIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_FILE_BINARY)); int iFileBinary = ImageList_AddIcon(hIml, hIcon); DeleteObject(hIcon); TreeView_SetImageList(tree, hIml, TVSIL_NORMAL); const u32 numDirs = fs->getNumDirs(); const u32 numFiles = fs->getNumFiles(); HTREEITEM *dirs = new HTREEITEM[numDirs]; memset(dirs, 0, sizeof(HTREEITEM) * numDirs); //printf("Dirs: %d\n", numDirs); //printf("Files: %d\n", numFiles); TVINSERTSTRUCT item; // data folder memset(&item, 0, sizeof(TVINSERTSTRUCT)); item.hParent = TVI_ROOT; item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;; item.item.pszText = (LPSTR)"data"; item.item.iImage = iFolderOpen; item.item.iSelectedImage = iFolderClosed; item.item.lParam = 0xFFFF; HTREEITEM hData = TreeView_InsertItem(tree, &item); // overlay folder memset(&item, 0, sizeof(TVINSERTSTRUCT)); item.hParent = TVI_ROOT; item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;; item.item.pszText = (LPSTR)"overlay"; item.item.iImage = iFolderOpen; item.item.iSelectedImage = iFolderClosed; item.item.lParam = 0xFFFE; HTREEITEM hOverlay = TreeView_InsertItem(tree, &item); for (u32 i = 1; i < numDirs; i++) { u16 id = (i | 0xF000); u16 parent = fs->getDirParrentByID(id) & 0x0FFF; string name = fs->getDirNameByID(id); //printf("%s\n", name.c_str()); TVINSERTSTRUCT item; memset(&item, 0, sizeof(item)); if (parent == 0) item.hParent = hData; else item.hParent = dirs[parent]; item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; item.item.pszText = (LPSTR)name.c_str(); item.item.iImage = iFolderOpen; item.item.iSelectedImage = iFolderClosed; item.item.lParam = id; dirs[i] = TreeView_InsertItem(tree, &item); } for (u32 i = 0; i < numFiles; i++) { u16 parent = fs->getFileParentById(i); if (parent == 0xFFFF) continue; parent &= 0x0FFF; string name = fs->getFileNameByID(i); TVINSERTSTRUCT item; memset(&item, 0, sizeof(item)); if (fs->isOverlay(i)) { item.hParent = hOverlay; } else { if (parent == 0) item.hParent = hData; else item.hParent = dirs[parent]; } item.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; item.item.pszText = (LPSTR)name.c_str(); item.item.iImage = iFileBinary; item.item.iSelectedImage = iFileBinary; item.item.lParam = i; TreeView_InsertItem(tree, &item); } delete [] dirs; SendMessage(tree, WM_SETREDRAW, (WPARAM)true, 0); popupMenu = LoadMenu(hAppInst, MAKEINTRESOURCE(MENU_FSNITRO)); } return FALSE; case WM_CLOSE: if (fs) { delete fs; fs = NULL; } if (popupMenu) { DestroyMenu(popupMenu); popupMenu = NULL; } PostQuitMessage(0); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: SendMessage(hWnd, WM_CLOSE, 0, 0); return TRUE; case ID_FSNITRO_VIEW: if (currentFileID < 0xF000) { if (RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*))) OpenToolWindow(new CMemView(MEMVIEW_ROM, fs->getStartAddrById(currentFileID))); return TRUE; } return FALSE; case ID_EXTRACTFILE: case ID_EXTRACTALL: { char tmp_path[MAX_PATH] = {0}; BROWSEINFO bp={0}; memset(&bp, 0, sizeof(bp)); bp.hwndOwner = hWnd; bp.pidlRoot = NULL; bp.pszDisplayName = NULL; bp.lpszTitle = "Select destination directory"; bp.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_USENEWUI; bp.lpfn = BrowseCallbackProc; LPITEMIDLIST tmp = SHBrowseForFolder((LPBROWSEINFO)&bp); if (tmp) { memset(tmp_path, 0, sizeof(tmp_path)); SHGetPathFromIDList(tmp, tmp_path); if (tmp_path[strlen(tmp_path)-1] != '\\') tmp_path[strlen(tmp_path)] = '\\'; if (LOWORD(wParam) == ID_EXTRACTALL) { string tmp = (string)tmp_path + (string)path.GetRomNameWithoutExtension() + (string)"\\"; mkdir(tmp.c_str(),0777); HWND progress = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_PROGRESS_WND), NULL, (DLGPROC)ProgressWnd); ShowWindow(progress, SW_SHOW); UpdateWindow(progress); fs->extractAll(tmp, extractCallback); DestroyWindow(progress); } else { if (currentFileID < 0xF000) fs->extractFile(currentFileID, (string)tmp_path); } } } return TRUE; } return FALSE; case WM_NOTIFY: { LPNMHDR notify = (LPNMHDR)lParam; if (wParam == IDC_FILES_TREE) { switch (notify->code) { case NM_DBLCLK: if (currentFileID < 0xF000) { if (RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*))) OpenToolWindow(new CMemView(MEMVIEW_ROM, fs->getStartAddrById(currentFileID))); return TRUE; } return FALSE; case NM_RCLICK: { DWORD tmp = GetMessagePos(); POINTS pos = MAKEPOINTS(tmp); HTREEITEM hItem = TreeView_GetNextItem(notify->hwndFrom, 0, TVGN_DROPHILITE); if(hItem) TreeView_SelectItem(notify->hwndFrom, hItem); TVITEM pitem; HTREEITEM item = TreeView_GetSelection(GetDlgItem(hWnd, IDC_FILES_TREE)); memset(&pitem, 0, sizeof(pitem)); pitem.hItem = item; pitem.mask = TVIF_PARAM; TreeView_GetItem(GetDlgItem(hWnd, IDC_FILES_TREE), &pitem); currentFileID = pitem.lParam; refreshQView(hWnd, currentFileID); EnableMenuItem(popupMenu, ID_EXTRACTFILE, MF_BYCOMMAND | ((currentFileID < 0xF000)?MF_ENABLED:MF_GRAYED)); EnableMenuItem(popupMenu, ID_FSNITRO_VIEW, MF_BYCOMMAND | ((currentFileID < 0xF000)?MF_ENABLED:MF_GRAYED)); SetMenuDefaultItem(GetSubMenu(popupMenu, 0), ID_FSNITRO_VIEW, FALSE); TrackPopupMenu(GetSubMenu(popupMenu, 0), TPM_LEFTALIGN | TPM_RIGHTBUTTON, pos.x, pos.y, NULL, hWnd, NULL); } break; case TVN_SELCHANGED: { LPNMTREEVIEW sel = (LPNMTREEVIEW)lParam; char buf[256] = {0}; currentFileID = sel->itemNew.lParam; refreshQView(hWnd, currentFileID); if ((currentFileID & 0xF000) == 0xF000) { SetWindowText(GetDlgItem(hWnd, IDC_FILE_INFO), ""); } else { u32 start = fs->getStartAddrById(currentFileID); u32 end = fs->getEndAddrById(currentFileID); u32 size = (end - start); sprintf(buf, "[%08X-%08X] size %u", start, end, size); SetWindowText(GetDlgItem(hWnd, IDC_FILE_INFO), buf); } } break; } } } return FALSE; } return FALSE; }