Forum > WinCE
Backspace key on smartphone
(1/1)
skoro:
Hi!
I have simple form with TEdit component and TMenu. Pressing Backspace key on TEdit cause to hide app instead to delete char in TEdit. Digging WinAPI I known that it smartphone feature and to get work proper you must handle SHSendBackToFocusWindow message but how I can handle WinAPI messages in TForm component?
PS: I am use native lazarus WinCE components, not KOL-CE
felipemdc:
It's a function, not a message:
http://msdn.microsoft.com/en-us/library/bb431757.aspx
I'm not sure where the routine should be called however
skoro:
Solved. Just for history. Invoke below form as
--- Code: ---frmResolver.Show
--- End code ---
I see that
--- Code: ---ShowModal
--- End code ---
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.
--- Code: ---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.
--- End code ---
felipemdc:
Just for the record: The calling convention you used it wrong, it should be cdecl in WinCE, not stdcall. This can cause all kinds of problems.
JohnvdWaeter:
@skoro:
What happens if you use ShowModal?
I see no problems?
kr,
John
Navigation
[0] Message Index