Solved. Just for history. Invoke below form as frmResolver.Show
I see that ShowModal
not stable with this code.
Also, on form must be TMenu, thus in all TEdit component Backspace on smartphone worked as usual: delete char, not close form.
unit formResolver;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, Menus, Buttons, StdCtrls;
type
TfrmResolver = class(TForm)
appMenu: TMainMenu;
appMenuClose: TMenuItem;
btnResolve1: TBitBtn;
btnResolve2: TBitBtn;
editResIpAddr: TEdit;
editResHostname: TEdit;
editIpAddr: TEdit;
editHostname: TEdit;
stHostname: TStaticText;
stIpAddr: TStaticText;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
public
end;
var
frmResolver: TfrmResolver;
implementation
uses Windows, aygshell;
var
OldWndProc: WNDPROC;
{$R *.lfm}
procedure SHSendBackToFocusWindow(uMsg: UINT; wp: WPARAM; lp: LPARAM) external 'aygshell' index 97;
function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam): LRESULT; stdcall;
begin
if uMsg = WM_HOTKEY then begin
if HIWORD(lParam) = VK_ESCAPE then begin
SHSendBackToFocusWindow(uMsg, wParam, lParam);
Exit;
end;
end;
Result := CallWindowProc(OldWndProc, Ahwnd, uMsg, wParam, lParam);
end;
procedure TfrmResolver.FormShow(Sender: TObject);
begin
editHostname.SetFocus;
end;
procedure TfrmResolver.FormCreate(Sender: TObject);
var
mbi: SHMenuBarInfo;
begin
mbi.hwndMB := SHFindMenuBar(frmResolver.Handle);
if mbi.hwndMB <> 0 then
SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_ESCAPE,
MAKELPARAM(SHMBOF_NODEFAULT or SHMBOF_NOTIFY, SHMBOF_NODEFAULT or SHMBOF_NOTIFY)
);
OldWndProc := Windows.WNDPROC(SetWindowLong(Self.Handle, GWL_WNDPROC, PtrInt(@WndCallback)));
end;
end.