You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ListViewControl.cxx 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // ListViewControl.cxx: implementation of the ListViewControl class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #ifdef HAVE_CONFIG_H
  5. #include <config.h>
  6. #endif
  7. #include "ListViewControl.h"
  8. #include "commctrl.h"
  9. //////////////////////////////////////////////////////////////////////
  10. // Construction/Destruction
  11. //////////////////////////////////////////////////////////////////////
  12. using namespace rfb;
  13. using namespace rfb::win32;
  14. ListViewControl::ListViewControl()
  15. {
  16. }
  17. bool ListViewControl::IsSelectedLVItem(DWORD idListView,
  18. HWND hDlg, int numberItem)
  19. {
  20. return (ListView_GetItemState(GetDlgItem(hDlg, idListView),
  21. numberItem, LVIS_SELECTED) == LVIS_SELECTED);
  22. }
  23. void ListViewControl::SelectLVItem(DWORD idListView, HWND hDlg, int numberItem)
  24. {
  25. ListView_SetItemState(GetDlgItem(hDlg, idListView),
  26. numberItem, LVIS_SELECTED, LVIS_SELECTED);
  27. }
  28. BOOL ListViewControl::InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns,
  29. char *title[], DWORD mask, DWORD LVStyle, DWORD format)
  30. {
  31. (void)ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle);
  32. char szText[256];
  33. LVCOLUMN lvc;
  34. int iCol;
  35. lvc.mask = mask;
  36. for (iCol = 0; iCol < columns; iCol++) {
  37. lvc.iSubItem = iCol;
  38. lvc.pszText = szText;
  39. lvc.cx = width;
  40. lvc.fmt = format;
  41. strcpy(szText, title[iCol]);
  42. if (ListView_InsertColumn(GetDlgItem(hDlg, idListView), iCol, &lvc) == -1)
  43. return FALSE;
  44. }
  45. return TRUE;
  46. }
  47. BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, char * texts[],
  48. int columns)
  49. {
  50. int i;
  51. LVITEM lvI;
  52. lvI.mask = LVIF_TEXT| LVIF_STATE;
  53. lvI.state = 0;
  54. lvI.stateMask = 0;
  55. lvI.iItem = number;
  56. lvI.iSubItem = 0;
  57. lvI.pszText = texts[0];
  58. if(ListView_InsertItem(GetDlgItem(hDlg, idListView), &lvI) == -1)
  59. return FALSE;
  60. for (i =1; i < columns; i++) {
  61. SetLVItemText(
  62. idListView, hDlg,
  63. number, i, texts[i]);
  64. }
  65. return TRUE;
  66. }
  67. void ListViewControl::SetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
  68. int namberColumn, char * text)
  69. {
  70. ListView_SetItemText(
  71. GetDlgItem(hDlg, idListView),
  72. numberItem, namberColumn, text);
  73. }
  74. void ListViewControl::GetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
  75. int namberColumn, char * text)
  76. {
  77. ListView_GetItemText(GetDlgItem(hDlg, idListView), numberItem,
  78. namberColumn, text, 256);
  79. }
  80. void ListViewControl::DeleteLVItem(DWORD idListView, HWND hDlg, int number)
  81. {
  82. (void)ListView_DeleteItem(GetDlgItem(hDlg, idListView), number);
  83. }
  84. void ListViewControl::DeleteAllLVItem(DWORD idListView, HWND hDlg)
  85. {
  86. (void)ListView_DeleteAllItems(GetDlgItem(hDlg, idListView));
  87. }
  88. ListViewControl::~ListViewControl()
  89. {
  90. }