From e832f984f265e5fa70d221a8a721ca8dccdeb4e5 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 20 Nov 2013 20:52:35 +0000 Subject: [PATCH] Turn "Drop" confirmation dialogs into custom critical types, so we can set focus to the Cancel button. See http://www.heidisql.com/forum.php?t=14042 --- source/helpers.pas | 3 +++ source/main.pas | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/helpers.pas b/source/helpers.pas index bbde5ed2..f708ee32 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -327,6 +327,7 @@ var AppSettings: TAppSettings; MutexHandle: THandle = 0; SystemImageList: TImageList; + mtCriticalConfirmation: TMsgDlgType = mtCustom; implementation @@ -2324,6 +2325,8 @@ var end; Btn.Caption := cap; Btn.ModalResult := BtnResult; + if (DlgType = mtCriticalConfirmation) and (BtnResult = mrCancel) then + Btn.Default := True; end; begin if (Win32MajorVersion >= 6) and StyleServices.Enabled then begin diff --git a/source/main.pas b/source/main.pas index ecb71748..6d21432a 100644 --- a/source/main.pas +++ b/source/main.pas @@ -2955,7 +2955,7 @@ begin // drop table selected in tree view. case ActiveDBObj.NodeType of lntDb: begin - if MessageDialog(f_('Drop Database "%s"?', [Conn.Database]), f_('WARNING: You will lose all objects in database %s!', [Conn.Database]), mtConfirmation, [mbok,mbcancel]) <> mrok then + if MessageDialog(f_('Drop Database "%s"?', [Conn.Database]), f_('WARNING: You will lose all objects in database %s!', [Conn.Database]), mtCriticalConfirmation, [mbok,mbcancel]) <> mrok then Abort; try db := Conn.Database; @@ -2997,7 +2997,7 @@ begin for DBObject in ObjectList do msg := msg + DBObject.Name + ', '; Delete(msg, Length(msg)-1, 2); - if MessageDialog(f_('Drop %d object(s) in database "%s"?', [ObjectList.Count, Conn.Database]), msg, mtConfirmation, [mbok,mbcancel]) = mrOk then begin + if MessageDialog(f_('Drop %d object(s) in database "%s"?', [ObjectList.Count, Conn.Database]), msg, mtCriticalConfirmation, [mbok,mbcancel]) = mrOk then begin try // Disable foreign key checks to avoid SQL errors if Conn.ServerVersionInt >= 40014 then