BOOL CALLBACK CompareDlg::run_dlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: { goToCenter(); _pHexEdit1->getWindowRect(_rcEdit1); _pHexEdit2->getWindowRect(_rcEdit2); _isUpDown = (_rcEdit1.left == _rcEdit2.left ? TRUE : FALSE); if (_isUpDown == FALSE) { /* hide the unneccesary elements */ ::ShowWindow(::GetDlgItem(_hSelf, IDC_STATIC_COMPARE_TB), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_BUTTON_TOP), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_BUTTON_BOTTOM), SW_HIDE); /* focus the correct button */ if (_rcEdit1.left < _rcEdit2.left) { if (_currentSC == MAIN_VIEW) { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_LEFT)); } else { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_RIGHT)); } } else { if (_currentSC == SUB_VIEW) { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_LEFT)); } else { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_RIGHT)); } } } else { /* hide the unneccesary elements */ ::ShowWindow(::GetDlgItem(_hSelf, IDC_STATIC_COMPARE_LR), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_BUTTON_LEFT), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_BUTTON_RIGHT), SW_HIDE); /* focus the correct button */ if (_rcEdit1.top < _rcEdit2.top) { if (_currentSC == MAIN_VIEW) { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_TOP)); } else { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_BOTTOM)); } } else { if (_currentSC == SUB_VIEW) { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_TOP)); } else { ::SetFocus(::GetDlgItem(_hSelf, IDC_BUTTON_BOTTOM)); } } } /* change language */ NLChangeDialog(_hInst, _nppData._nppHandle, _hSelf, _T("CompDialog")); break; } case WM_COMMAND : { BOOL owEdit2 = FALSE; switch (LOWORD(wParam)) { case IDCANCEL: ::EndDialog(_hSelf, IDCANCEL); return FALSE; case IDC_BUTTON_TOP: if (_rcEdit1.top < _rcEdit2.top) owEdit2 = TRUE; break; case IDC_BUTTON_BOTTOM: if (_rcEdit2.top < _rcEdit1.top) owEdit2 = TRUE; break; case IDC_BUTTON_LEFT: if (_rcEdit1.left < _rcEdit2.left) owEdit2 = TRUE; break; case IDC_BUTTON_RIGHT: if (_rcEdit2.left < _rcEdit1.left) owEdit2 = TRUE; break; default: break; } tHexProp hexProp1 = _pHexEdit1->GetHexProp(); tHexProp hexProp2 = _pHexEdit2->GetHexProp(); /* set settings in on of the hex edit */ if (owEdit2 == TRUE) { tHexProp hexProp = hexProp2; hexProp.bits = hexProp1.bits; hexProp.columns = hexProp1.columns; hexProp.isBin = hexProp1.isBin; _pHexEdit2->SetHexProp(hexProp); } else { tHexProp hexProp = hexProp1; hexProp.bits = hexProp2.bits; hexProp.columns = hexProp2.columns; hexProp.isBin = hexProp2.isBin; _pHexEdit1->SetHexProp(hexProp); } ::EndDialog(_hSelf, LOWORD(wParam)); break; } default: break; } return FALSE; }
BOOL CALLBACK OptionDlg::run_dlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: { goToCenter(); for (int i = 0; i < SFMT_MAX; i++) { ::SendDlgItemMessage(_hSelf, IDC_COMBO_SIZE_FORMAT, CB_ADDSTRING, 0, (LPARAM)pszSizeFmt[i]); } for (i = 0; i < DFMT_MAX; i++) { ::SendDlgItemMessage(_hSelf, IDC_COMBO_DATE_FORMAT, CB_ADDSTRING, 0, (LPARAM)pszDateFmt[i]); } ::SendDlgItemMessage(_hSelf, IDC_EDIT_TIMEOUT, EM_LIMITTEXT, 5, 0); SetParams(); LongUpdate(); /* change language */ NLChangeDialog(_hInst, _nppData._nppHandle, _hSelf, _T("Options")); NLChangeCombo(_hInst, _nppData._nppHandle, ::GetDlgItem(_hSelf, IDC_COMBO_SIZE_FORMAT), _T("ComboSize"), SFMT_MAX); NLChangeCombo(_hInst, _nppData._nppHandle, ::GetDlgItem(_hSelf, IDC_COMBO_DATE_FORMAT), _T("ComboDate"), DFMT_MAX); break; } case WM_COMMAND : { switch (LOWORD(wParam)) { case IDC_CHECK_LONG: { LongUpdate(); return TRUE; } case IDC_BTN_OPENDLG: { // 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)_pProp->nppExecProp.szScriptPath; // 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, _pProp->nppExecProp.szScriptPath)) { // Set edit control to the directory path. ::SetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_SCRIPTPATH), _pProp->nppExecProp.szScriptPath); } pShellMalloc->Free(pidl); } pShellMalloc->Release(); delete [] info.pszDisplayName; } break; } case IDC_BTN_EXAMPLE_FILE: { #ifdef UNICODE CHAR szBOM[] = {0xFF, 0xFE}; #endif DWORD dwByteWritten = 0; TCHAR szExampleScriptPath[MAX_PATH]; if (_pProp->nppExecProp.szScriptPath[0] == '.') { /* module path of notepad */ GetModuleFileName(_hInst, szExampleScriptPath, sizeof(szExampleScriptPath)); PathRemoveFileSpec(szExampleScriptPath); PathAppend(szExampleScriptPath, _pProp->nppExecProp.szScriptPath); } else { _tcscpy(szExampleScriptPath, _pProp->nppExecProp.szScriptPath); } ::PathAppend(szExampleScriptPath, _T("Goto path.exec")); HANDLE hFile = ::CreateFile(szExampleScriptPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); #ifdef UNICODE ::WriteFile(hFile, szBOM, sizeof(szBOM), &dwByteWritten, NULL); #endif for (INT i = 0; i < MAX_NPP_EXAMPLE_LINE; i++) ::WriteFile(hFile, szExampleScript[i], _tcslen(szExampleScript[i]) * sizeof(TCHAR), &dwByteWritten, NULL); ::CloseHandle(hFile); break; } case IDCANCEL: ::EndDialog(_hSelf, IDCANCEL); return TRUE; case IDOK: { if (GetParams() == FALSE) { return FALSE; } ::EndDialog(_hSelf, IDOK); return TRUE; } default: return FALSE; } break; } default: break; } return FALSE; }
INT_PTR CALLBACK OptionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: { TCITEM item; TCHAR text[32]; goToCenter(); ETDTProc EnableDlgTheme = (ETDTProc)::SendMessage(_nppData._nppHandle, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0); if (EnableDlgTheme != NULL) EnableDlgTheme(_hSelf, ETDT_ENABLETAB); /* set tab texts */ item.mask = TCIF_TEXT; for (UINT i = 0; i < PROP_MAX; i++) { if (NLGetText(_hInst, _hParent, szTabNames[i], text, sizeof(text)) == FALSE) _tcscpy(text, szTabNames[i]); item.pszText = text; item.cchTextMax = (int)_tcslen(text); ::SendDlgItemMessage(_hSelf, IDC_TAB_PROP, TCM_INSERTITEM, i, (LPARAM)&item); } TabUpdate(); /* init color combos */ _ColCmbRegTxt.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_REGTXT_TXT)); _ColCmbRegBk.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_REGTXT_BK)); _ColCmbSelTxt.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_SEL_TXT)); _ColCmbSelBk.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_SEL_BK)); _ColCmbDiffTxt.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_DIFF_TXT)); _ColCmbDiffBk.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_DIFF_BK)); _ColCmbBkMkTxt.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_BKMK_TXT)); _ColCmbBkMkBk.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_BKMK_BK)); _ColCmbCurLine.init(_hInst, _hParent, ::GetDlgItem(_hSelf, IDC_COMBO_CURLINE)); /* init the font name combo */ LOGFONT lf; ZeroMemory(&lf, sizeof lf); lf.lfCharSet = DEFAULT_CHARSET; lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE; vector<string> vFontList; vFontList.push_back(_T("")); HDC hDC = ::GetDC(NULL); ::EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM) &vFontList, 0); for (size_t i = 0 ; i < vFontList.size(); i++) { ::SendDlgItemMessage(_hSelf, IDC_COMBO_FONTNAME, CB_ADDSTRING, 0, (LPARAM)vFontList[i].c_str()); } /* init font size combos */ for (size_t i = 0 ; i < G_FONTSIZE_MAX; i++) { _stprintf(text, _T("%d"), g_iFontSize[i]); ::SendDlgItemMessage(_hSelf, IDC_COMBO_FONTSIZE, CB_ADDSTRING, 0, (LPARAM)text); } SetParams(); /* change language */ NLChangeDialog(_hInst, _nppData._nppHandle, _hSelf, _T("Options")); break; } case WM_COMMAND : { switch (LOWORD(wParam)) { case IDOK: if (GetParams() == FALSE) return FALSE; ::EndDialog(_hSelf, IDOK); return TRUE; case IDCANCEL: ::EndDialog(_hSelf, IDCANCEL); return TRUE; case IDC_COMBO_REGTXT_TXT: _ColCmbRegTxt.onSelect(); break; case IDC_COMBO_REGTXT_BK: _ColCmbRegBk.onSelect(); break; case IDC_COMBO_SEL_TXT: _ColCmbSelTxt.onSelect(); break; case IDC_COMBO_SEL_BK: _ColCmbSelBk.onSelect(); break; case IDC_COMBO_DIFF_TXT: _ColCmbDiffTxt.onSelect(); break; case IDC_COMBO_DIFF_BK: _ColCmbDiffBk.onSelect(); break; case IDC_COMBO_BKMK_TXT: _ColCmbBkMkTxt.onSelect(); break; case IDC_COMBO_BKMK_BK: _ColCmbBkMkBk.onSelect(); break; case IDC_COMBO_CURLINE: _ColCmbCurLine.onSelect(); break; default: return FALSE; } break; } case WM_NOTIFY: { NMHDR nmhdr = *((LPNMHDR)lParam); if ((nmhdr.idFrom == IDC_TAB_PROP) && (nmhdr.code == TCN_SELCHANGE)) { TabUpdate(); return TRUE; } break; } default: break; } return FALSE; }
INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG : { initDialog(); goToCenter(); return TRUE; } case WM_ACTIVATE : { UINT posBeg; UINT posEnd; ::SendMessage(_hParentHandle, HEXM_GETSEL, (WPARAM)&posBeg, (LPARAM)&posEnd); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_IN_SEL), ((posBeg == posEnd)?FALSE:TRUE)); /* change language */ NLChangeDialog(_hInst, _nppData._nppHandle, _hSelf, _T("FindReplace")); break; } case WM_COMMAND : { switch (LOWORD(wParam)) { case IDOK : { onFind(FALSE); return TRUE; } case IDC_REPLACE: { onReplace(); break; } case IDC_COUNT : { processAll(COUNT); break; } case IDC_REPLACEALL : { HWND hSci = getCurrentHScintilla(); ScintillaMsg(hSci, SCI_BEGINUNDOACTION); processAll(REPLACE_ALL); ScintillaMsg(hSci, SCI_ENDUNDOACTION); return TRUE; } case IDC_COMBO_DATATYPE: { if (HIWORD(wParam) == CBN_SELCHANGE) changeCoding(); break; } case IDC_CHECK_TRANSPARENT : { setTrans(); break; } case IDC_RADIO_DIRUP : case IDC_RADIO_DIRDOWN : { _whichDirection = isChecked(IDC_RADIO_DIRDOWN); return TRUE; } case IDC_CHECK_MATCHCASE : { _isMatchCase = isChecked(IDC_CHECK_MATCHCASE); return TRUE; } case IDC_CHECK_WRAP : { _isWrap = isChecked(IDC_CHECK_WRAP); return TRUE; } case IDC_CHECK_IN_SEL : { _isInSel = isChecked(IDC_CHECK_IN_SEL); return TRUE; } case IDCANCEL : { display(FALSE); ::SetFocus(_hParentHandle); break; } default : break; } break; } case WM_NOTIFY: { NMHDR nmhdr = *((LPNMHDR)lParam); if ((nmhdr.idFrom == IDC_SWITCH) && (nmhdr.code == TCN_SELCHANGE)) { _findReplace = TabCtrl_GetCurSel(::GetDlgItem(_hSelf, IDC_SWITCH)); updateDialog(); } break; } case WM_HSCROLL : { if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_SLIDER_PERCENTAGE)) { setTrans(); } return TRUE; } } return 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; }