Permalink
Browse files

Include ADO connection string in status bar connection details, short…

…en the lines reasonably and show the full lines in a message box when clicking on it. See http://www.heidisql.com/forum.php?t=23049
  • Loading branch information...
ansgarbecker committed Jan 14, 2017
1 parent f5224e1 commit 53b4ab69119a5728ce5315faa609d3c9b463c052
Showing with 46 additions and 3 deletions.
  1. +11 −2 source/dbconnection.pas
  2. +1 −0 source/main.dfm
  3. +34 −1 source/main.pas
View
@@ -4742,7 +4742,7 @@ function TDBConnection.ExtractIdentifier(var SQL: String): String;
function TDBConnection.ConnectionInfo: TStringList;
var
Infos, Val, v: String;
Infos, Val, v, ConnectionString: String;
major, minor, build: Integer;
rx: TRegExpr;
@@ -4789,7 +4789,16 @@ function TDBConnection.ConnectionInfo: TStringList;
rx.Free;
end;
ngMSSQL: ; // Nothing specific yet
ngMSSQL: begin
// clear out password
ConnectionString := TAdoDBConnection(Self).FAdoHandle.ConnectionString;
rx := TRegExpr.Create;
rx.ModifierI := True;
rx.Expression := '(\Wpassword=)([^;]*)';
ConnectionString := rx.Replace(ConnectionString, '${1}******', True);
rx.Free;
Result.Values[_('Connection string')] := ConnectionString;
end;
ngPgSQL: begin
v := IntToStr(PQlibVersion);
View
@@ -93,6 +93,7 @@ object MainForm: TMainForm
Width = 250
end>
ParentDoubleBuffered = False
OnClick = StatusBarClick
OnMouseLeave = StatusBarMouseLeave
OnMouseMove = StatusBarMouseMove
OnDrawPanel = StatusBarDrawPanel
View
@@ -1001,6 +1001,7 @@ TMainForm = class(TForm)
procedure actGotoDbTreeExecute(Sender: TObject);
procedure actGotoFilterExecute(Sender: TObject);
procedure actGotoTabNumberExecute(Sender: TObject);
procedure StatusBarClick(Sender: TObject);
private
// Executable file details
FAppVerMajor: Integer;
@@ -1219,6 +1220,38 @@ procedure TMainForm.ShowStatusMsg(Msg: String=''; PanelNr: Integer=6);
end;
procedure TMainForm.StatusBarClick(Sender: TObject);
var
Click: TPoint;
i, j: Integer;
PanelRect: TRect;
Infos: TStringList;
InfoText: String;
begin
// Handle click events on specific statusbar panels
Click := StatusBar.ScreenToClient(Mouse.CursorPos);
LogSQL(inttostr(click.X)+':'+inttostr(click.Y));
for i:=0 to StatusBar.Panels.Count-1 do begin
SendMessage(StatusBar.Handle, SB_GETRECT, i, Integer(@PanelRect));
if PtInRect(PanelRect, Click) then begin
// We found the clicked panel
case i of
3: begin
Infos := ActiveConnection.ConnectionInfo;
InfoText := '';
for j:=0 to Infos.Count-1 do begin
InfoText := InfoText + Infos.Names[j] + ': ' + Infos.ValueFromIndex[j] + CRLF + CRLF;
end;
MessageDialog(Trim(InfoText), mtInformation, [mbOK]);
end;
end;
Break;
end;
end;
end;
procedure TMainForm.StatusBarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
const Rect: TRect);
var
@@ -1281,7 +1314,7 @@ procedure TMainForm.StatusBarMouseMove(Sender: TObject; Shift: TShiftState; X, Y
Infos := ActiveConnection.ConnectionInfo;
BalloonHint1.Description := '';
for i:=0 to Infos.Count-1 do
BalloonHint1.Description := BalloonHint1.Description + Infos.Names[i] + ': ' + Infos.ValueFromIndex[i] + CRLF;
BalloonHint1.Description := BalloonHint1.Description + Infos.Names[i] + ': ' + sstr(Infos.ValueFromIndex[i],100) + CRLF;
BalloonHint1.Description := Trim(BalloonHint1.Description);
OffsetRect(PanelRect, Bar.ClientOrigin.X, Bar.ClientOrigin.Y);
BalloonHint1.ShowHint(PanelRect);

0 comments on commit 53b4ab6

Please sign in to comment.