From: Oleg Sheikin Date: Fri, 1 Jul 2005 13:31:14 +0000 (+0000) Subject: Minor code improving. X-Git-Tag: v0.0.90~384^2~536 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1475737b726299374df6edb40caa29e82363cb88;p=tigervnc.git Minor code improving. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@299 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/rfb_win32/ListViewControl.cxx b/rfb_win32/ListViewControl.cxx index 3240d8bf..492aa8b0 100644 --- a/rfb_win32/ListViewControl.cxx +++ b/rfb_win32/ListViewControl.cxx @@ -15,74 +15,74 @@ ListViewControl::ListViewControl() } int ListViewControl::IsSelectedLVItem(DWORD idListView, - HWND hDlg, int numberItem) + HWND hDlg, int numberItem) { - return (ListView_GetItemState(GetDlgItem(hDlg, idListView), - numberItem, LVIS_SELECTED) == LVIS_SELECTED); + return (ListView_GetItemState(GetDlgItem(hDlg, idListView), + numberItem, LVIS_SELECTED) == LVIS_SELECTED); } void SelectLVItem(DWORD idListView, HWND hDlg, int numberItem) { - ListView_SetItemState(GetDlgItem(hDlg, idListView), - numberItem, LVIS_SELECTED, LVIS_SELECTED); + ListView_SetItemState(GetDlgItem(hDlg, idListView), + numberItem, LVIS_SELECTED, LVIS_SELECTED); } BOOL ListViewControl::InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns, - TCHAR *title[], DWORD mask, DWORD LVStyle, DWORD format) + TCHAR *title[], DWORD mask, DWORD LVStyle, DWORD format) { - ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle); - TCHAR szText[256]; - LVCOLUMN lvc; - int iCol; - - lvc.mask = mask; - - for (iCol = 0; iCol < columns; iCol++) { - lvc.iSubItem = iCol; - lvc.pszText = szText; - lvc.cx = width; - lvc.fmt = format; - - _tcscpy(szText, title[iCol]); - if (ListView_InsertColumn(GetDlgItem(hDlg, idListView), iCol, &lvc) == -1) - return FALSE; - } - return TRUE; + ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle); + TCHAR szText[256]; + LVCOLUMN lvc; + int iCol; + + lvc.mask = mask; + + for (iCol = 0; iCol < columns; iCol++) { + lvc.iSubItem = iCol; + lvc.pszText = szText; + lvc.cx = width; + lvc.fmt = format; + + _tcscpy(szText, title[iCol]); + if (ListView_InsertColumn(GetDlgItem(hDlg, idListView), iCol, &lvc) == -1) + return FALSE; + } + return TRUE; } BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, TCHAR * texts[], - int columns) + int columns) { - int i; - LVITEM lvI; - lvI.mask = LVIF_TEXT| LVIF_STATE; - lvI.state = 0; - lvI.stateMask = 0; - lvI.iItem = number; - lvI.iSubItem = 0; - lvI.pszText = texts[0]; - - if(ListView_InsertItem(GetDlgItem(hDlg, idListView), &lvI) == -1) - return NULL; - - for (i =1; i < columns; i++) { - SetLVItemText( - idListView, hDlg, - number, i, texts[i]); - } - return TRUE; + int i; + LVITEM lvI; + lvI.mask = LVIF_TEXT| LVIF_STATE; + lvI.state = 0; + lvI.stateMask = 0; + lvI.iItem = number; + lvI.iSubItem = 0; + lvI.pszText = texts[0]; + + if(ListView_InsertItem(GetDlgItem(hDlg, idListView), &lvI) == -1) + return NULL; + + for (i =1; i < columns; i++) { + SetLVItemText( + idListView, hDlg, + number, i, texts[i]); + } + return TRUE; } void ListViewControl::SetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text) + int namberColumn, TCHAR * text) { - ListView_SetItemText( - GetDlgItem(hDlg, idListView), - numberItem, namberColumn, text); + ListView_SetItemText( + GetDlgItem(hDlg, idListView), + numberItem, namberColumn, text); } void ListViewControl::GetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text) + int namberColumn, TCHAR * text) { ListView_GetItemText(GetDlgItem(hDlg, idListView), numberItem, namberColumn, text, 256); @@ -90,13 +90,14 @@ void ListViewControl::GetLVItemText(DWORD idListView, HWND hDlg, int numberItem, void ListViewControl::DeleteLVItem(DWORD idListView, HWND hDlg, int number) { - ListView_DeleteItem(GetDlgItem(hDlg, idListView), number); + ListView_DeleteItem(GetDlgItem(hDlg, idListView), number); } void ListViewControl::DeleteAllLVItem(DWORD idListView, HWND hDlg) { - ListView_DeleteAllItems(GetDlgItem(hDlg, idListView)); + ListView_DeleteAllItems(GetDlgItem(hDlg, idListView)); } + ListViewControl::~ListViewControl() { } diff --git a/rfb_win32/ListViewControl.h b/rfb_win32/ListViewControl.h index fa171998..aef916e0 100644 --- a/rfb_win32/ListViewControl.h +++ b/rfb_win32/ListViewControl.h @@ -9,26 +9,26 @@ #include "commctrl.h" namespace rfb { - + namespace win32 { - class ListViewControl - { - public: - ListViewControl(); - int IsSelectedLVItem(DWORD idListView, HWND hDlg, int numberItem); - void SelectLVItem(DWORD idListView, HWND hDlg, int numberItem); - BOOL InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns, - TCHAR * title[], DWORD mask, DWORD style, DWORD format); - BOOL InsertLVItem(DWORD idListView, HWND hDlg, int number, TCHAR * texts[], - int columns); - void SetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text); - void GetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text); - void DeleteLVItem(DWORD idListView, HWND hDlg, int number); - void DeleteAllLVItem(DWORD idListView, HWND hDlg); - virtual ~ListViewControl(); - }; + class ListViewControl + { + public: + ListViewControl(); + int IsSelectedLVItem(DWORD idListView, HWND hDlg, int numberItem); + void SelectLVItem(DWORD idListView, HWND hDlg, int numberItem); + BOOL InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns, + TCHAR * title[], DWORD mask, DWORD style, DWORD format); + BOOL InsertLVItem(DWORD idListView, HWND hDlg, int number, TCHAR * texts[], + int columns); + void SetLVItemText(DWORD idListView, HWND hDlg, int numberItem, + int namberColumn, TCHAR * text); + void GetLVItemText(DWORD idListView, HWND hDlg, int numberItem, + int namberColumn, TCHAR * text); + void DeleteLVItem(DWORD idListView, HWND hDlg, int number); + void DeleteAllLVItem(DWORD idListView, HWND hDlg); + virtual ~ListViewControl(); + }; }; }; diff --git a/winvnc/ControlPanel.cxx b/winvnc/ControlPanel.cxx index 8162068b..60624ce6 100644 --- a/winvnc/ControlPanel.cxx +++ b/winvnc/ControlPanel.cxx @@ -13,24 +13,24 @@ using namespace winvnc; bool ControlPanel::showDialog() { - return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONTROL_PANEL), NULL); + return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONTROL_PANEL), NULL); } void ControlPanel::initDialog() { - TCHAR *ColumnsStrings[] = { + TCHAR *ColumnsStrings[] = { "IP address", "Time connected", "Status" }; - InitLVColumns(IDC_LIST_CONNECTIONS, handle, 120, 3, ColumnsStrings, - LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, - LVS_EX_FULLROWSELECT, LVCFMT_LEFT); + InitLVColumns(IDC_LIST_CONNECTIONS, handle, 120, 3, ColumnsStrings, + LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, + LVS_EX_FULLROWSELECT, LVCFMT_LEFT); } bool ControlPanel::onCommand(int cmd) { - switch (cmd) { + switch (cmd) { case IDC_PROPERTIES: SendMessage(m_hSTIcon, WM_COMMAND, ID_OPTIONS, 0); return false; @@ -54,17 +54,17 @@ bool ControlPanel::onCommand(int cmd) } } return false; - + } void ControlPanel::UpdateListView() { - + } BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) { + switch (msg) { case WM_INITDIALOG: handle = hwnd; initDialog(); @@ -84,10 +84,10 @@ BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) void ControlPanel::getSelectedConn(std::list* selsockets) { - + } ControlPanel::~ControlPanel() { - + } diff --git a/winvnc/ControlPanel.h b/winvnc/ControlPanel.h index ed761ead..5f9bc240 100644 --- a/winvnc/ControlPanel.h +++ b/winvnc/ControlPanel.h @@ -18,13 +18,13 @@ #include namespace winvnc { - + class ControlPanel : rfb::win32::Dialog, rfb::win32::ListViewControl { public: - ControlPanel(VNCServerWin32 * server, HWND hSTIcon) : Dialog(GetModuleHandle(0)), ListViewControl(){ - m_server = server; - m_hSTIcon = hSTIcon; - }; + ControlPanel(VNCServerWin32 * server, HWND hSTIcon) : Dialog(GetModuleHandle(0)), ListViewControl(){ + m_server = server; + m_hSTIcon = hSTIcon; + }; virtual bool showDialog(); virtual void initDialog(); virtual bool onCommand(int cmd); @@ -34,9 +34,9 @@ namespace winvnc { protected: virtual BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); void getSelectedConn(std::list* selsockets); - VNCServerWin32 * m_server; - std::list sockets; - HWND m_hSTIcon; + VNCServerWin32 * m_server; + std::list sockets; + HWND m_hSTIcon; }; };