Ticket #1455: patch5.diff
File patch5.diff, 3.7 KB (added by , 20 years ago) |
---|
-
UsersListCtrl.cpp
52 53 ON_COMMAND(ID_USERVIEWCONTEXT_KICK, OnContextmenuKick) 53 54 ON_WM_CONTEXTMENU() 54 55 //}}AFX_MSG_MAP 56 ON_WM_SIZE() 55 57 END_MESSAGE_MAP() 56 58 57 59 ///////////////////////////////////////////////////////////////////////////// … … 62 64 if (CListCtrl::OnCreate(lpCreateStruct) == -1) 63 65 return -1; 64 66 65 InsertColumn(0,"Connected users",LVCFMT_LEFT,1000); 67 InsertColumn(0,"ID",LVCFMT_RIGHT,-1,0); 68 InsertColumn(1,"Account",LVCFMT_LEFT,-1,1); 69 InsertColumn(2,"IP",LVCFMT_RIGHT,-1,2); 70 AutoResizeColumns(); 71 66 72 return 0; 67 73 } 68 74 75 void CUsersListCtrl::AutoResizeColumns() 76 { 77 SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER); 78 SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER); 79 SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER); 80 } 81 69 82 void CUsersListCtrl::ProcessConnOp(int op, const t_connectiondata &connectionData) 70 83 { 71 84 if (op == USERCONTROL_CONNOP_ADD) 72 85 { 73 CString str; 86 CString str_id; 87 str_id.Format("%06d",connectionData.userid); 88 int index = InsertItem(GetItemCount(), str_id); 74 89 if (connectionData.user == "") 75 str.Format("(not logged in) (%06d)",connectionData.userid);90 SetItemText(index,1,"(not logged in)"); 76 91 else 77 str.Format("%s (%06d)", connectionData.user, connectionData.userid);78 int index = InsertItem(GetItemCount(), str);92 SetItemText(index,1,connectionData.user); 93 SetItemText(index,2,connectionData.ip); 79 94 t_connectiondata *pData = new t_connectiondata; 80 95 *pData = connectionData; 81 96 SetItemData(index, (DWORD)pData); 97 AutoResizeColumns(); 82 98 83 99 if (GetItemCount() == 1) 84 100 m_pOwner->SetIcon(); … … 92 108 { 93 109 *pData = connectionData; 94 110 95 CString str; 111 CString str_id; 112 str_id.Format("%06d",connectionData.userid); 113 SetItemText(i,0,str_id); 96 114 if (connectionData.user=="") 97 str.Format("(not logged in) (%06d)",connectionData.userid);115 SetItemText(i,1,"(not logged in)"); 98 116 else 99 str.Format("%s (%06d)",connectionData.user,connectionData.userid); 100 SetItemText(i,0,str); 117 SetItemText(i,1,connectionData.user); 118 AutoResizeColumns(); 119 101 120 break; 102 121 } 103 122 } … … 111 130 { 112 131 delete pData; 113 132 DeleteItem(i); 133 AutoResizeColumns(); 114 134 break; 115 135 } 116 136 } … … 257 277 break; 258 278 } 259 279 return TRUE; 260 } 261 No newline at end of file 280 } 281 282 void CUsersListCtrl::OnSize(UINT nType, int cx, int cy) 283 { 284 CListCtrl::OnSize(nType, cx, cy); 285 286 AutoResizeColumns(); 287 } -
UsersListCtrl.h
42 42 // Operationen 43 43 public: 44 44 BOOL ParseUserControlCommand(unsigned char *pData, DWORD dwDataLength); 45 void AutoResizeColumns(); 45 46 46 47 // Überschreibungen 47 48 // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen … … 63 64 //}}AFX_MSG 64 65 65 66 DECLARE_MESSAGE_MAP() 67 public: 68 afx_msg void OnSize(UINT nType, int cx, int cy); 66 69 }; 67 70 68 71 -
UsersView.cpp
95 95 96 96 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 97 97 m_pListCtrl=new CUsersListCtrl(pMainFrame); 98 m_pListCtrl->Create(LVS_NOSORTHEADER|LVS_REPORT|WS_CHILD | WS_VISIBLE | LVS_SHOWSELALWAYS|LVS_SHAREIMAGELISTS|WS_VSCROLL |LVS_NOCOLUMNHEADER,CRect(0,0,0,0),this,0);98 m_pListCtrl->Create(LVS_NOSORTHEADER|LVS_REPORT|WS_CHILD | WS_VISIBLE | LVS_SHOWSELALWAYS|LVS_SHAREIMAGELISTS|WS_VSCROLL,CRect(0,0,0,0),this,0); 99 99 100 100 return 0; 101 101 }