static int resize_column(HWND hwnd,HWND hlistview,char *str,int col) { int cw,sw; cw=ListView_GetColumnWidth(hlistview,col); sw=get_str_width(hlistview,str)+14; if(sw>cw){ RECT rect={0}; int diff=sw-cw; int w,h; GetWindowRect(hwnd,&rect); w=rect.right-rect.left; h=rect.bottom-rect.top; SetWindowPos(hwnd,NULL,0,0,w+diff,h,SWP_NOMOVE|SWP_NOZORDER); ListView_SetColumnWidth(hlistview,col,cw+diff); } return TRUE; }
void CManageBookmarksDialog::SaveState() { m_pmbdps->SaveDialogPosition(m_hDlg); HWND hListView = GetDlgItem(m_hDlg,IDC_MANAGEBOOKMARKS_LISTVIEW); int iColumn = 0; for(auto itr = m_pmbdps->m_vectorColumnInfo.begin();itr != m_pmbdps->m_vectorColumnInfo.end();++itr) { if(itr->bActive) { itr->iWidth = ListView_GetColumnWidth(hListView,iColumn); ++iColumn; } } m_pmbdps->m_bStateSaved = TRUE; }
int wbGetListViewColumnWidths(PWBOBJ pwbo, int *pwidths) { LV_COLUMN lvct; int i; if(!pwbo || !pwbo->hwnd || !IsWindow(pwbo->hwnd)) return FALSE; for(i = 0; i < MAX_LISTVIEWCOLS; i++) { lvct.iSubItem = i - 0; lvct.mask = LVCF_SUBITEM; if(pwidths) { *(pwidths + i) = ListView_GetColumnWidth(pwbo->hwnd, i); } if(!ListView_GetColumn(pwbo->hwnd, i, &lvct)) break; } return i; }
VOID ListView_GrowWindow( HANDLE WindowHandle ) { UINT32 columnWidth = 0; RECT windowRect, listViewRect; UINT8 totalColumns, i; totalColumns = ListView_Columns; for (i = 0; i < totalColumns; i++) { columnWidth += ListView_GetColumnWidth(i); } columnWidth += 50; GetWindowRect(WindowHandle, &windowRect); if (columnWidth > (UINT32)(windowRect.right - windowRect.left)) { SetWindowPos( WindowHandle, 0, 0, 0, columnWidth, windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); GetWindowRect(ListView_Handle, &listViewRect); SetWindowPos( ListView_Handle, 0, 0, 0, columnWidth - 15, listViewRect.bottom - listViewRect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); } }
void MemMgr_StoreSettings (void) { if (IsWindow (l.hManager)) { GetWindowRect (l.hManager, &lr.rManager); HWND hList = GetDlgItem (l.hManager, IDC_LIST); if (IsWindow (hList)) { for (size_t ii = 0; ii < 6; ++ii) lr.acxColumns[ ii ] = ListView_GetColumnWidth (hList, ii); } } HKEY hk; if (RegCreateKey (HKEY_LOCAL_MACHINE, TEXT("Software\\Random\\MemMgr"), &hk) == 0) { RegSetValueEx (hk, TEXT("Settings"), 0, REG_BINARY, (PBYTE)&lr, sizeof(lr)); RegCloseKey (hk); } }
int CCListBox::GetColumnIndexesAndSizes(LIST_COLUMNORDER* p) { int nColumns = this->GetColumnCount(); int i; int* pOrder = NULL; // Get column orders. pOrder = new int[nColumns]; if(pOrder == 0) return -1; ListView_GetColumnOrderArray(m_hWnd, nColumns, pOrder); // Now get the column sizes and stick ALL the info in the outgoing struct for(i=0;i<nColumns;i++) { if(p) p[i].Set(pOrder[i], ListView_GetColumnWidth(m_hWnd, i)); } delete [] pOrder; return nColumns; }
void VDUISaveListViewColumnsW32(HWND hwnd, const char *name) { HWND hwndHeader = ListView_GetHeader(hwnd); int count = Header_GetItemCount(hwndHeader); vdfastvector<float> widths(count); int sum = 0; for(int i=0; i<count; ++i) { int w = ListView_GetColumnWidth(hwnd, i); widths[i] = (float)w; sum += w; } if (sum > 0) { float invsum = 1.0f / sum; for(int i=0; i<count; ++i) widths[i] *= invsum; VDRegistryAppKey key("Window Placement"); key.setBinary(name, (const char *)widths.data(), count*sizeof(float)); } }
void SaveColumnSizes(HWND hwndResults) { int columnOrder[NUM_COLUMNID]; int columnCount; char szSetting[32]; int i; struct FindAddDlgData *dat; dat = (struct FindAddDlgData*)GetWindowLongPtr(GetParent(hwndResults), GWLP_USERDATA); columnCount = Header_GetItemCount(ListView_GetHeader(hwndResults)); if (columnCount != NUM_COLUMNID) return; ListView_GetColumnOrderArray(hwndResults, columnCount, columnOrder); for (i=0; i < NUM_COLUMNID; i++) { mir_snprintf(szSetting, SIZEOF(szSetting), "ColOrder%d", i); db_set_b(NULL, "FindAdd", szSetting, (BYTE)columnOrder[i]); if (i>=columnCount) continue; mir_snprintf(szSetting, SIZEOF(szSetting), "ColWidth%d", i); db_set_w(NULL, "FindAdd", szSetting, (WORD)ListView_GetColumnWidth(hwndResults, i)); } db_set_b(NULL, "FindAdd", "SortColumn", (BYTE)dat->iLastColumnSortIndex); db_set_b(NULL, "FindAdd", "SortAscending", (BYTE)dat->bSortAscending); }
INT_PTR CALLBACK device_list_wndproc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { TCHAR tipText[80]; POINT pt; static int oldX, oldY; int newX, newY; LVHITTESTINFO hitTestInfo; LVITEM lvitem; device_context_t* dev_context; BOOL ignored; switch(message) { case WM_MOUSELEAVE: // The mouse pointer has left our window. // Deactivate the tooltip. SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)FALSE, (LPARAM)&g_toolItem); g_TrackingMouse = FALSE; return FALSE; case WM_MOUSEMOVE: if (!g_TrackingMouse) { // The mouse has just entered the window. // Request notification when the mouse leaves. TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) }; tme.hwndTrack = hDlg; tme.dwFlags = TME_LEAVE; TrackMouseEvent(&tme); // Activate the tooltip. SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)&g_toolItem); g_TrackingMouse = TRUE; } newX = LOWORD(lParam); newY = HIWORD(lParam); // Make sure the mouse has actually moved. The presence of the tooltip // causes Windows to send the message continuously. if ((newX != oldX) || (newY != oldY)) { oldX = newX; oldY = newY; memset(&hitTestInfo,0,sizeof(hitTestInfo)); hitTestInfo.pt.x = newX; hitTestInfo.pt.y = newY; if ((ListView_HitTest(hDlg, &hitTestInfo) == -1) || newX > ListView_GetColumnWidth(hDlg, 0)) { safe_sprintf(tipText, sizeof(tipText) - 1, TEXT("%s"), TEXT("")); SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE,FALSE, (LPARAM)&g_toolItem); } else { SendMessage(g_hwndTrackingTT, TTM_SETDELAYTIME,TTDT_INITIAL, 1000); memset(&lvitem, 0 , sizeof(lvitem)); lvitem.iItem = hitTestInfo.iItem; lvitem.mask = LVIF_PARAM; ignored = ListView_GetItem(hDlg,&lvitem); dev_context = (device_context_t*)lvitem.lParam; // Update the text. safe_sprintf(tipText, sizeof(tipText)-1 , TEXT("%s"), wdi_get_vendor_name(dev_context->wdi->vid)); SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE,TRUE, (LPARAM)&g_toolItem); } g_toolItem.lpszText = tipText; SendMessage(g_hwndTrackingTT, TTM_SETTOOLINFO, 0, (LPARAM)&g_toolItem); // Position the tooltip. // The coordinates are adjusted so that the tooltip does not // overlap the mouse pointer. pt.x = newX; pt.y = newY; ClientToScreen(hDlg, &pt); SendMessage(g_hwndTrackingTT, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(pt.x + 10, pt.y - 20)); } break; } return CallWindowProc(device_list_wndproc_orig, hDlg, message, wParam, lParam); }
void CManageBookmarksDialog::OnListViewHeaderRClick() { DWORD dwCursorPos = GetMessagePos(); POINT ptCursor; ptCursor.x = GET_X_LPARAM(dwCursorPos); ptCursor.y = GET_Y_LPARAM(dwCursorPos); HMENU hMenu = CreatePopupMenu(); int iItem = 0; for each(auto ci in m_pmbdps->m_vectorColumnInfo) { TCHAR szColumn[128]; GetColumnString(ci.ColumnType,szColumn,SIZEOF_ARRAY(szColumn)); MENUITEMINFO mii; mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID|MIIM_STRING|MIIM_STATE; mii.wID = ci.ColumnType; mii.dwTypeData = szColumn; mii.fState = 0; if(ci.bActive) { mii.fState |= MFS_CHECKED; } /* The name column cannot be removed. */ if(ci.ColumnType == CManageBookmarksDialogPersistentSettings::COLUMN_TYPE_NAME) { mii.fState |= MFS_DISABLED; } InsertMenuItem(hMenu,iItem,TRUE,&mii); ++iItem; } int iCmd = TrackPopupMenu(hMenu,TPM_LEFTALIGN|TPM_RETURNCMD,ptCursor.x,ptCursor.y,0,m_hDlg,NULL); DestroyMenu(hMenu); int iColumn = 0; for(auto itr = m_pmbdps->m_vectorColumnInfo.begin();itr != m_pmbdps->m_vectorColumnInfo.end();++itr) { if(itr->ColumnType == iCmd) { HWND hListView = GetDlgItem(m_hDlg,IDC_MANAGEBOOKMARKS_LISTVIEW); if(itr->bActive) { itr->iWidth = ListView_GetColumnWidth(hListView,iColumn); ListView_DeleteColumn(hListView,iColumn); } else { LVCOLUMN lvCol; TCHAR szTemp[128]; GetColumnString(itr->ColumnType,szTemp,SIZEOF_ARRAY(szTemp)); lvCol.mask = LVCF_TEXT|LVCF_WIDTH; lvCol.pszText = szTemp; lvCol.cx = itr->iWidth; ListView_InsertColumn(hListView,iColumn,&lvCol); HWND hTreeView = GetDlgItem(m_hDlg,IDC_MANAGEBOOKMARKS_TREEVIEW); HTREEITEM hSelected = TreeView_GetSelection(hTreeView); CBookmarkFolder &BookmarkFolder = m_pBookmarkTreeView->GetBookmarkFolderFromTreeView(hSelected); int iItem = 0; for(auto itrBookmarks = BookmarkFolder.begin();itrBookmarks != BookmarkFolder.end();++itrBookmarks) { TCHAR szColumn[256]; GetBookmarkItemColumnInfo(*itrBookmarks,itr->ColumnType,szColumn,SIZEOF_ARRAY(szColumn)); ListView_SetItemText(hListView,iItem,iColumn,szColumn); ++iItem; } } itr->bActive = !itr->bActive; break; } else { if(itr->bActive) { ++iColumn; } } } }
inline size_t CListView::ColumnWidth(size_t nColumn) const { return ListView_GetColumnWidth(m_hWnd, nColumn); }
static INT_PTR CALLBACK LangOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwndList = GetDlgItem(hwndDlg, IDC_LANGLIST); LVITEM lvi; switch(msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); hwndLangOpt = hwndDlg; ListView_SetExtendedListViewStyle(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP); ListView_SetImageList(hwndList, CreateRadioImages(ListView_GetBkColor(hwndList), ListView_GetTextColor(hwndList)), LVSIL_STATE); /* auto-destroyed */ { LVCOLUMN lvc; lvc.mask = LVCF_TEXT; lvc.pszText = TranslateT("Installed Languages"); ListView_InsertColumn(hwndList, 0, &lvc); } if ( ServiceExists(MS_FLAGS_LOADFLAGICON)) ListView_SetImageList(hwndList, ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR24, 8, 8), LVSIL_SMALL); TCHAR szPath[MAX_PATH]; GetPackPath(szPath, SIZEOF(szPath), FALSE, _T("")); SetDlgItemText(hwndDlg, IDC_SKINROOTFOLDER, szPath); SendMessage(hwndDlg, M_RELOADLIST, 0, 0); SendMessage(hwndDlg, M_SHOWFILECOL, 0, 1); return TRUE; case M_RELOADLIST: /* init list */ ListView_DeleteAllItems(hwndList); ListView_DeleteColumn(hwndList, 1); /* if present */ { HIMAGELIST himl = ListView_GetImageList(hwndList, LVSIL_SMALL); ImageList_RemoveAll(himl); /* enum all packs */ EnumPacks(InsertPackItemEnumProc, _T("langpack_*.txt"), "Miranda Language Pack Version 1", (WPARAM)hwndList, (LPARAM)himl); /* make it use current langpack locale for sort */ ListView_SortItems(hwndList, CompareListItem, CallService(MS_LANGPACK_GETLOCALE, 0, 0)); //CheckDlgButton(hwndDlg, IDC_ENABLEAUTOUPDATES, db_get_b(NULL, "LangMan", "EnableAutoUpdates", SETTING_ENABLEAUTOUPDATES_DEFAULT) != 0); /* show selection */ int iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED); if (iItem != -1) ListView_EnsureVisible(hwndList, iItem, FALSE); } return TRUE; case M_SHOWFILECOL: if ((BOOL)lParam && ListView_GetItemCount(hwndList) > 1) { /* add column */ LVCOLUMN lvc; ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE_USEHEADER); lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; lvc.pszText = TranslateT("File"); lvc.cx = 160; ListView_InsertColumn(hwndList, lvc.iSubItem = 1, &lvc); ListView_SetColumnWidth(hwndList, 0, ListView_GetColumnWidth(hwndList, 0) - lvc.cx); /* add text */ lvi.mask = LVIF_PARAM; lvi.iSubItem = 0; for (lvi.iItem = 0; ListView_GetItem(hwndList, &lvi); ++lvi.iItem) { LANGPACK_INFO *pack = (LANGPACK_INFO*)lvi.lParam; ListView_SetItemText(hwndList, lvi.iItem, 1, (pack->flags&LPF_DEFAULT) ? TranslateT("built-in") : pack->szFileName); } } else { ListView_DeleteColumn(hwndList, 1); ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE_USEHEADER); } return TRUE; case WM_DESTROY: ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_LANGLIST)); return TRUE; case WM_THEMECHANGED: case WM_SETTINGCHANGE: { HIMAGELIST himl = ListView_SetImageList(hwndList, CreateRadioImages(ListView_GetBkColor(hwndList), ListView_GetTextColor(hwndList)), LVSIL_STATE); /* auto-destroyed */ if (himl != NULL) ImageList_Destroy(himl); } break; case WM_CTLCOLORLISTBOX: /* mimic readonly edit */ return (BOOL)SendMessage(hwndDlg, WM_CTLCOLORSTATIC, wParam, lParam); case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_LANGEMAIL: { char buf[512]; lstrcpyA(buf, "mailto:"); if (GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), &buf[7], sizeof(buf)-7)) CallService(MS_UTILS_OPENURL, FALSE, (LPARAM)buf); return TRUE; } case IDC_MORELANG: CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)"http://miranda-ng.org/"); return TRUE; } break; case WM_CONTEXTMENU: if (GetDlgCtrlID((HWND)wParam) == IDC_LANGLIST) { /* get item */ LVHITTESTINFO hti; POINTSTOPOINT(hti.pt, MAKEPOINTS(lParam)); if (hti.pt.x == -1 && hti.pt.y == -1) { /* keyboard invoked */ hti.iItem = ListView_GetNextItem((HWND)wParam, -1, LVNI_SELECTED); if (hti.iItem != -1) break; RECT rc; if (!ListView_GetItemRect((HWND)wParam, hti.iItem, &rc, LVIR_SELECTBOUNDS)) break; hti.pt.x = rc.left + (rc.right - rc.left) / 2; hti.pt.y = rc.top + (rc.bottom - rc.top) / 2; ClientToScreen((HWND)wParam, &hti.pt); } else { ScreenToClient((HWND)wParam, &hti.pt); if (ListView_HitTest((HWND)wParam, &hti) == -1 || !(hti.flags&LVHT_ONITEM)) break; POINTSTOPOINT(hti.pt, MAKEPOINTS(lParam)); } /* param */ lvi.iItem = hti.iItem; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (!ListView_GetItem((HWND)wParam, &lvi)) break; /* context menu */ LANGPACK_INFO *pack = (LANGPACK_INFO*)lvi.lParam; if (!(pack->flags & LPF_DEFAULT)) { HMENU hContextMenu = CreatePopupMenu(); if (hContextMenu != NULL) { AppendMenu(hContextMenu, MF_STRING, 2, TranslateT("&Remove...")); if (TrackPopupMenuEx(hContextMenu, TPM_RETURNCMD | TPM_NONOTIFY | TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_HORPOSANIMATION | TPM_VERPOSANIMATION, hti.pt.x, hti.pt.y, (HWND)wParam, NULL)) DeletePackFile(hwndDlg, (HWND)wParam, hti.iItem, pack); DestroyMenu(hContextMenu); } } return TRUE; } break; case WM_NOTIFYFORMAT: SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, NFR_UNICODE); return TRUE; case WM_NOTIFY: NMHDR *nmhdr = (NMHDR*)lParam; switch (nmhdr->idFrom) { case IDC_LANGLIST: switch (nmhdr->code) { case LVN_DELETEITEM: lvi.iItem = ((NMLISTVIEW*)lParam)->iItem; /* nmlv->lParam is invalid */ lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (ListView_GetItem(nmhdr->hwndFrom, &lvi)) mir_free((LANGPACK_INFO*)lvi.lParam); break; case LVN_ITEMCHANGED: { NMLISTVIEW *nmlv = (NMLISTVIEW*)lParam; if (!(nmlv->uChanged&LVIF_STATE)) break; /* display info and check radio item */ if (nmlv->uNewState&LVIS_SELECTED && !(nmlv->uOldState&LVIS_SELECTED)) { ListView_SetItemState(nmhdr->hwndFrom, nmlv->iItem, INDEXTOSTATEIMAGEMASK(2), LVIS_STATEIMAGEMASK); DisplayPackInfo(hwndDlg, (LANGPACK_INFO*)nmlv->lParam); } /* disable all other radio items */ else if (nmlv->uNewState&INDEXTOSTATEIMAGEMASK(2)) { for (int iItem = ListView_GetItemCount(nmhdr->hwndFrom) - 1; iItem != -1; --iItem) if (iItem != nmlv->iItem) ListView_SetItemState(nmhdr->hwndFrom, iItem, INDEXTOSTATEIMAGEMASK(1), LVIS_STATEIMAGEMASK); /* enable apply */ if (nmlv->uOldState) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), SW_SHOW); } } } break; case LVN_KEYDOWN: { int iItem = ListView_GetNextItem(nmhdr->hwndFrom, -1, LVNI_SELECTED); switch (((NMLVKEYDOWN*)lParam)->wVKey) { case VK_SPACE: ListView_SetItemState(nmhdr->hwndFrom, iItem, INDEXTOSTATEIMAGEMASK(2), LVIS_STATEIMAGEMASK); break; case VK_DELETE: lvi.iItem = iItem; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (ListView_GetItem(nmhdr->hwndFrom, &lvi)) { LANGPACK_INFO *pack = (LANGPACK_INFO*)lvi.lParam; if (!(pack->flags&LPF_DEFAULT)) DeletePackFile(hwndDlg, nmhdr->hwndFrom, iItem, pack); } break; } } break; case NM_CLICK: LVHITTESTINFO hti; lParam = GetMessagePos(); POINTSTOPOINT(hti.pt, MAKEPOINTS(lParam)); ScreenToClient(nmhdr->hwndFrom, &hti.pt); if (ListView_HitTest(nmhdr->hwndFrom, &hti) != -1) if (hti.flags&(LVHT_ONITEMSTATEICON | LVHT_ONITEMICON)) /* one of them */ ListView_SetItemState(nmhdr->hwndFrom, hti.iItem, LVIS_SELECTED, LVIS_SELECTED); } break; case 0: switch (nmhdr->code) { case PSN_APPLY: lvi.mask = LVIF_STATE | LVIF_PARAM; lvi.stateMask = LVIS_STATEIMAGEMASK; lvi.iSubItem = 0; for (lvi.iItem = 0; ListView_GetItem(hwndList, &lvi); ++lvi.iItem) { LANGPACK_INFO *pack = (LANGPACK_INFO*)lvi.lParam; if (lvi.state&INDEXTOSTATEIMAGEMASK(2) && !(pack->flags & LPF_ENABLED)) { if(!(pack->flags & LPF_DEFAULT)) db_set_ws(NULL, "LangMan", "Langpack", pack->szFileName); else db_unset(NULL, "LangMan", "Langpack"); TCHAR szPath[MAX_PATH]; GetPackPath(szPath, SIZEOF(szPath), FALSE, pack->szFileName); CallService(MS_LANGPACK_RELOAD, 0, (LPARAM)szPath); pack->flags |= LPF_ENABLED; CloseWindow(GetParent(hwndDlg)); DestroyWindow(GetParent(hwndDlg)); } else pack->flags &= ~LPF_ENABLED; } return TRUE; } } break; } return FALSE; }
BOOL plMultistageBehComponent::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { // Adding a new stage if (LOWORD(wParam) == IDC_ADD) { // Create the new stage and give it a default name. plBaseStage* stage = new plStandardStage; int count = fStages.size(); fStages.push_back(stage); char buf[64]; sprintf(buf, "Stage %d", count); stage->SetName(buf); // Add the new stage to the list and make sure the list is wide enough HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST); int idx = ListView_AddString(hList, stage->GetName().c_str()); ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE); ListView_SetItemState(hList, idx, LVIS_SELECTED, LVIS_SELECTED); // Put up the new stages dialog IDestroyStageDlg(); fCurStage = idx; ICreateStageDlg(); SetSaveRequiredFlag(); } // Removing the selected stage else if (LOWORD(wParam) == IDC_REMOVE) { HWND hList = GetDlgItem(fDlg, IDC_STAGE_LIST); int sel = ListView_GetNextItem(hList, -1, LVNI_SELECTED); if (sel != -1) { IDestroyStageDlg(); plBaseStage* stage = fStages[sel]; fStages.erase(fStages.begin()+sel); delete stage; ListView_DeleteItem(hList, sel); SetSaveRequiredFlag(); } } else if (LOWORD(wParam) == IDC_FREEZE_PHYS) { fFreezePhys = (Button_GetCheck((HWND)lParam) == BST_CHECKED); SetSaveRequiredFlag(); } else if (LOWORD(wParam) == IDC_SMART_SEEK) { fSmartSeek = (Button_GetCheck((HWND)lParam) == BST_CHECKED); SetSaveRequiredFlag(); } else if (LOWORD(wParam) == IDC_MULTI_REVERSE_CTL) { fReverseFBOnRelease = (Button_GetCheck((HWND)lParam) == BST_CHECKED); SetSaveRequiredFlag(); } return TRUE; } break; case WM_NOTIFY: { NMHDR *nmhdr = (NMHDR*)lParam; if (nmhdr->idFrom == IDC_STAGE_LIST) { switch (nmhdr->code) { // Stop Max from reading keypresses while the list has focus case NM_SETFOCUS: plMaxAccelerators::Disable(); return TRUE; case NM_KILLFOCUS: plMaxAccelerators::Enable(); return TRUE; // The edit box this creates kills the focus on the listbox, // so add an extra disable to ignore it case LVN_BEGINLABELEDIT: plMaxAccelerators::Disable(); return TRUE; // Finishing changing the name of a stage case LVN_ENDLABELEDIT: { NMLVDISPINFO *di = (NMLVDISPINFO*)lParam; const char *name = di->item.pszText; // If the name was changed... if (name && *name != '\0') { plBaseStage* stage = fStages[fCurStage]; stage->SetName(name); // Make sure the column is wide enough int width = ListView_GetStringWidth(nmhdr->hwndFrom, name)+10; if (width > ListView_GetColumnWidth(nmhdr->hwndFrom, 0)) { ListView_SetColumnWidth(nmhdr->hwndFrom, 0, width); } // Return true to keep the changes SetWindowLong(hDlg, DWL_MSGRESULT, TRUE); } plMaxAccelerators::Enable(); } return TRUE; case LVN_ITEMCHANGED: { int sel = ListView_GetNextItem(nmhdr->hwndFrom, -1, LVNI_SELECTED); IDestroyStageDlg(); if (sel != -1 && sel != fCurStage) { fCurStage = sel; ICreateStageDlg(); } } return TRUE; } } } break; } return FALSE; }
INT_PTR Dlg_MemBookmark::MemBookmarkDialogProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { PMEASUREITEMSTRUCT pmis; PDRAWITEMSTRUCT pdis; int nSelect; HWND hList; int offset = 2; RECT rcBounds, rcLabel; switch ( uMsg ) { case WM_INITDIALOG: { GenerateResizes( hwnd ); m_hMemBookmarkDialog = hwnd; hList = GetDlgItem( m_hMemBookmarkDialog, IDC_RA_LBX_ADDRESSES ); SetupColumns( hList ); // Auto-import bookmark file when opening dialog if ( g_pCurrentGameData->GetGameID() != 0 ) { std::string file = RA_DIR_BOOKMARKS + std::to_string( g_pCurrentGameData->GetGameID() ) + "-Bookmarks.txt"; ImportFromFile( file ); } RestoreWindowPosition( hwnd, "Memory Bookmarks", true, false ); return TRUE; } case WM_GETMINMAXINFO: { LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; lpmmi->ptMinTrackSize = pDlgMemBookmarkMin; } break; case WM_SIZE: { RARect winRect; GetWindowRect( hwnd, &winRect ); for ( ResizeContent content : vDlgMemBookmarkResize ) content.Resize( winRect.Width(), winRect.Height() ); //InvalidateRect( hwnd, NULL, TRUE ); RememberWindowSize(hwnd, "Memory Bookmarks"); } break; case WM_MOVE: RememberWindowPosition(hwnd, "Memory Bookmarks"); break; case WM_MEASUREITEM: pmis = (PMEASUREITEMSTRUCT)lParam; pmis->itemHeight = 16; return TRUE; case WM_DRAWITEM: { pdis = (PDRAWITEMSTRUCT)lParam; // If there are no list items, skip this message. if ( pdis->itemID == -1 ) break; switch ( pdis->itemAction ) { case ODA_SELECT: case ODA_DRAWENTIRE: hList = GetDlgItem( hwnd, IDC_RA_LBX_ADDRESSES ); ListView_GetItemRect( hList, pdis->itemID, &rcBounds, LVIR_BOUNDS ); ListView_GetItemRect( hList, pdis->itemID, &rcLabel, LVIR_LABEL ); RECT rcCol ( rcBounds ); rcCol.right = rcCol.left + ListView_GetColumnWidth( hList, 0 ); // Draw Item Label - Column 0 wchar_t buffer[ 512 ]; if ( m_vBookmarks[ pdis->itemID ]->Decimal() ) swprintf_s ( buffer, 512, L"(D)%s", m_vBookmarks[ pdis->itemID ]->Description().c_str() ); else swprintf_s ( buffer, 512, L"%s", m_vBookmarks[ pdis->itemID ]->Description().c_str() ); if ( pdis->itemState & ODS_SELECTED ) { SetTextColor( pdis->hDC, GetSysColor( COLOR_HIGHLIGHTTEXT ) ); SetBkColor( pdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) ); FillRect( pdis->hDC, &rcBounds, GetSysColorBrush( COLOR_HIGHLIGHT ) ); } else { SetTextColor( pdis->hDC, GetSysColor( COLOR_WINDOWTEXT ) ); COLORREF color; if ( m_vBookmarks[ pdis->itemID ]->Frozen() ) color = RGB( 255, 255, 160 ); else color = GetSysColor( COLOR_WINDOW ); HBRUSH hBrush = CreateSolidBrush( color ); SetBkColor( pdis->hDC, color ); FillRect( pdis->hDC, &rcBounds, hBrush ); DeleteObject( hBrush ); } if ( wcslen( buffer ) > 0 ) { rcLabel.left += ( offset / 2 ); rcLabel.right -= offset; DrawTextW( pdis->hDC, buffer, wcslen( buffer ), &rcLabel, DT_SINGLELINE | DT_LEFT | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS ); } // Draw Item Label for remaining columns LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH; for ( size_t i = 1; ListView_GetColumn( hList, i, &lvc ); ++i ) { rcCol.left = rcCol.right; rcCol.right += lvc.cx; switch ( i ) { case CSI_ADDRESS: swprintf_s ( buffer, 512, L"%06x", m_vBookmarks[ pdis->itemID ]->Address() ); break; case CSI_VALUE: if ( m_vBookmarks[ pdis->itemID ]->Decimal() ) swprintf_s ( buffer, 512, L"%u", m_vBookmarks[ pdis->itemID ]->Value() ); else { switch ( m_vBookmarks[ pdis->itemID ]->Type() ) { case 1: swprintf_s ( buffer, 512, L"%02x", m_vBookmarks[ pdis->itemID ]->Value() ); break; case 2: swprintf_s ( buffer, 512, L"%04x", m_vBookmarks[ pdis->itemID ]->Value() ); break; case 3: swprintf_s ( buffer, 512, L"%08x", m_vBookmarks[ pdis->itemID ]->Value() ); break; } } break; case CSI_PREVIOUS: if ( m_vBookmarks[ pdis->itemID ]->Decimal() ) swprintf_s ( buffer, 512, L"%u", m_vBookmarks[ pdis->itemID ]->Previous() ); else { switch ( m_vBookmarks[ pdis->itemID ]->Type() ) { case 1: swprintf_s ( buffer, 512, L"%02x", m_vBookmarks[ pdis->itemID ]->Previous() ); break; case 2: swprintf_s ( buffer, 512, L"%04x", m_vBookmarks[ pdis->itemID ]->Previous() ); break; case 3: swprintf_s ( buffer, 512, L"%08x", m_vBookmarks[ pdis->itemID ]->Previous() ); break; } } break; case CSI_CHANGES: swprintf_s ( buffer, 512, L"%d", m_vBookmarks[ pdis->itemID ]->Count() ); break; default: swprintf_s ( buffer, 512, L"" ); break; } if ( wcslen( buffer ) == 0 ) continue; UINT nJustify = DT_LEFT; switch ( lvc.fmt & LVCFMT_JUSTIFYMASK ) { case LVCFMT_RIGHT: nJustify = DT_RIGHT; break; case LVCFMT_CENTER: nJustify = DT_CENTER; break; default: break; } rcLabel = rcCol; rcLabel.left += offset; rcLabel.right -= offset; DrawTextW( pdis->hDC, buffer, wcslen( buffer ), &rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS ); } //if (pdis->itemState & ODS_SELECTED) //&& (GetFocus() == this) // DrawFocusRect(pdis->hDC, &rcBounds); break; case ODA_FOCUS: break; } return TRUE; } case WM_NOTIFY: { switch ( LOWORD( wParam ) ) { case IDC_RA_LBX_ADDRESSES: if ( ( (LPNMHDR)lParam )->code == NM_CLICK ) { hList = GetDlgItem( hwnd, IDC_RA_LBX_ADDRESSES ); nSelect = ListView_GetNextItem( hList, -1, LVNI_FOCUSED ); if ( nSelect == -1 ) break; } else if ( ( (LPNMHDR)lParam )->code == NM_DBLCLK ) { hList = GetDlgItem( hwnd, IDC_RA_LBX_ADDRESSES ); LPNMITEMACTIVATE pOnClick = (LPNMITEMACTIVATE)lParam; if ( pOnClick->iItem != -1 && pOnClick->iSubItem == CSI_DESC ) { nSelItemBM = pOnClick->iItem; nSelSubItemBM = pOnClick->iSubItem; EditLabel ( pOnClick->iItem, pOnClick->iSubItem ); } else if ( pOnClick->iItem != -1 && pOnClick->iSubItem == CSI_ADDRESS ) { g_MemoryDialog.SetWatchingAddress( m_vBookmarks[ pOnClick->iItem ]->Address() ); MemoryViewerControl::setAddress( ( m_vBookmarks[ pOnClick->iItem ]->Address() & ~( 0xf ) ) - ( (int)( MemoryViewerControl::m_nDisplayedLines / 2 ) << 4 ) + ( 0x50 ) ); } } } return TRUE; } case WM_COMMAND: { switch ( LOWORD( wParam ) ) { case IDOK: case IDCLOSE: case IDCANCEL: EndDialog( hwnd, true ); return TRUE; case IDC_RA_ADD_BOOKMARK: { if ( g_MemoryDialog.GetHWND() != nullptr ) AddAddress(); return TRUE; } case IDC_RA_DEL_BOOKMARK: { HWND hList = GetDlgItem( hwnd, IDC_RA_LBX_ADDRESSES ); int nSel = ListView_GetNextItem( hList, -1, LVNI_SELECTED ); if ( nSel != -1 ) { while ( nSel >= 0 ) { MemBookmark* pBookmark = m_vBookmarks[ nSel ]; // Remove from vector m_vBookmarks.erase( m_vBookmarks.begin() + nSel ); // Remove from map std::vector<const MemBookmark*> *pVector; pVector = &m_BookmarkMap.find( pBookmark->Address() )->second; pVector->erase( std::find( pVector->begin(), pVector->end(), pBookmark ) ); if ( pVector->size() == 0 ) m_BookmarkMap.erase( pBookmark->Address() ); delete pBookmark; ListView_DeleteItem( hList, nSel ); nSel = ListView_GetNextItem( hList, -1, LVNI_SELECTED ); } InvalidateRect( hList, NULL, FALSE ); } return TRUE; } case IDC_RA_FREEZE: { if ( m_vBookmarks.size() > 0 ) { hList = GetDlgItem( hwnd, IDC_RA_LBX_ADDRESSES ); unsigned int uSelectedCount = ListView_GetSelectedCount( hList ); if ( uSelectedCount > 0 ) { for ( int i = ListView_GetNextItem( hList, -1, LVNI_SELECTED ); i >= 0; i = ListView_GetNextItem( hList, i, LVNI_SELECTED ) ) m_vBookmarks[ i ]->SetFrozen( !m_vBookmarks[ i ]->Frozen() ); } ListView_SetItemState( hList, -1, LVIF_STATE, LVIS_SELECTED ); } return TRUE; } case IDC_RA_CLEAR_CHANGE: { if ( m_vBookmarks.size() > 0 ) { hList = GetDlgItem( hwnd, IDC_RA_LBX_ADDRESSES ); int idx = -1; for ( MemBookmark* bookmark : m_vBookmarks ) { idx++; bookmark->ResetCount(); } InvalidateRect( hList, NULL, FALSE ); } return TRUE; } case IDC_RA_DECIMALBOOKMARK: { if ( m_vBookmarks.size() > 0 ) { hList = GetDlgItem( hwnd, IDC_RA_LBX_ADDRESSES ); unsigned int uSelectedCount = ListView_GetSelectedCount( hList ); if ( uSelectedCount > 0 ) { for ( int i = ListView_GetNextItem( hList, -1, LVNI_SELECTED ); i >= 0; i = ListView_GetNextItem( hList, i, LVNI_SELECTED ) ) m_vBookmarks[ i ]->SetDecimal( !m_vBookmarks[ i ]->Decimal() ); } ListView_SetItemState( hList, -1, LVIF_STATE, LVIS_SELECTED ); } return TRUE; } case IDC_RA_SAVEBOOKMARK: { ExportJSON(); return TRUE; } case IDC_RA_LOADBOOKMARK: { std::string file = ImportDialog(); if (file.length() > 0 ) ImportFromFile( file ); return TRUE; } default: return FALSE; } } default: break; } return FALSE; }
void DrawStuff(LPDRAWITEMSTRUCT lpDrawItem) { PUSERKEYINFO pui; DRAWSTRUCT *ds; LISTSTRUCT *ls; int index; RECT rc; //HICON hIcon; HWND hDlg,hwndList; int max; BOOL focused; focused=TRUE; if(lpDrawItem->hwndItem!=0) { if(GetFocus()!=lpDrawItem->hwndItem) focused=FALSE; } hwndList=lpDrawItem->hwndItem; hDlg=GetParent(hwndList); ls=GetListStruct(hwndList); ds=GetDrawStruct(hDlg); pui=(PUSERKEYINFO)(lpDrawItem->itemData); CopyRect(&rc,&(lpDrawItem->rcItem)); #ifdef _WIN32 ImageList_Draw(ds->hIml,pui->icon, lpDrawItem->hDC, rc.left+((CX_SMICON-16)/2), rc.top+((CY_SMICON-16)/2), ILD_TRANSPARENT); #else hIcon=LoadIcon(gPGPsdkUILibInst,MAKEINTRESOURCE(pui->icon)); DrawIcon(lpDrawItem->hDC, rc.left+((CX_SMICON-32)/2), rc.top+((CY_SMICON-32)/2), hIcon); DeleteObject(hIcon); #endif rc.right=rc.left; rc.left=rc.left+16; max=0; for(index=0;index<NUMCOLUMNS;index++) { #if LISTBOX max=max+ls->colwidth[index]; #else max=max+ ListView_GetColumnWidth(lpDrawItem->hwndItem,index); #endif } for(index=0;index<NUMCOLUMNS;index++) { #if LISTBOX rc.right=rc.right+ls->colwidth[index]; #else rc.right=rc.right+ ListView_GetColumnWidth(lpDrawItem->hwndItem,index); #endif switch(index) { case 0: { HFONT oldFont; RECT origrc; // Save original rect CopyRect(&origrc,&rc); oldFont=SelectObject(lpDrawItem->hDC, ds->hFont); if(pui->pru->kind==kPGPRecipientUserKind_MissingRecipient) SelectObject(lpDrawItem->hDC, ds->hStrikeOut); // See if we need the lock icon if(pui->pru->lockRefCount!=0) { RECT temprc; CopyRect(&temprc,&rc); temprc.left=temprc.right-16; if(temprc.left>rc.left) { // Enough space. Draw Lock if((BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused) { FillRect (lpDrawItem->hDC, &temprc, ds->HighBrush); } else { FillRect (lpDrawItem->hDC, &temprc, ds->BackBrush); } ImageList_Draw(ds->hIml,IDX_CLOSEDLOCK, lpDrawItem->hDC, temprc.left+((CX_SMICON-16)/2), temprc.top+((CY_SMICON-16)/2), ILD_TRANSPARENT); // Make space for lock from text rc.right=rc.right-16; } } DrawItemColumn(lpDrawItem->hDC,pui->UserId, &rc); // Set rectangle back to original CopyRect(&rc,&origrc); SelectObject(lpDrawItem->hDC,oldFont); break; } case 1: { if(ds->DisplayMarginal) DrawBar(ds,lpDrawItem->hDC,&rc,pui->Validity, 2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused); else DrawNoviceButton(ds,lpDrawItem->hDC,&rc,pui->Validity, 2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused); break; } /* case 2: // we no longer display trust in rec dlg { DrawBar(ds,lpDrawItem->hDC,&rc,pui->Trust, 2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused); break; } */ case 2: { HFONT oldFont; oldFont=SelectObject(lpDrawItem->hDC, ds->hFont); DrawItemColumn(lpDrawItem->hDC,pui->szSize, &rc); SelectObject(lpDrawItem->hDC,oldFont); break; } } rc.left=rc.right; } lpDrawItem->rcItem.right=max; }
void PopupListviewColumnsMenu( HWND hListview, LISTVIEW_COLUMN * ColumnList ) { HMENU hMenu = CreatePopupMenu(); MENUITEMINFO item; ZeroMemory(&item,sizeof(item)); // Build list of columns for (int col = 0; ColumnList[col].Title; ++col ) { item.cbSize = sizeof item; item.fMask = MIIM_ID | MIIM_STATE | MIIM_CHECKMARKS | MIIM_TYPE; item.wID = col + 1; // zero is used for errors or no selection item.fType = MFT_STRING; item.fState = ListView_GetColumnWidth( hListview, col ) ? MFS_CHECKED : 0; item.hbmpChecked = NULL; item.hbmpUnchecked = NULL; item.hbmpItem = HBMMENU_SYSTEM; item.dwTypeData = (TCHAR *) ColumnList[col].Title; InsertMenuItem( hMenu, col, true, &item ); } // add separator item.fType = MFT_SEPARATOR; InsertMenuItem( hMenu, col++, true, &item ); // add "more..." entry item.fType = MFT_STRING; item.fState = 0; item.dwTypeData = TEXT("More..."); item.wID = col + 1; // zero is used for errors or no selection InsertMenuItem( hMenu, col++, true, &item ); // create menu POINT pt; GetCursorPos( &pt ); int i = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, pt.x, pt.y, 0, hListview, NULL ); if ( i > 0 ) { // process result --i; if ( i >= col - 1 ) { MessageBox( hListview, TEXT("More"), NULL, MB_OK ); } else { if ( ListView_GetColumnWidth(hListview,i) > 0 ) { // delete item ColumnList[i].Width = ListView_GetColumnWidth( hListview, i ); ListView_SetColumnWidth( hListview, i, 0 ); #if 0 HWND hHeader = ListView_GetHeader( hListview ); Header_DeleteItem( hHeader, i ); #endif } else { // insert item ListView_SetColumnWidth( hListview, i, ColumnList[i].Width ); #if 0 HWND hHeader = ListView_GetHeader( hListview ); HDITEM item = { 0 }; item.mask = HDI_TEXT | HDI_WIDTH; item.pszText = (TCHAR *) ColumnList[i].Title; item.cxy = ColumnList[i].Width; Header_InsertItem( hHeader, i, &item ); #endif } } } }
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); timerID = 0; { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); mir_subclassWindow(hwndList, PluginListWndProc); HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADEDGRAY); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADEDGRAY); ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T(""); col.cx = 40; ListView_InsertColumn(hwndList, 0, &col); col.pszText = TranslateT("Plugin"); col.cx = 180; ListView_InsertColumn(hwndList, 1, &col); col.pszText = TranslateT("Name"); col.cx = 180;//max = 220; ListView_InsertColumn(hwndList, 2, &col); col.pszText = TranslateT("Version"); col.cx = 75; ListView_InsertColumn(hwndList, 3, &col); ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT); // scan the plugin dir for plugins, cos arPluginList.destroy(); szFilter.Empty(); enumPlugins(dialogListPlugins, (WPARAM)hwndDlg, (LPARAM)hwndList); // sort out the headers ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE); // dll name int w = ListView_GetColumnWidth(hwndList, 1); if (w > 110) { ListView_SetColumnWidth(hwndList, 1, w = 110); } int max = w < 110 ? 189 + 110 - w : 189; ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE); // short name w = ListView_GetColumnWidth(hwndList, 2); if (w > max) ListView_SetColumnWidth(hwndList, 2, max); ListView_SortItems(hwndList, SortPlugins, (LPARAM)hwndDlg); } return TRUE; case WM_NOTIFY: if (lParam) { NMLISTVIEW *hdr = (NMLISTVIEW *)lParam; if (hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) { if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000)) { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM it; it.mask = LVIF_PARAM | LVIF_STATE; it.iItem = hdr->iItem; if (!ListView_GetItem(hwndList, &it)) break; PluginListItemData *dat = (PluginListItemData*)it.lParam; if (dat->flags & STATIC_PLUGIN) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } // find all another standard plugins by mask and disable them if ((hdr->uNewState == 0x2000) && dat->stdPlugin != 0) { for (int iRow = 0; iRow != -1; iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL)) { if (iRow != hdr->iItem) { // skip the plugin we're standing on LVITEM dt; dt.mask = LVIF_PARAM; dt.iItem = iRow; if (ListView_GetItem(hwndList, &dt)) { PluginListItemData *dat2 = (PluginListItemData*)dt.lParam; if (dat2->stdPlugin & dat->stdPlugin) {// mask differs // the lParam is unset, so when the check is unset the clist block doesnt trigger int iSave = dat2->stdPlugin; dat2->stdPlugin = 0; ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK); dat2->stdPlugin = iSave; } } } } } if (bOldMode) ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), TRUE); // this here only in "ghazan mode" SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if (hdr->iItem != -1) { int sel = hdr->uNewState & LVIS_SELECTED; HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = hdr->iItem; if (ListView_GetItem(hwndList, &lvi)) { PluginListItemData *dat = (PluginListItemData*)lvi.lParam; TCHAR buf[1024]; ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf)); SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T("")); ptrT tszAuthor(latin2t(sel ? dat->author : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINAUTHOR, tszAuthor); ptrT tszEmail(latin2t(sel ? dat->authorEmail : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINEMAIL, tszEmail); ptrT p(Langpack_PcharToTchar(dat->description)); SetDlgItemText(hwndDlg, IDC_PLUGINLONGINFO, sel ? p : _T("")); ptrT tszCopyright(latin2t(sel ? dat->copyright : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINCPYR, tszCopyright); ptrT tszUrl(latin2t(sel ? dat->homepage : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINURL, tszUrl); if (!equalUUID(miid_last, dat->uuid)) { char szUID[128]; uuidToString(dat->uuid, szUID, sizeof(szUID)); SetDlgItemTextA(hwndDlg, IDC_PLUGINPID, sel ? szUID : ""); } else SetDlgItemText(hwndDlg, IDC_PLUGINPID, sel ? TranslateT("<none>") : _T("")); } } } if (hdr->hdr.code == PSN_APPLY) { bool needRestart = false; TCHAR bufRestart[1024]; int bufLen = mir_sntprintf(bufRestart, _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); for (int iRow = 0; iRow != -1;) { TCHAR buf[1024]; ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf)); int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0); if (!bOldMode && iState != 0x3000) { LVITEM lvi = { 0 }; lvi.mask = LVIF_IMAGE | LVIF_PARAM; lvi.stateMask = -1; lvi.iItem = iRow; lvi.iSubItem = 0; if (ListView_GetItem(hwndList, &lvi)) { lvi.mask = LVIF_IMAGE; PluginListItemData *dat = (PluginListItemData*)lvi.lParam; if (iState == 0x2000) { // enabling plugin if (lvi.iImage == 3 || lvi.iImage == 5) { if (lvi.iImage == 3 && LoadPluginDynamically(dat)) { lvi.iImage = 2; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } else { // disabling plugin if (lvi.iImage == 2 || lvi.iImage == 4) { if (lvi.iImage == 2 && UnloadPluginDynamically(dat)) { lvi.iImage = 3; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } } } iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL); } LoadStdPlugins(); ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart); if (needRestart) { mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?")); if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES) CallService(MS_SYSTEM_RESTART, 1, 0); } } } break; case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { switch (LOWORD(wParam)) { case IDC_GETMOREPLUGINS: Utils_OpenUrl("http://miranda-ng.org/downloads/"); break; case IDC_PLUGINEMAIL: case IDC_PLUGINURL: char buf[512]; char *p = &buf[7]; mir_strcpy(buf, "mailto:"); if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7)) Utils_OpenUrl(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p); break; } } break; case WM_DESTROY: arPluginList.destroy(); RemoveAllItems(GetDlgItem(hwndDlg, IDC_PLUGLIST)); break; } return FALSE; }
INT_PTR TpresetsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: cfgSet(IDFF_lvWidth0,ListView_GetColumnWidth(hlv,0)); if (italicFont) { DeleteObject(italicFont); } italicFont=NULL; if (boldFont) { DeleteObject(boldFont); } boldFont=NULL; break; case WM_NOTIFY: { NMHDR *nmhdr=LPNMHDR(lParam); if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_PRESETS) switch (nmhdr->code) { case LVN_GETDISPINFO: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; int i=nmdi->item.iItem; if (i==-1) { break; } if (nmdi->item.mask&LVIF_TEXT) { strcpy(nmdi->item.pszText,(*parent->localPresets)[i]->presetName); } return TRUE; } case LVN_ITEMCHANGED: { if (nochange) { break; } NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam); if (nmlv->iItem==-1) { return TRUE; } char_t presetName[1024]; ListView_GetItemText(hlv,nmlv->iItem,0,presetName,1023); applying=true; parent->selectPreset(presetName); cfg2dlg(); applying=false; return TRUE; } case LVN_KEYDOWN: { NMLVKEYDOWN *nmkd=(NMLVKEYDOWN*)lParam; switch (nmkd->wVKey) { case VK_F2: ListView_EditLabel(hlv,ListView_GetNextItem(hlv,-1,LVNI_SELECTED)); return TRUE; case VK_SPACE: changePresetState(); return TRUE; } break; } case NM_DBLCLK: case NM_CLICK: { NMITEMACTIVATE *nmia=LPNMITEMACTIVATE(lParam); if (nmia->iItem==-1) { char_t activePresetName[MAX_PATH]; deciD->getActivePresetName(activePresetName, countof(activePresetName)); applying=true; parent->selectPreset(activePresetName); cfg2dlg(); applying=false; } else if (nmhdr->code==NM_DBLCLK) { changePresetState(); } return TRUE; } case LVN_ENDLABELEDIT: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; if (!nmdi->item.pszText) { return FALSE; } if (parent->localPresets->getPreset(nmdi->item.pszText,false)==NULL && Tpreset::isValidPresetName(nmdi->item.pszText)) { setDlgResult(TRUE); ffstring presetName; Tpreset::normalizePresetName(presetName,nmdi->item.pszText); renamePreset(presetName.c_str()); } else { setDlgResult(FALSE); } } case NM_CUSTOMDRAW: { NMLVCUSTOMDRAW *lvcd=LPNMLVCUSTOMDRAW(lParam); if (lvcd->nmcd.dwDrawStage==CDDS_PREPAINT) { setDlgResult(CDRF_NOTIFYITEMDRAW); return TRUE; } if (lvcd->nmcd.dwDrawStage==CDDS_ITEMPREPAINT) { if (!italicFont) { LOGFONT oldFont; HFONT hf=(HFONT)GetCurrentObject(lvcd->nmcd.hdc,OBJ_FONT); GetObject(hf,sizeof(LOGFONT),&oldFont); oldFont.lfItalic=TRUE; italicFont=CreateFontIndirect(&oldFont); oldFont.lfItalic=FALSE; oldFont.lfWeight=FW_BLACK; boldFont=CreateFontIndirect(&oldFont); } Tpreset *preset=(*parent->localPresets)[lvcd->nmcd.dwItemSpec]; if (preset->autoLoadedFromFile) { SelectObject(lvcd->nmcd.hdc,italicFont); } const char_t *defaultPreset=cfgGetStr(IDFF_defaultPreset); if (stricmp(defaultPreset,preset->presetName)==0) { SelectObject(lvcd->nmcd.hdc,boldFont); } setDlgResult(/*CDRF_NOTIFYPOSTPAINT*/CDRF_NEWFONT); return TRUE; } return TRUE; } } break; } } return TconfPageDec::msgProc(uMsg,wParam,lParam); }
/****************************************************************************** * * FUNCTION: SavePositionSettings * * PURPOSE: Saves the current window settings to the Registry. * ******************************************************************************/ VOID SavePositionSettings( HWND hWnd ) { RECT rc; int i; char *nextInString, *nextExString, *nextHiString; char recentExList[(MAXFILTERLEN+1) * NUMRECENTFILTERS + 1]; char recentInList[(MAXFILTERLEN+1) * NUMRECENTFILTERS + 1]; char recentHiList[(MAXFILTERLEN+1) * NUMRECENTFILTERS + 1]; HKEY hKey; // get the position of the main window PositionInfo.posversion = POSITION_VERSION; GetWindowRect( hWnd, &rc ); if( !IsIconic( hWnd ) && !IsZoomed( hWnd )) { PositionInfo.left = rc.left; PositionInfo.top = rc.top; PositionInfo.width = rc.right - rc.left; PositionInfo.height = rc.bottom - rc.top; } PositionInfo.maximized = IsZoomed( hWnd ); PositionInfo.ontop = OnTop; // get the widths of the listview columns for( i = 0; i < NUMCOLUMNS; i++ ) { PositionInfo.column[i] = ListView_GetColumnWidth( hWndList, i ); } // get the history depth PositionInfo.historydepth = MaxLines; // save time format PositionInfo.clocktime = ClockTime; PositionInfo.showms = ShowMs; // save font PositionInfo.font = LogFont; // get misc device filters PositionInfo.logsuccess = FilterDefinition.logsuccess; PositionInfo.logerror = FilterDefinition.logerror; PositionInfo.logreads = FilterDefinition.logreads; PositionInfo.logwrites = FilterDefinition.logwrites; PositionInfo.logaux = FilterDefinition.logaux; // save highlight colors PositionInfo.highlightfg = HighlightFg; PositionInfo.highlightbg = HighlightBg; // Save recent filters recentInList[0] = 0; nextInString = recentInList; for( i = 0; i < NUMRECENTFILTERS; i++ ) { if( !RecentInFilters[i][0] ) { break; } strcpy( nextInString, RecentInFilters[i] ); nextInString = &nextInString[ strlen( nextInString ) + 1]; } *nextInString = 0; recentExList[0] = 0; nextExString = recentExList; for( i = 0; i < NUMRECENTFILTERS; i++ ) { if( !RecentExFilters[i][0] ) { break; } strcpy( nextExString, RecentExFilters[i] ); nextExString = &nextExString[ strlen( nextExString ) + 1]; } *nextExString = 0; recentHiList[0] = 0; nextHiString = recentHiList; for( i = 0; i < NUMRECENTFILTERS; i++ ) { if( !RecentHiFilters[i][0] ) { break; } strcpy( nextHiString, RecentHiFilters[i] ); nextHiString = &nextHiString[ strlen( nextHiString ) + 1]; } *nextHiString = 0; // save connection info to registry RegOpenKey(HKEY_CURRENT_USER, REGMON_SETTINGS_KEY, &hKey ); RegSetValueEx( hKey, REGMON_SETTINGS_VALUE, 0, REG_BINARY, (LPBYTE) &PositionInfo, sizeof( PositionInfo ) ); RegSetValueEx( hKey, REGMON_RECENT_INFILTER_VALUE, 0, REG_BINARY, (LPBYTE) &recentInList, (DWORD) (nextInString - recentInList) + 1 ); RegSetValueEx( hKey, REGMON_RECENT_EXFILTER_VALUE, 0, REG_BINARY, (LPBYTE) &recentExList, (DWORD) (nextExString - recentExList) + 1 ); RegSetValueEx( hKey, REGMON_RECENT_HIFILTER_VALUE, 0, REG_BINARY, (LPBYTE) &recentHiList, (DWORD) (nextHiString - recentHiList) + 1 ); CloseHandle( hKey ); }
INT_PTR TconvolverPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: cfgSet(IDFF_lvConvolverWidth0,ListView_GetColumnWidth(hlv,0)); cfgSet(IDFF_lvConvolverWidth1,ListView_GetColumnWidth(hlv,1)); cfgSet(IDFF_lvConvolverWidth2,ListView_GetColumnWidth(hlv,2)); cfgSet(IDFF_lvConvolverSelected,lvGetSelItem(IDC_LV_CONVOLVER_FILES)); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_CONVOLVER_FILE: if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) { char_t flnm[MAX_PATH]; GetDlgItemText(m_hwnd,IDC_ED_CONVOLVER_FILE,flnm,MAX_PATH); cfgSet(IDFF_convolverFile,flnm); format2dlg(flnm); } return TRUE; } break; case WM_NOTIFY: { NMHDR *nmhdr=LPNMHDR(lParam); if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_CONVOLVER_FILES) switch (nmhdr->code) { case LVN_ITEMCHANGED: { NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam); enableMapping(nmlv->iItem!=-1); return TRUE; } case NM_DBLCLK: { NMITEMACTIVATE *nmia=(NMITEMACTIVATE*)lParam; if (nmia->iItem==-1 || nmia->iSubItem!=1) { return FALSE; } onManualFileSet(); return TRUE; } case LVN_GETDISPINFO: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; int i=nmdi->item.iItem; if (i==-1) { break; } if (nmdi->item.mask&LVIF_TEXT) switch (nmdi->item.iSubItem) { case 0: { static const int speakers[]= {SPEAKER_FRONT_LEFT,SPEAKER_FRONT_RIGHT,SPEAKER_FRONT_CENTER,SPEAKER_LOW_FREQUENCY,SPEAKER_BACK_LEFT,SPEAKER_BACK_RIGHT}; strcpy(nmdi->item.pszText,_(IDC_LV_CONVOLVER_FILES,TsampleFormat::getSpeakerName(speakers[i]))); break; } case 1: { int dx=ListView_GetColumnWidth(hlv,1); char_t flnm[MAX_PATH]; cfgGet(speakersIdffs[i],flnm,MAX_PATH); HDC dc=GetDC(hlv); HGDIOBJ old=SelectObject(dc,(HGDIOBJ)SendMessage(hlv,WM_GETFONT,0,0)); PathCompactPath(dc,flnm,std::max(20,dx-15)); SelectObject(dc,old); ReleaseDC(hlv,dc); strcpy(nmdi->item.pszText,flnm); break; } case 2: if (const char_t *flnm=cfgGetStr(speakersIdffs[i])) if (flnm[0] && !speakerFormats[i]) { speakerFormats[i]=getWavDesc(flnm,IDC_LV_CONVOLVER_FILES); } strcpy(nmdi->item.pszText,speakerFormats[i].c_str()); break; } return TRUE; } } break; } } return TconfPageDecAudio::msgProc(uMsg,wParam,lParam); }
BOOL Picker_SaveColumnWidths(HWND hwndPicker) { struct PickerInfo *pPickerInfo; int *widths; int *order; int *tmpOrder; int nColumnMax = 0, i = 0; BOOL bSuccess = FALSE; BOOL res = 0; pPickerInfo = GetPickerInfo(hwndPicker); /* allocate space for the column info */ widths = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*widths)); order = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*order)); tmpOrder = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*tmpOrder)); if (!widths || !order || !tmpOrder) goto done; /* retrieve the values */ memset(widths, 0, pPickerInfo->nColumnCount * sizeof(*widths)); memset(order, 0, pPickerInfo->nColumnCount * sizeof(*order)); pPickerInfo->pCallbacks->pfnGetColumnWidths(widths); pPickerInfo->pCallbacks->pfnGetColumnOrder(order); /* switch the list view to LVS_REPORT style so column widths reported correctly */ SetWindowLong(hwndPicker, GWL_STYLE, (GetWindowLong(hwndPicker, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT); nColumnMax = Picker_GetNumColumns(hwndPicker); if (GetUseOldControl()) { for (i = 0; i < nColumnMax; i++) { widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = ListView_GetColumnWidth(hwndPicker, i); } } else { /* Get the Column Order and save it */ res = ListView_GetColumnOrderArray(hwndPicker, nColumnMax, tmpOrder); for (i = 0; i < nColumnMax; i++) { widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = ListView_GetColumnWidth(hwndPicker, i); order[i] = Picker_GetRealColumnFromViewColumn(hwndPicker, tmpOrder[i]); } } pPickerInfo->pCallbacks->pfnSetColumnWidths(widths); pPickerInfo->pCallbacks->pfnSetColumnOrder(order); bSuccess = TRUE; done: if (widths) free(widths); if (order) free(order); if (tmpOrder) free(tmpOrder); res++; return bSuccess; }
static int GetColWidth(openfile* p, int Index) { if (p->Win.Smartphone) return p->DlgWidth[Index]; // no GUI update possible return WinPixelToUnitX(&p->Win,ListView_GetColumnWidth(p->WndList,Index)); }
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { HWND hwndList=GetDlgItem(hwndDlg,IDC_PLUGLIST); LVCOLUMN col; HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 4, 0); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_UNICODE ); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_ANSI ); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_LOADED ); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_NOTLOADED ); ListView_SetImageList( hwndList, hIml, LVSIL_SMALL ); TranslateDialogDefault(hwndDlg); col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = TranslateT("Plugin"); col.cx = 70;//max = 140; ListView_InsertColumn(hwndList,0,&col); col.pszText=TranslateT("Name"); col.cx = 70;//max = 220; ListView_InsertColumn(hwndList,1,&col); col.pszText=TranslateT("Version"); col.cx=55; ListView_InsertColumn(hwndList,2,&col); col.pszText=_T(""); col.cx=20; ListView_InsertColumn(hwndList,3,&col); //ListView_InsertColumn(hwndList,4,&col); // XXX: Won't work on windows 95 without IE3+ or 4.70 ListView_SetExtendedListViewStyleEx( hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT ); // scan the plugin dir for plugins, cos enumPlugins( dialogListPlugins, ( WPARAM )hwndDlg, ( LPARAM )hwndList ); // sort out the headers { int w, max; ListView_SetColumnWidth( hwndList, 0, LVSCW_AUTOSIZE ); // dll name w = ListView_GetColumnWidth( hwndList, 0 ); if (w>140) { ListView_SetColumnWidth( hwndList, 0, 140 ); w = 140; } max = w<140? 220+140-w:220; ListView_SetColumnWidth( hwndList, 1, LVSCW_AUTOSIZE ); // short name w = ListView_GetColumnWidth( hwndList, 1 ); if (w>max) ListView_SetColumnWidth( hwndList, 1, max ); } return TRUE; } case WM_NOTIFY: { NMLISTVIEW * hdr = (NMLISTVIEW *) lParam; if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000 ) && IsWindowVisible(hdr->hdr.hwndFrom) ) { HWND hwndList = GetDlgItem(hwndDlg,IDC_PLUGLIST); PluginListItemData* dat; int iRow; LVITEM it; it.mask=LVIF_PARAM | LVIF_STATE; it.iItem = hdr->iItem; if ( !ListView_GetItem( hwndList, &it )) break; dat = ( PluginListItemData* )it.lParam; if ( dat->flags == DEFMOD_DB ) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } // if enabling and replaces, find all other replaces and toggle off if ( hdr->uNewState & 0x2000 && dat->flags != 0 ) { for ( iRow=0; iRow != -1; ) { if ( iRow != hdr->iItem ) { LVITEM dt; dt.mask = LVIF_PARAM; dt.iItem = iRow; if ( ListView_GetItem( hwndList, &dt )) { PluginListItemData* dat2 = ( PluginListItemData* )dt.lParam; if ( dat2->flags == dat->flags ) { // the lParam is unset, so when the check is unset the clist block doesnt trigger int lParam = dat2->flags; dat2->flags = 0; ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK ); dat2->flags = lParam; } } } iRow = ListView_GetNextItem( hwndList, iRow, LVNI_ALL ); } } ShowWindow( GetDlgItem(hwndDlg, IDC_RESTART ), TRUE ); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); break; } if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != -1 ) { TCHAR buf[1024]; int sel = hdr->uNewState & LVIS_SELECTED; HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = hdr->iItem; if ( ListView_GetItem( hwndList, &lvi )) { PluginListItemData* dat = ( PluginListItemData* )lvi.lParam; ListView_GetItemText(hwndList, hdr->iItem, 1, buf, SIZEOF(buf)); SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGININFOFRAME),sel ? buf : _T("")); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINAUTHOR), sel ? dat->author : "" ); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINEMAIL), sel ? dat->authorEmail : "" ); { TCHAR* p = LangPackPcharToTchar( dat->description ); SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGINLONGINFO), sel ? p : _T("")); mir_free( p ); } SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINCPYR), sel ? dat->copyright : "" ); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINURL), sel ? dat->homepage : "" ); if(equalUUID(miid_last, dat->uuid)) SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGINPID), sel ? TranslateT("<none>") : _T("")); else { char szUID[128]; uuidToString( dat->uuid, szUID, sizeof(szUID)); SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINPID), sel ? szUID : "" ); } } } if ( hdr && hdr->hdr.code == PSN_APPLY ) { HWND hwndList=GetDlgItem(hwndDlg,IDC_PLUGLIST); int iRow; int iState; TCHAR buf[1024]; for (iRow=0 ; iRow != (-1) ; ) { ListView_GetItemText(hwndList, iRow, 0, buf, SIZEOF(buf)); iState=ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, iState&0x2000 ? 1 : 0); iRow=ListView_GetNextItem(hwndList, iRow, LVNI_ALL); } } break; } case WM_COMMAND: if ( HIWORD(wParam) == STN_CLICKED ) { switch (LOWORD(wParam)) { case IDC_PLUGINEMAIL: case IDC_PLUGINURL: { char buf[512]; char * p = &buf[7]; lstrcpyA(buf,"mailto:"); if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7) ) { CallService(MS_UTILS_OPENURL,0,(LPARAM) (LOWORD(wParam)==IDC_PLUGINEMAIL ? buf : p) ); } break; } case IDC_GETMOREPLUGINS: { CallService(MS_UTILS_OPENURL,0,(LPARAM) "http://addons.miranda-im.org/index.php?action=display&id=1" ); break; } } } break; case WM_DESTROY: RemoveAllItems( GetDlgItem( hwndDlg, IDC_PLUGLIST )); break; } return FALSE; }
INT_PTR CALLBACK _main_dialog_proc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) { WORD id = LOWORD(wparam); WORD code = HIWORD(wparam); _wnd_data *wnd; _dnode *sel; _dmnt *mnt; int k = 0; switch ( message ) { case WM_INITDIALOG : { memset( __lists, HWND_NULL, sizeof(__lists) ); __lists[HMAIN_DRIVES] = GetDlgItem( hwnd, IDC_DISKDRIVES ); __dlg = hwnd; _init_main_dlg( hwnd ); _load_diskdrives( hwnd, &__drives, _list_volumes(0) ); { TCITEM tab_item = { TCIF_TEXT }; HWND h_tab = GetDlgItem(hwnd, IDT_INFO); _tab_data *d_tab = malloc(sizeof(_tab_data)); zeroauto( d_tab, sizeof(_tab_data) ); d_tab->curr_tab = 1; wnd_set_long( hwnd, GWL_USERDATA, d_tab ); wnd = _sub_class( h_tab, SUB_NONE, CreateDialog( __hinst, MAKEINTRESOURCE(DLG_MAIN_INFO), GetDlgItem(hwnd, IDC_MAIN_TAB), _tab_proc ), CreateDialog( __hinst, MAKEINTRESOURCE(DLG_MAIN_ACTION), GetDlgItem(hwnd, IDC_MAIN_TAB), _tab_proc ), HWND_NULL ); { __lists[HMAIN_INFO] = GetDlgItem( wnd->dlg[0], IDC_INF_TABLE ); __lists[HMAIN_ACT] = GetDlgItem( wnd->dlg[1], IDC_ACT_TABLE ); } { __dlg_act_info = wnd->dlg[1]; _list_insert_col( __lists[HMAIN_INFO], 380 ); _list_insert_col( __lists[HMAIN_INFO], 90 ); while ( _list_insert_item( __lists[HMAIN_INFO], k, 0, _info_table_items[k], 0 ) ) k++; _set_header_text( __lists[HMAIN_INFO], 0, STR_HEAD_NO_ICONS, sizeof_w(STR_HEAD_NO_ICONS) ); _list_insert_col( __lists[HMAIN_ACT], 90 ); _list_insert_col( __lists[HMAIN_ACT], 70 ); _list_insert_col( __lists[HMAIN_ACT], 85 ); _list_insert_col( __lists[HMAIN_ACT], 50 ); _list_insert_item( __lists[HMAIN_ACT], 0, 0, _act_table_items[0], 0 ); ListView_SetItemText( __lists[HMAIN_ACT], 0, 2, _act_table_items[3] ); _list_insert_item( __lists[HMAIN_ACT], 1, 0, _act_table_items[1], 0 ); ListView_SetItemText( __lists[HMAIN_ACT], 1, 2, _act_table_items[4] ); _init_combo( GetDlgItem( __dlg_act_info, IDC_COMBO_PASSES), wipe_modes, WP_NONE, FALSE, -1 ); SendMessage( GetDlgItem( __dlg_act_info, IDC_PROGRESS ), PBM_SETBARCOLOR, 0, _cl( COLOR_BTNSHADOW, DARK_CLR - 20 ) ); SendMessage( GetDlgItem( __dlg_act_info, IDC_PROGRESS ), PBM_SETRANGE, 0, MAKELPARAM(0, PRG_STEP) ); } tab_item.pszText = L"Info"; TabCtrl_InsertItem( h_tab, 0, &tab_item ); { NMHDR mhdr = { 0, 0, TCN_SELCHANGE }; TabCtrl_SetCurSel( h_tab, 0 ); SendMessage(hwnd, WM_NOTIFY, IDT_INFO, (LPARAM)&mhdr); } } SendMessage( hwnd, WM_SYSCOLORCHANGE, 0, 0 ); _set_timer( MAIN_TIMER, TRUE, TRUE ); _set_timer( RAND_TIMER, TRUE, FALSE ); _set_timer( POST_TIMER, TRUE, FALSE ); return 0L; } break; case WM_WINDOWPOSCHANGED : { WINDOWPOS *pos = (WINDOWPOS *)lparam; int flags = pos->flags; _dlg_right = pos->cx + pos->x; _dlg_bottom = pos->cy + pos->y; _dlg_left = pos->x; if ( ( flags & SWP_SHOWWINDOW ) || ( flags & SWP_HIDEWINDOW ) ) { _set_timer( MAIN_TIMER, flags & SWP_SHOWWINDOW, TRUE ); } return 0L; } break; case WM_ENTERSIZEMOVE : { //_middle_ctl( // GetDlgItem(hwnd, IDC_DISKDRIVES), // GetDlgItem(hwnd, IDC_RESIZING), // TRUE // ); //ShowWindow(GetDlgItem(hwnd, IDC_DISKDRIVES), SW_HIDE); return 0L; } break; case WM_EXITSIZEMOVE : { //ShowWindow(GetDlgItem(hwnd, IDC_DISKDRIVES), SW_SHOW); return 0L; } break; case WM_SIZING : { RECT *rect = ((RECT *)lparam); rect->right = _dlg_right; rect->left = _dlg_left; if ( rect->bottom - rect->top < MAIN_DLG_MIN_HEIGHT ) { rect->bottom = rect->top + MAIN_DLG_MIN_HEIGHT; } return 1L; } break; case WM_SIZE : { int height = HIWORD(lparam); int width = LOWORD(lparam); int k; _size_move_ctls _resize[ ] = { { -1, IDC_DISKDRIVES, FALSE, 0, 0 }, { -1, IDC_STATIC_LIST, TRUE, 0, 0 }, { -1, IDC_STATIC_RIGHT, TRUE, 0, 0 } }; _size_move_ctls _move[ ] = { { IDC_STATIC_LIST, IDC_MAIN_TAB, TRUE, 0, 6 }, { IDC_STATIC_LIST, IDT_INFO, FALSE, 0, 3 }, { IDT_INFO, IDC_LINE_BOTTOM, TRUE, 0, 2 } }; { int c_size_hide = _main_headers[1].width; int c_size_show = c_size_hide - GetSystemMetrics(SM_CXVSCROLL); int c_size_curr = ListView_GetColumnWidth( __lists[HMAIN_DRIVES], 1 ); if ( GetWindowLong(__lists[HMAIN_DRIVES], GWL_STYLE) & WS_VSCROLL ) { if ( c_size_curr != c_size_show ) ListView_SetColumnWidth( __lists[HMAIN_DRIVES], 1, c_size_show ); } else { if ( c_size_curr != c_size_hide ) ListView_SetColumnWidth( __lists[HMAIN_DRIVES], 1, c_size_hide ); } } if ( height == 0 || width == 0 ) { return 0L; } for ( k = 0; k < array_num(_resize); k++ ) { _resize_ctl( GetDlgItem(hwnd, _resize[k].id), height - _dlg_height, 0, _resize[k].val ); } _dlg_height = height; for ( k = 0; k < array_num(_move); k++ ) { _relative_move( GetDlgItem( hwnd, _move[k].anchor ), GetDlgItem( hwnd, _move[k].id ), _move[k].dy, _move[k].dy, _move[k].val ); InvalidateRect( GetDlgItem( hwnd, _move[k].id ), NULL, TRUE ); } _middle_ctl( GetDlgItem( hwnd, IDC_DISKDRIVES ), GetDlgItem( hwnd, IDC_RESIZING ), TRUE ); return 0L; } break; case WM_SYSCOMMAND : { if ( wparam == SC_MINIMIZE || wparam == SC_RESTORE ) { _set_timer( MAIN_TIMER, wparam == SC_RESTORE, TRUE ); } return 0L; } break; case WM_APP + WM_APP_SHOW : { ShowWindow( hwnd, SW_HIDE ); } break; case WM_NOTIFY : { if ( wparam == IDT_INFO ) { if ( ((NMHDR *)lparam)->code == TCN_SELCHANGE ) { HWND h_tab = GetDlgItem( hwnd, IDT_INFO ); if ( !_is_curr_in_group(h_tab) ) { _change_page( h_tab, TabCtrl_GetCurSel(h_tab) ); } } } if ( wparam == IDC_DISKDRIVES ) { sel = pv( _get_sel_item( __lists[HMAIN_DRIVES] ) ); mnt = &sel->mnt; if ( ((NMHDR *)lparam)->code == LVN_ITEMCHANGED && (((NMLISTVIEW *)lparam)->uNewState & LVIS_FOCUSED ) ) { _update_info_table( FALSE ); _activate_page( ); _refresh_menu( ); return 1L; } if ( ((NMHDR *)lparam)->code == LVN_ITEMACTIVATE ) { BOOL mount = ( !(sel->mnt.info.status.flags & F_ENABLED) ) && ( sel->mnt.fs[0] == '\0' ); if (! mount ) { if (! sel->is_root ) __execute( mnt->info.status.mnt_point ); } else { _menu_mount( sel ); } } switch( ((NM_LISTVIEW *)lparam)->hdr.code ) { case LVN_KEYDOWN : { WORD key = ((NMLVKEYDOWN *)lparam)->wVKey; int item = ListView_GetSelectionMark( __lists[HMAIN_DRIVES] ); switch ( key ) { case VK_UP: item -= 1; break; case VK_DOWN: item += 1; break; } if ( _is_root_item(_get_item_index( __lists[HMAIN_DRIVES], item )) ) { ListView_SetItemState( __lists[HMAIN_DRIVES], item, LVIS_FOCUSED, TRUE ); } if ( key != VK_APPS ) { break; } } case NM_RCLICK : { int item; HMENU h_popup = CreatePopupMenu( ); _dact *act = _create_act_thread( sel, -1, -1 ); _update_info_table( FALSE ); _activate_page( ); _set_timer(MAIN_TIMER, FALSE, FALSE); _refresh_menu( ); if ( ListView_GetSelectedCount( __lists[HMAIN_DRIVES] ) && !_is_root_item((LPARAM)sel) && _is_active_item((LPARAM)sel) ) { if ( mnt->info.status.flags & F_ENABLED ) { if ( mnt->info.status.flags & F_CDROM ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_UNMOUNT, IDS_UNMOUNT ); } else { if ( mnt->info.status.flags & F_FORMATTING ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_FORMAT, IDS_FORMAT ); } else { if ( IS_UNMOUNTABLE(&mnt->info.status) ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_UNMOUNT, IDS_UNMOUNT ); } if ( !(mnt->info.status.flags & F_SYNC) ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); AppendMenu( h_popup, MF_STRING, ID_VOLUMES_CHANGEPASS, IDS_CHPASS ); } if ( !(act && act->status == ACT_RUNNING) ) { if ( mnt->info.status.flags & F_SYNC ) { if ( GetMenuItemCount(h_popup) > 0 ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); } AppendMenu( h_popup, MF_STRING, ID_VOLUMES_ENCRYPT, IDS_ENCRYPT ); } else { if ( GetMenuItemCount(h_popup) > 0 ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); } AppendMenu( h_popup, MF_STRING, ID_VOLUMES_REENCRYPT, IDS_REENCRYPT ); } AppendMenu( h_popup, MF_STRING, ID_VOLUMES_DECRYPT, IDS_DECRYPT ); } } } } else { if ( mnt->info.status.flags & F_CDROM ) { if ( *mnt->fs == '\0' ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_MOUNT, IDS_MOUNT ); } } else { if ( *mnt->fs == '\0' ) { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_MOUNT, IDS_MOUNT ); } else { AppendMenu( h_popup, MF_STRING, ID_VOLUMES_ENCRYPT, IDS_ENCRYPT ); } if ( IS_UNMOUNTABLE(&mnt->info.status) ) { AppendMenu( h_popup, MF_SEPARATOR, 0, NULL ); AppendMenu( h_popup, MF_STRING, ID_VOLUMES_FORMAT, IDS_FORMAT ); } } } } /* _state_menu( popup, sel && sel->status.flags & F_LOCKED ? MF_GRAYED : MF_ENABLED ); */ item = TrackPopupMenu( h_popup, TPM_RETURNCMD | TPM_LEFTBUTTON, LOWORD(GetMessagePos( )), HIWORD(GetMessagePos( )), 0, hwnd, NULL ); DestroyMenu( h_popup ); switch ( item ) { case ID_VOLUMES_DECRYPT : _menu_decrypt(sel); break; case ID_VOLUMES_ENCRYPT : _menu_encrypt(sel); break; case ID_VOLUMES_FORMAT : _menu_format(sel); break; case ID_VOLUMES_REENCRYPT : _menu_reencrypt(sel); break; case ID_VOLUMES_UNMOUNT : _menu_unmount(sel); break; case ID_VOLUMES_MOUNT : _menu_mount(sel); break; case ID_VOLUMES_CHANGEPASS : _menu_change_pass(sel); break; } if ( item ) { _refresh( TRUE ); } _set_timer( MAIN_TIMER, TRUE, TRUE ); } break; case NM_CLICK : { sel = pv( _get_item_index( __lists[HMAIN_DRIVES], ((NM_LISTVIEW *)lparam)->iItem ) ); _update_info_table( FALSE ); _activate_page( ); _refresh_menu( ); } break; } } if ( ((NMHDR *)lparam)->code == HDN_ITEMCHANGED ) { InvalidateRect( __lists[HMAIN_DRIVES], NULL, TRUE ); } if ( ((NMHDR *)lparam)->code == HDN_ITEMCHANGING ) { return 0L; } if ( ((NMHDR *)lparam)->code == HDN_BEGINTRACK ) { return 1L; } } break; case WM_COMMAND: { _dnode *node = pv( _get_sel_item( __lists[HMAIN_DRIVES] ) ); switch (id) { case ID_SHIFT_TAB : case ID_TAB : { HWND h_current = GetFocus( ); HWND h_next = GetNextDlgTabItem( hwnd, h_current, id == ID_SHIFT_TAB ); SetFocus( h_next ); } break; case ID_TOOLS_DRIVER : { if ( __msg_q( __dlg, L"Remove DiskCryptor driver?") ) { int rlt; if ( (rlt = _drv_action(DA_REMOVE, 0)) != ST_OK ) { __error_s( __dlg, L"Error remove DiskCryptor driver", rlt ); } else { return 0L; } } } break; case ID_TOOLS_BENCHMARK : _dlg_benchmark( __dlg ); break; case ID_HELP_ABOUT : _dlg_about( __dlg ); break; case ID_HOMEPAGE : __execute( DC_HOMEPAGE ); break; case ID_EXIT : { SendMessage( hwnd, WM_CLOSE, 0, 1 ); } break; case IDC_BTN_WIZARD : _menu_wizard(node); break; case ID_VOLUMES_DELETE_MNTPOINT : { wchar_t *mnt_point = node->mnt.info.status.mnt_point; if ( __msg_q( __dlg, L"Are you sure you want to delete mount point [%s]?", mnt_point ) ) { _set_trailing_slash(mnt_point); DeleteVolumeMountPoint(mnt_point); } } break; case IDC_BTN_DECRYPT_ : case ID_VOLUMES_DECRYPT : _menu_decrypt( node ); break; case IDC_BTN_ENCRYPT_ : case ID_VOLUMES_ENCRYPT : _menu_encrypt( node ); break; case ID_VOLUMES_MOUNTALL : case IDC_BTN_MOUNTALL_ : _menu_mountall( ); break; case ID_VOLUMES_DISMOUNTALL : case IDC_BTN_UNMOUNTALL_ : _menu_unmountall( ); break; case ID_VOLUMES_DISMOUNT : _menu_unmount( node ); break; case ID_VOLUMES_MOUNT : _menu_mount( node ); break; case ID_VOLUMES_FORMAT : _menu_format(node); break; case ID_VOLUMES_REENCRYPT : _menu_reencrypt( node ); break; case ID_TOOLS_SETTINGS : _dlg_options( __dlg ); break; case ID_BOOT_OPTIONS : _dlg_config_loader( __dlg, FALSE ); break; case ID_VOLUMES_CHANGEPASS : _menu_change_pass( node ); break; case ID_TOOLS_CLEARCACHE : _menu_clear_cache( ); break; case ID_VOLUMES_BACKUPHEADER : _menu_backup_header( node ); break; case ID_VOLUMES_RESTOREHEADER : _menu_restore_header( node ); break; case ID_TOOLS_ENCRYPT_CD: _menu_encrypt_cd( ); break; } switch ( id ) { case IDC_BTN_MOUNT_: { node->mnt.info.status.flags & F_ENABLED ? _menu_unmount(node) : _menu_mount(node); } break; case ID_TOOLS_BSOD : { if ( __msg_q( __dlg, L"Crash?" ) ) { dc_get_bsod( ); } } break; } if ( id == IDCANCEL ) { ShowWindow(hwnd, SW_HIDE); } _refresh(TRUE); } break; case WM_CLOSE : { if ( lparam ) { _tray_icon(FALSE); EndDialog(hwnd, 0); ExitProcess(0); } else { ShowWindow(hwnd, SW_HIDE); } return 0L; } break; case WM_DESTROY : { PostQuitMessage(0); return 0L; } break; case WM_HOTKEY : { switch (wparam) { case 0 : { int mount_cnt; dc_mount_all(NULL, &mount_cnt, 0); } break; case 1 : dc_unmount_all( ); break; case 2 : dc_clean_pass_cache( ); break; case 3 : dc_get_bsod( ); break; } return 1L; } break; case WM_ENDSESSION : { if ( lparam & ENDSESSION_LOGOFF ) { if ( __config.conf_flags & CONF_DISMOUNT_LOGOFF ) { dc_unmount_all( ); } if ( __config.conf_flags & CONF_WIPEPAS_LOGOFF ) { dc_clean_pass_cache( ); } } } break; case WM_SYSCOLORCHANGE : { COLORREF cl_light = _cl( COLOR_BTNFACE, LGHT_CLR ); COLORREF cl_button = GetSysColor( COLOR_BTNFACE ); int k; for ( k = 0; k < array_num(__lists); k++ ) { if ( ( __lists[k] != HWND_NULL ) && ( __lists[k] != NULL ) ) { ListView_SetBkColor( __lists[k], cl_button ); ListView_SetTextBkColor( __lists[k], cl_button ); ListView_SetExtendedListViewStyle( __lists[k], LVS_EX_FULLROWSELECT ); if ( !IsWindowEnabled( __lists[k] ) ) { // EnableWindow( __lists[k], TRUE ); // EnableWindow( __lists[k], FALSE ); } } } TreeView_SetBkColor( GetDlgItem(hwnd, IDC_TREE), cl_light ); ListView_SetBkColor( __lists[HMAIN_DRIVES], cl_light ); ListView_SetTextBkColor( __lists[HMAIN_DRIVES], cl_light ); ListView_SetExtendedListViewStyle( __lists[HMAIN_DRIVES], LVS_EX_FULLROWSELECT ); ListView_SetImageList( __lists[HMAIN_DRIVES], __dsk_img, LVSIL_SMALL ); } break; case WM_APP + WM_APP_TRAY : { switch ( lparam ) { case WM_LBUTTONDOWN : { BOOL show = !IsWindowVisible(hwnd); ShowWindow(hwnd, show ? SW_SHOW : SW_HIDE); if ( show ) { SetForegroundWindow(hwnd); } } break; case WM_RBUTTONDOWN : { POINT pt; int item; HMENU menu = CreatePopupMenu( ); AppendMenu( menu, MF_STRING, ID_VOLUMES_UNMOUNTALL, IDS_UNMOUNTALL ); AppendMenu( menu, MF_STRING, ID_VOLUMES_MOUNTALL, IDS_MOUNTALL ); AppendMenu( menu, MF_SEPARATOR, 0, NULL ); AppendMenu( menu, MF_STRING, ID_TOOLS_SETTINGS, IDS_SETTINGS ); AppendMenu( menu, MF_STRING, ID_HELP_ABOUT, IDS_ABOUT ); AppendMenu( menu, MF_SEPARATOR, 0, NULL ); AppendMenu( menu, MF_STRING, ID_EXIT, IDS_EXIT ); GetCursorPos(&pt); SetForegroundWindow( hwnd ); item = TrackPopupMenu ( menu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL ); DestroyMenu( menu ); switch (item) { case ID_VOLUMES_UNMOUNTALL : _menu_unmountall( ); break; case ID_VOLUMES_MOUNTALL : _menu_mountall( ); break; case ID_HELP_ABOUT : _dlg_about( HWND_DESKTOP ); break; case ID_TOOLS_SETTINGS : _dlg_options( __dlg ); break; case ID_EXIT : { SendMessage(hwnd, WM_CLOSE, 0, 1); } break; } } break; } } break; default: { int rlt = _draw_proc( message, lparam ); if (rlt != -1) { return rlt; } } } return 0L; }
int W_ListView::GetColumnWidth(int col) { if (col < 0 || col >= m_col) return 0; return ListView_GetColumnWidth(m_hwnd,col); }
void MainWnd_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpDrawItem) { if (lpDrawItem->CtlType != ODT_LISTVIEW) return; HDC hDC = lpDrawItem->hDC; SetBkMode(hDC, TRANSPARENT); INT iColumn = 0, x, cx; RECT rcItem, rcSubItem, rcText; STRING Str; x = -GetScrollPos(g_hListView, SB_HORZ); rcItem = lpDrawItem->rcItem; if (lpDrawItem->itemState & ODS_SELECTED) { FillRect(hDC, &rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1)); SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); } else { FillRect(hDC, &rcItem, (HBRUSH)(COLOR_WINDOW + 1)); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); } cx = ListView_GetColumnWidth(g_hListView, iColumn); rcSubItem = rcItem; rcSubItem.left = x; rcSubItem.right = x + cx; WCHAR sz[MAX_STRING]; rcText = rcSubItem; InflateRect(&rcText, -1, -1); Str = g_Items[lpDrawItem->itemID].m_Name; BYTE CharSet1 = g_Items[lpDrawItem->itemID].m_CharSet1; if (CharSet1 != DEFAULT_CHARSET) wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet1); else wsprintfW(sz, L"%s", Str.c_str()); DrawTextW(hDC, sz, lstrlenW(sz), &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); x += cx; ++iColumn; cx = ListView_GetColumnWidth(g_hListView, iColumn); rcSubItem = rcItem; rcSubItem.left = x; rcSubItem.right = x + cx; rcText = rcSubItem; InflateRect(&rcText, -1, -1); Str = g_Items[lpDrawItem->itemID].m_Substitute; BYTE CharSet2 = g_Items[lpDrawItem->itemID].m_CharSet2; if (CharSet2 != DEFAULT_CHARSET) wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet2); else wsprintfW(sz, L"%s", Str.c_str()); DrawTextW(hDC, sz, lstrlenW(sz), &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); }
INT_PTR TcodecsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: cfgSet(IDFF_lvCodecsWidth0,ListView_GetColumnWidth(hlv,0)); cfgSet(IDFF_lvCodecsWidth1,ListView_GetColumnWidth(hlv,1)); cfgSet(IDFF_lvCodecsWidth2,ListView_GetColumnWidth(hlv,2)); cfgSet(IDFF_lvCodecsSelected,lvGetSelItem(IDC_LV_INCODECS)); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CBX_INCODECS: if (HIWORD(wParam)==CBN_SELCHANGE && IsWindowVisible(hcbx)) { int ii=lvGetSelItem(IDC_LV_INCODECS); int idff=formats[ii].idff; cfgSet(idff,(int)cbxGetCurItemData(IDC_CBX_INCODECS)); options2dlg(ii); return TRUE; } break; case IDC_CHB_CODEC_OPT1: case IDC_CHB_CODEC_OPT2: case IDC_CHB_CODEC_OPT3: case IDC_CHB_CODEC_OPT4: dlg2options(LOWORD(wParam)); return TRUE; } break; case WM_NOTIFY: { NMHDR *nmhdr=LPNMHDR(lParam); if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_INCODECS) switch (nmhdr->code) { case LVN_GETDISPINFO: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; int i=nmdi->item.iItem; if (i==-1) { break; } if (nmdi->item.mask&LVIF_TEXT) switch (nmdi->item.iSubItem) { case 0: strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].descr)); break; case 1: strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].getDecoderName(cfgGet(formats[i].idff)))); break; case 2: strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].hint)); break; } return TRUE; } case LVN_GETINFOTIP: { NMLVGETINFOTIP *nmit=(NMLVGETINFOTIP*)lParam; if (nmit->iItem!=-1 && nmit->iSubItem==0) { ff_strncpy(nmit->pszText,formats[nmit->iItem].hint,nmit->cchTextMax); } return TRUE; } case LVN_ITEMCHANGED: { NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam); if (nmlv->iItem!=curitem) { curitem=-1; show(false,IDC_CBX_INCODECS); options2dlg(nmlv->iItem); } return TRUE; } case NM_CLICK: { NMITEMACTIVATE *nmia=LPNMITEMACTIVATE(lParam); if (nmia->iItem!=-1 && nmia->iSubItem==1) { beginCodecChange(nmia->iItem); } else { show(false,IDC_CBX_INCODECS); } return TRUE; } } break; } } return TconfPageBase::msgProc(uMsg,wParam,lParam); }