Skip to content
Snippets Groups Projects
Commit c31203fc authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add keyboard shortcuts to Clients list view: Ctrl-A, Ctrl-F and Del

Ctrl-A - Select All
Ctrl-F - Filter IP address
DEL - Close Socket

Also, use Begin/EndUpdate() calls to batch updates to the ListView in Timer
tick (no visible difference, but it's the right thing to do).

I don't know why C++Builder increased the TextHeight value of this form from
13 to 15, but doesn't seem to really matter (or at least, I couldn't tell).
parent 513715f0
Branches
Tags
No related merge requests found
Pipeline #6605 passed
...@@ -57,6 +57,7 @@ void __fastcall TClientForm::TimerTimer(TObject *Sender) ...@@ -57,6 +57,7 @@ void __fastcall TClientForm::TimerTimer(TObject *Sender)
if(WaitForSingleObject(ListMutex,1)!=WAIT_OBJECT_0) if(WaitForSingleObject(ListMutex,1)!=WAIT_OBJECT_0)
return; return;
ListView->Items->BeginUpdate();
for(i=0;i<ListView->Items->Count;i++) { for(i=0;i<ListView->Items->Count;i++) {
t=time(NULL)-(ulong)ListView->Items->Item[i]->Data; t=time(NULL)-(ulong)ListView->Items->Item[i]->Data;
if(t/(60*60)) if(t/(60*60))
...@@ -66,8 +67,8 @@ void __fastcall TClientForm::TimerTimer(TObject *Sender) ...@@ -66,8 +67,8 @@ void __fastcall TClientForm::TimerTimer(TObject *Sender)
ListView->Items->Item[i]->SubItems->Strings[5]=str; ListView->Items->Item[i]->SubItems->Strings[5]=str;
} }
ListView->Items->EndUpdate();
ReleaseMutex(ListMutex); ReleaseMutex(ListMutex);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -158,3 +159,10 @@ void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender) ...@@ -158,3 +159,10 @@ void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender)
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TClientForm::SelectAllMenuItemClick(TObject *Sender)
{
for(int i = 0; i < ListView->Items->Count; ++i)
ListView->Items->Item[i]->Selected = true;
}
//---------------------------------------------------------------------------
...@@ -16,38 +16,38 @@ object ClientForm: TClientForm ...@@ -16,38 +16,38 @@ object ClientForm: TClientForm
OldCreateOrder = False OldCreateOrder = False
OnHide = FormHide OnHide = FormHide
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 15
object ListView: TListView object ListView: TListView
Left = 0 Left = 0
Top = 0 Top = 0
Width = 615 Width = 615
Height = 307 Height = 306
Align = alClient Align = alClient
Color = clBlack Color = clBlack
Columns = < Columns = <
item item
Caption = 'Socket' Caption = 'Socket'
Width = 49 Width = 57
end end
item item
Caption = 'Protocol' Caption = 'Protocol'
Width = 53 Width = 61
end end
item item
Caption = 'User' Caption = 'User'
Width = 73 Width = 84
end end
item item
Caption = 'Address' Caption = 'Address'
Width = 81 Width = 93
end end
item item
Caption = 'Host Name' Caption = 'Host Name'
Width = 81 Width = 93
end end
item item
Caption = 'Port' Caption = 'Port'
Width = 45 Width = 52
end end
item item
AutoSize = True AutoSize = True
...@@ -72,11 +72,21 @@ object ClientForm: TClientForm ...@@ -72,11 +72,21 @@ object ClientForm: TClientForm
Top = 200 Top = 200
object CloseSocketMenuItem: TMenuItem object CloseSocketMenuItem: TMenuItem
Caption = '&Close Socket' Caption = '&Close Socket'
ShortCut = 46
OnClick = CloseSocketMenuItemClick OnClick = CloseSocketMenuItemClick
end end
object FilterIpMenuItem: TMenuItem object FilterIpMenuItem: TMenuItem
Caption = '&Filter IP Address' Caption = '&Filter IP Address'
ShortCut = 16454
OnClick = FilterIpMenuItemClick OnClick = FilterIpMenuItemClick
end end
object N1: TMenuItem
Caption = '-'
end
object SelectAllMenuItem: TMenuItem
Caption = 'Select All'
ShortCut = 16449
OnClick = SelectAllMenuItemClick
end
end end
end end
...@@ -55,10 +55,13 @@ __published: // IDE-managed Components ...@@ -55,10 +55,13 @@ __published: // IDE-managed Components
TPopupMenu *PopupMenu; TPopupMenu *PopupMenu;
TMenuItem *CloseSocketMenuItem; TMenuItem *CloseSocketMenuItem;
TMenuItem *FilterIpMenuItem; TMenuItem *FilterIpMenuItem;
TMenuItem *N1;
TMenuItem *SelectAllMenuItem;
void __fastcall FormHide(TObject *Sender); void __fastcall FormHide(TObject *Sender);
void __fastcall TimerTimer(TObject *Sender); void __fastcall TimerTimer(TObject *Sender);
void __fastcall CloseSocketMenuItemClick(TObject *Sender); void __fastcall CloseSocketMenuItemClick(TObject *Sender);
void __fastcall FilterIpMenuItemClick(TObject *Sender); void __fastcall FilterIpMenuItemClick(TObject *Sender);
void __fastcall SelectAllMenuItemClick(TObject *Sender);
private: // User declarations private: // User declarations
public: // User declarations public: // User declarations
__fastcall TClientForm(TComponent* Owner); __fastcall TClientForm(TComponent* Owner);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment