void DoCompare(void) { TCHAR szFile[MAX_PATH]; BOOL doMatch = TRUE; LPSTR compare1 = NULL; LPSTR compare2 = NULL; tHexProp hexProp1 = hexEdit1.GetHexProp(); tHexProp hexProp2 = hexEdit2.GetHexProp(); tCmpResult cmpResult = {0}; if ((hexProp1.bits != hexProp2.bits) || (hexProp1.columns != hexProp2.columns) || (hexProp1.isBin != hexProp2.isBin)) { /* ask which hex edits should be used to have same settings in both */ CompareDlg dlg; dlg.init((HINSTANCE)g_hModule, nppData); if (dlg.doDialog(&hexEdit1, &hexEdit2, currentSC) == IDCANCEL) { return; } } /* create file for compare results */ _tcscpy(cmpResult.szFileName, cmparePath); _tcscpy(szFile, ::PathFindFileName(hexEdit1.GetHexProp().szFileName)); ::PathRemoveExtension(szFile); ::PathAppend(cmpResult.szFileName, szFile); _tcscat(cmpResult.szFileName, _T("_")); _tcscpy(szFile, ::PathFindFileName(hexEdit2.GetHexProp().szFileName)); ::PathRemoveExtension(szFile); _tcscat(cmpResult.szFileName, szFile); _tcscat(cmpResult.szFileName, _T(".cmp")); cmpResult.hFile = ::CreateFile(cmpResult.szFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (cmpResult.hFile != INVALID_HANDLE_VALUE) { LPSTR buffer1 = (LPSTR)new CHAR[COMP_BLOCK+1]; LPSTR buffer2 = (LPSTR)new CHAR[COMP_BLOCK+1]; /* get text size to comapre */ INT maxLength1 = ScintillaMsg(nppData._scintillaMainHandle, SCI_GETTEXTLENGTH) + 1; INT maxLength2 = ScintillaMsg(nppData._scintillaSecondHandle, SCI_GETTEXTLENGTH) + 1; /* get max length */ INT curPos = 0; INT maxLength = maxLength1; INT minLength = maxLength1; if (maxLength2 > maxLength1) { maxLength = maxLength2; } else { minLength = maxLength2; } while (curPos < minLength) { CHAR val = FALSE; INT posSrc = 0; INT length1 = ((maxLength1 - curPos) > COMP_BLOCK ? COMP_BLOCK : (maxLength1 % COMP_BLOCK)); INT length2 = ((maxLength2 - curPos) > COMP_BLOCK ? COMP_BLOCK : (maxLength2 % COMP_BLOCK)); ScintillaGetText(nppData._scintillaMainHandle, buffer1, curPos, length1 - 1); ScintillaGetText(nppData._scintillaSecondHandle, buffer2, curPos, length2 - 1); while ((posSrc < length1) && (posSrc < length2)) { DWORD hasWritten = 0; if (buffer1[posSrc] != buffer2[posSrc]) { val = TRUE; doMatch = FALSE; } /* increment source buffer */ posSrc++; /* write to file */ if (hexProp1.bits == 1) { ::WriteFile(cmpResult.hFile, &val, sizeof(val), &hasWritten, NULL); val = FALSE; } else if ((posSrc % hexProp1.bits) == 0) { ::WriteFile(cmpResult.hFile, &val, sizeof(val), &hasWritten, NULL); val = FALSE; } } /* increment file position */ curPos += posSrc; } if (doMatch == TRUE) { if (NLMessageBox((HINSTANCE)g_hModule, nppData._nppHandle, _T("MsgBox CompMatch"), MB_OK) == FALSE) ::MessageBox(nppData._nppHandle, _T("Files Match."), _T("Hex-Editor Compare"), MB_OK); ::CloseHandle(cmpResult.hFile); ::DeleteFile(cmpResult.szFileName); } else { DWORD hasWritten = 0; CHAR val = TRUE; for (UINT i = (minLength / hexProp1.bits); i < (maxLength / hexProp1.bits); i++) { ::WriteFile(cmpResult.hFile, &val, sizeof(val), &hasWritten, NULL); } /* create two structures for each view */ tCmpResult* pCmpResult1 = (tCmpResult*)new tCmpResult; tCmpResult* pCmpResult2 = (tCmpResult*)new tCmpResult; if ((pCmpResult1 != NULL) && (pCmpResult2 != NULL)) { /* set data */ *pCmpResult1 = cmpResult; *pCmpResult2 = cmpResult; hexEdit1.SetCompareResult(pCmpResult1, pCmpResult2); hexEdit2.SetCompareResult(pCmpResult2, pCmpResult1); } else { delete pCmpResult1; delete pCmpResult2; } } delete [] buffer1; delete [] buffer2; } }
BOOL OptionDlg::GetParams(void) { TCHAR text[16]; UINT col = 0; UINT add = 0; UINT bitsValue = 0; BOOL bRet = FALSE; /* get default layout */ ::GetWindowText(::GetDlgItem(_hSelf, IDC_ADDWIDTH_EDIT), text, 16); add = _ttoi(text); ::GetWindowText(::GetDlgItem(_hSelf, IDC_COLUMN_EDIT), text, 16); col = _ttoi(text); /* get bit alignment */ if (::SendDlgItemMessage(_hSelf, IDC_RADIO_8, BM_GETCHECK, 0, 0) == BST_CHECKED) bitsValue = HEX_BYTE; else if (::SendDlgItemMessage(_hSelf, IDC_RADIO_16, BM_GETCHECK, 0, 0) == BST_CHECKED) bitsValue = HEX_WORD; else if (::SendDlgItemMessage(_hSelf, IDC_RADIO_32, BM_GETCHECK, 0, 0) == BST_CHECKED) bitsValue = HEX_DWORD; else bitsValue = HEX_LONG; /* test if values are possible */ if ((col > 0) && (col <= (128 / bitsValue))) { bRet = TRUE; } else { if (NLMessageBox(_hInst, _hParent, _T("MsgBox MaxColCnt"), MB_OK|MB_ICONERROR) == FALSE) ::MessageBox(_hParent, _T("Maximum of 128 bytes can be shown in a row."), _T("Hex-Editor: Column Count"), MB_OK|MB_ICONERROR); bRet = FALSE; } if (bRet == TRUE) { if ((add >= 4) && (add <= 16)) { bRet = TRUE; } else { if (NLMessageBox(_hInst, _hParent, _T("MsgBox MaxAddCnt"), MB_OK|MB_ICONERROR) == FALSE) ::MessageBox(_hParent, _T("Only values between 4 and 16 possible."), _T("Hex-Editor: Address Width"), MB_OK|MB_ICONERROR); bRet = FALSE; } } if (bRet == TRUE) { _pProp->hexProp.addWidth = add; _pProp->hexProp.columns = col; _pProp->hexProp.bits = bitsValue; /* get endian */ if (::SendDlgItemMessage(_hSelf, IDC_RADIO_BIG, BM_GETCHECK, 0, 0) == BST_CHECKED) _pProp->hexProp.isLittle = FALSE; else _pProp->hexProp.isLittle = TRUE; /* get display form */ if (::SendDlgItemMessage(_hSelf, IDC_RADIO_HEX, BM_GETCHECK, 0, 0) == BST_CHECKED) _pProp->hexProp.isBin = FALSE; else _pProp->hexProp.isBin = TRUE; /* get autostart properties */ ::GetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_EXTLIST), _pProp->autoProp.szExtensions, _countof(_pProp->autoProp.szExtensions)); ::GetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_PERCENT), _pProp->autoProp.szPercent, _countof(_pProp->autoProp.szPercent)); /* get font information */ ::GetWindowText(::GetDlgItem(_hSelf, IDC_COMBO_FONTNAME), _pProp->fontProp.szFontName, _countof(_pProp->fontProp.szFontName)); _pProp->fontProp.iFontSizeElem = (UINT)::SendDlgItemMessage(_hSelf, IDC_COMBO_FONTSIZE, CB_GETCURSEL, 0, 0); _pProp->fontProp.isBold = (::SendDlgItemMessage(_hSelf, IDC_CHECK_BOLD, BM_GETCHECK, 0, 0) == BST_CHECKED); _pProp->fontProp.isItalic = (::SendDlgItemMessage(_hSelf, IDC_CHECK_ITALIC, BM_GETCHECK, 0, 0) == BST_CHECKED); _pProp->fontProp.isUnderline = (::SendDlgItemMessage(_hSelf, IDC_CHECK_UNDERLINE, BM_GETCHECK, 0, 0) == BST_CHECKED); _pProp->fontProp.isCapital = (::SendDlgItemMessage(_hSelf, IDC_CHECK_CLM, BM_GETCHECK, 0, 0) == BST_CHECKED); _pProp->fontProp.isFocusRect = (::SendDlgItemMessage(_hSelf, IDC_CHECK_FOCUSRC, BM_GETCHECK, 0, 0) == BST_CHECKED); _ColCmbRegTxt.getColor(&_pProp->colorProp.rgbRegTxt); _ColCmbRegBk.getColor(&_pProp->colorProp.rgbRegBk); _ColCmbSelTxt.getColor(&_pProp->colorProp.rgbSelTxt); _ColCmbSelBk.getColor(&_pProp->colorProp.rgbSelBk); _ColCmbDiffTxt.getColor(&_pProp->colorProp.rgbDiffTxt); _ColCmbDiffBk.getColor(&_pProp->colorProp.rgbDiffBk); _ColCmbBkMkTxt.getColor(&_pProp->colorProp.rgbBkMkTxt); _ColCmbBkMkBk.getColor(&_pProp->colorProp.rgbBkMkBk); _ColCmbCurLine.getColor(&_pProp->colorProp.rgbCurLine); } else { ::SendDlgItemMessage(_hSelf, IDC_TAB_PROP, TCM_SETCURSEL, PROP_VIEW, NULL); } return bRet; }
void FindReplaceDlg::onFind(BOOL isVolatile) { /* get current scintilla */ HWND hSciSrc = getCurrentHScintilla(); INT lenSrc = ScintillaMsg(hSciSrc, SCI_GETLENGTH); INT offset = 0; INT length = 0; INT posBeg = 0; INT posEnd = 0; INT wrapPos = 0; BOOL loopEnd = FALSE; BOOL doWrap = FALSE; BOOL wrapDone = FALSE; tComboInfo info = {0}; if (_hSCI == NULL) { /* create new scintilla handle */ _hSCI = (HWND)::SendMessage(_nppData._nppHandle, NPPM_CREATESCINTILLAHANDLE, 0, (LPARAM)_hSelf); } /* in dependency of find type get search information from combo or directly from source */ if (isVolatile == FALSE) { _pFindCombo->getText(&_find); info = _find; if (info.length == 0) return; } else { getSelText(&info); if (info.length == 0) { if (NLMessageBox(_hInst, _hParent, _T("MsgBox SelectSomething"), MB_OK) == FALSE) ::MessageBox(_hParent, _T("Select something in the text!"), _T("Hex-Editor"), MB_OK); return; } } /* set match case */ ScintillaMsg(_hSCI, SCI_SETSEARCHFLAGS, _isMatchCase ? SCFIND_MATCHCASE : 0, 0); /* get selection and correct anchor and cursor position */ ::SendMessage(_hParentHandle, HEXM_GETSEL, (WPARAM)&posBeg, (LPARAM)&posEnd); if (posEnd < posBeg) { UINT posTmp = posBeg; posBeg = posEnd; posEnd = posTmp; } wrapPos = posBeg; do { BOOL isConverted = FALSE; /* copy data into scintilla handle (encoded if necessary) and select string */ if ((wrapDone == TRUE) && (lenSrc < FIND_BLOCK)) { if (_whichDirection == DIR_DOWN) { length = wrapPos + info.length + 1; } else { length = FIND_BLOCK; } } else { length = FIND_BLOCK; } if (_whichDirection == DIR_DOWN) { offset = posBeg; if (LittleEndianChange(_hSCI, hSciSrc, &offset, &length) == TRUE) { ScintillaMsg(_hSCI, SCI_SETTARGETSTART, posEnd - offset); ScintillaMsg(_hSCI, SCI_SETTARGETEND, length); isConverted = TRUE; } } else { posEnd -= FIND_BLOCK; offset = posEnd; if (LittleEndianChange(_hSCI, hSciSrc, &offset, &length) == TRUE) { ScintillaMsg(_hSCI, SCI_SETTARGETSTART, posBeg); ScintillaMsg(_hSCI, SCI_SETTARGETEND, posEnd - offset); isConverted = TRUE; } } if (isConverted == TRUE) { /* find string */ INT posFind = ScintillaMsg(_hSCI, SCI_SEARCHINTARGET, info.length, (LPARAM)info.text); if (posFind != -1) { /* found */ posFind += offset; ::SendMessage(_hParentHandle, HEXM_SETSEL, posFind, posFind + info.length); if (isVolatile == FALSE) { _pFindCombo->addText(info); } loopEnd = TRUE; } else { /* calculate new start find position */ if (_whichDirection == DIR_DOWN) { posBeg = offset + length; /* test if out of bound */ if ((posBeg >= lenSrc) && (wrapDone == FALSE)) { posBeg = 0; /* notify wrap is done */ doWrap = TRUE; } else if (posBeg != lenSrc) { /* calculate new start find position */ posBeg -= (info.length + 1); } /* indicate that wrap is still done */ wrapDone = doWrap; } else { /* indicate wrap done next time */ wrapDone = doWrap; posBeg = offset; /* test if out of bound */ if ((posBeg <= 0) && (wrapDone == FALSE)) { posBeg = lenSrc; /* notify wrap is done */ doWrap = TRUE; } else if (posBeg != 0) { /* calculate new start find position */ posBeg += (info.length + 1); } } /* if wrap was done and posBeg is jump over the wrapPos (start pos on function call)... */ if ((wrapDone == TRUE) && (((_whichDirection == DIR_DOWN) && (posBeg >= wrapPos)) || ((_whichDirection == DIR_UP ) && (posEnd <= wrapPos)))) { /* ... leave the function */ TCHAR text[128]; TCHAR TEMP[128]; if (NLGetText(_hInst, _hParent, _T("CantFind"), TEMP, 128)) { _tcscpy(text, TEMP); if (NLGetText(_hInst, _hParent, (_findReplace == TRUE)?_T("Replace"):_T("Find"), TEMP, 128)) { ::MessageBox(_hParent, text, TEMP, MB_OK); } else { ::MessageBox(_hParent, text, (_findReplace == TRUE)?_T("Replace"):_T("Find"), MB_OK); } } else { ::MessageBox(_hSelf, _T("Can't find"),(_findReplace == TRUE)?_T("Replace"):_T("Find"), MB_OK); } loopEnd = TRUE; } /* for further calculation */ posEnd = posBeg; } CleanScintillaBuf(_hSCI); } else { loopEnd = TRUE; } } while (loopEnd == FALSE); }
BOOL CALLBACK PropDlg::run_dlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: { /* set discription */ TCHAR szBuffer[256]; /* change language previously to avoid change of dynamic text*/ NLChangeDialog(_hInst, _hParent, _hSelf, _T("FavProp")); _stprintf(szBuffer, _T("%s:"), _pDesc); ::SetWindowText(::GetDlgItem(_hSelf, IDC_STATIC_FAVES_DESC), szBuffer); /* if name is not defined extract from link */ _tcscpy(szBuffer, _pLink); if ((_pName[0] == '\0') && (szBuffer[0] != '\0')) { if (szBuffer[_tcslen(szBuffer)-1] == '\\') { szBuffer[_tcslen(szBuffer)-1] = '\0'; } if (szBuffer[_tcslen(szBuffer)-1] == ':') { _tcscpy(_pName, szBuffer); } else { _tcscpy(_pName, (_tcsrchr(szBuffer, '\\')+1)); } } /* set name and link */ ::SetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_NAME), _pName); ::SetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_LINK), _pLink); SetFocus(::GetDlgItem(_hSelf, IDC_EDIT_NAME)); _hTreeCtrl = ::GetDlgItem(_hSelf, IDC_TREE_SELECT); goToCenter(); if (_linkDlg == LINK_DLG_NONE) { RECT rcName, rcLink; ::ShowWindow(::GetDlgItem(_hSelf, IDC_BTN_OPENDLG), SW_HIDE); ::GetWindowRect(::GetDlgItem(_hSelf, IDC_EDIT_NAME), &rcName); ::GetWindowRect(::GetDlgItem(_hSelf, IDC_EDIT_LINK), &rcLink); rcLink.right = rcName.right; ScreenToClient(_hSelf, &rcLink); ::SetWindowPos(::GetDlgItem(_hSelf, IDC_EDIT_LINK), NULL, rcLink.left, rcLink.top, rcLink.right-rcLink.left, rcLink.bottom-rcLink.top, SWP_NOZORDER); } if (_seeDetails == FALSE) { RECT rc = {0}; ::DestroyWindow(::GetDlgItem(_hSelf, IDC_TREE_SELECT)); ::DestroyWindow(::GetDlgItem(_hSelf, IDC_STATIC_SELECT)); ::DestroyWindow(::GetDlgItem(_hSelf, IDC_BUTTON_DETAILS)); /* resize window */ ::GetWindowRect(_hSelf, &rc); rc.top += 74; rc.bottom -= 74; /* resize window and keep sure to resize correct */ ::SetWindowPos(_hSelf, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); } else { /* get current icon offset */ UINT iIconPos = _pElem->uParam & FAVES_PARAM; /* set image list */ ::SendMessage(_hTreeCtrl, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)GetSmallImageList(FALSE)); HTREEITEM hItem = InsertItem(_pElem->pszName, iIconPos, _iUImgPos, 0, 0, TVI_ROOT, TVI_LAST, TRUE, (LPARAM)_pElem); TreeView_SelectItem(_hTreeCtrl, hItem); if (!NLGetText(_hInst, _hParent, _T("Details"), _szDetails, 20)) { _tcscpy(_szDetails, _T("Details %s")); } _stprintf(szBuffer, _szDetails, _T("<<")); ::SetWindowText(::GetDlgItem(_hSelf, IDC_BUTTON_DETAILS), szBuffer); } break; } case WM_COMMAND : { switch (LOWORD(wParam)) { case IDC_BUTTON_DETAILS: { RECT rc = {0}; TCHAR szBuffer[20]; /* toggle visibility state */ _seeDetails ^= TRUE; /* resize window */ ::GetWindowRect(_hSelf, &rc); if (_seeDetails == FALSE) { ::ShowWindow(::GetDlgItem(_hSelf, IDC_TREE_SELECT), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_STATIC_SELECT), SW_HIDE); _stprintf(szBuffer, _szDetails, _T(">>")); ::SetWindowText(::GetDlgItem(_hSelf, IDC_BUTTON_DETAILS), szBuffer); rc.bottom -= 148; } else { ::ShowWindow(::GetDlgItem(_hSelf, IDC_TREE_SELECT), SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_STATIC_SELECT), SW_SHOW); _stprintf(szBuffer, _szDetails, _T("<<")); ::SetWindowText(::GetDlgItem(_hSelf, IDC_BUTTON_DETAILS), szBuffer); rc.bottom += 148; } ::SetWindowPos(_hSelf, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); break; } case IDC_BTN_OPENDLG: { if (_linkDlg == LINK_DLG_FOLDER) { // This code was copied and slightly modifed from: // http://www.bcbdev.com/faqs/faq62.htm // SHBrowseForFolder returns a PIDL. The memory for the PIDL is // allocated by the shell. Eventually, we will need to free this // memory, so we need to get a pointer to the shell malloc COM // object that will free the PIDL later on. LPMALLOC pShellMalloc = 0; if (::SHGetMalloc(&pShellMalloc) == NO_ERROR) { // If we were able to get the shell malloc object, // then proceed by initializing the BROWSEINFO stuct BROWSEINFO info; ZeroMemory(&info, sizeof(info)); info.hwndOwner = _hParent; info.pidlRoot = NULL; info.pszDisplayName = (LPTSTR)new TCHAR[MAX_PATH]; info.lpszTitle = _T("Select a folder:"); info.ulFlags = BIF_RETURNONLYFSDIRS; info.lpfn = BrowseCallbackProc; info.lParam = (LPARAM)_pLink; // Execute the browsing dialog. LPITEMIDLIST pidl = ::SHBrowseForFolder(&info); // pidl will be null if they cancel the browse dialog. // pidl will be not null when they select a folder. if (pidl) { // Try to convert the pidl to a display string. // Return is true if success. if (::SHGetPathFromIDList(pidl, _pLink)) { // Set edit control to the directory path. ::SetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_LINK), _pLink); } pShellMalloc->Free(pidl); } pShellMalloc->Release(); delete [] info.pszDisplayName; } } else { LPTSTR pszLink = NULL; FileDlg dlg(_hInst, _hParent); dlg.setDefFileName(_pLink); if (_tcsstr(_pDesc, _T("Session")) != NULL) dlg.setExtFilter(_T("Session file"), _T(".session"), NULL); dlg.setExtFilter(_T("All types"), _T(".*"), NULL); if (_fileMustExist == TRUE) { pszLink = dlg.doSaveDlg(); } else { pszLink = dlg.doOpenSingleFileDlg(); } if (pszLink != NULL) { // Set edit control to the directory path. _tcscpy(_pLink, pszLink); ::SetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_LINK), _pLink); } } break; } case IDCANCEL: { ::EndDialog(_hSelf, FALSE); return TRUE; } case IDOK: { UINT lengthName = ::SendDlgItemMessage(_hSelf, IDC_EDIT_NAME, WM_GETTEXTLENGTH, 0, 0) + 1; UINT lengthLink = ::SendDlgItemMessage(_hSelf, IDC_EDIT_LINK, WM_GETTEXTLENGTH, 0, 0) + 1; SendDlgItemMessage(_hSelf, IDC_EDIT_NAME, WM_GETTEXT, lengthName, (LPARAM)_pName); SendDlgItemMessage(_hSelf, IDC_EDIT_LINK, WM_GETTEXT, lengthLink, (LPARAM)_pLink); if ((_tcslen(_pName) != 0) && (_tcslen(_pLink) != 0)) { TCHAR pszGroupName[MAX_PATH]; GetFolderPathName(TreeView_GetSelection(_hTreeCtrl), pszGroupName); _strGroupName = pszGroupName; ::EndDialog(_hSelf, TRUE); return TRUE; } else { if (NLMessageBox(_hInst, _hParent, _T("MsgBox AllFields"), MB_OK) == FALSE) ::MessageBox(_hParent, _T("Fill out all fields!"), _T("Error"), MB_OK); } break; } default: break; } break; } case WM_SIZE: { RECT rc = {0}; RECT rcMain = {0}; /* get main window size */ ::GetWindowRect(_hSelf, &rcMain); /* resize static box */ ::GetWindowRect(::GetDlgItem(_hSelf, IDC_STATIC_FAVES_DESC), &rc); rc.bottom = rcMain.bottom - 46; ScreenToClient(_hSelf, &rc); ::SetWindowPos(::GetDlgItem(_hSelf, IDC_STATIC_FAVES_DESC), NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); /* set position of OK button */ ::GetWindowRect(::GetDlgItem(_hSelf, IDOK), &rc); rc.top = rcMain.bottom - 36; rc.bottom = rcMain.bottom - 12; ScreenToClient(_hSelf, &rc); ::SetWindowPos(::GetDlgItem(_hSelf, IDOK), NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); /* set position of CANCEL button */ ::GetWindowRect(::GetDlgItem(_hSelf, IDCANCEL), &rc); rc.top = rcMain.bottom - 36; rc.bottom = rcMain.bottom - 12; ScreenToClient(_hSelf, &rc); ::SetWindowPos(::GetDlgItem(_hSelf, IDCANCEL), NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); /* set position of DETAILS button */ ::GetWindowRect(::GetDlgItem(_hSelf, IDC_BUTTON_DETAILS), &rc); rc.top = rcMain.bottom - 36; rc.bottom = rcMain.bottom - 12; ScreenToClient(_hSelf, &rc); ::SetWindowPos(::GetDlgItem(_hSelf, IDC_BUTTON_DETAILS), NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); break; } case WM_NOTIFY: { LPNMHDR nmhdr = (LPNMHDR)lParam; if (nmhdr->hwndFrom == _hTreeCtrl) { switch (nmhdr->code) { case TVN_ITEMEXPANDING: { DWORD dwpos = ::GetMessagePos(); TVHITTESTINFO ht; HTREEITEM hItem; ht.pt.x = GET_X_LPARAM(dwpos); ht.pt.y = GET_Y_LPARAM(dwpos); ::ScreenToClient(_hTreeCtrl, &ht.pt); hItem = TreeView_HitTest(_hTreeCtrl, &ht); if (hItem != NULL) { if (!TreeView_GetChild(_hTreeCtrl, hItem)) { DrawChildrenOfItem(hItem); } } break; } case TVN_SELCHANGED: { /* only when link params are also viewed */ if (_bWithLink == TRUE) { HTREEITEM hItem = TreeView_GetSelection(_hTreeCtrl); if (hItem != NULL) { PELEM pElem = (PELEM)GetParam(hItem); if (pElem != NULL) { if (pElem->uParam & FAVES_PARAM_LINK) { ::SetDlgItemText(_hSelf, IDC_EDIT_NAME, pElem->pszName); ::SetDlgItemText(_hSelf, IDC_EDIT_LINK, pElem->pszLink); } else { ::SetDlgItemText(_hSelf, IDC_EDIT_NAME, _T("")); ::SetDlgItemText(_hSelf, IDC_EDIT_LINK, _T("")); } } } } break; } default: break; } } break; } case WM_DESTROY : { /* deregister this dialog */ ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (LPARAM)_hSelf); break; } default: break; } return FALSE; }