There is only a ListBox and PopupMenu, attached to it (Delphi XE7, VCL). When I right-click a ListBox, menu is invoked, and when I long press the stylus (or finger) on the tablet does not. What could be the problem? Thanks!
1 Answers
According to this MSDN documentation:
How to Enable Tablet Press-and-Hold Gesture in MFC Application
To enable the right-click concept that usually means "display the context menu", and comes in the form of WM_RBUTTONDOWN, WM_RBUTTONUP, and WM_CONTEXTMENU messages and ISG_HOLDENTER and ISG_RIGHTTAP events, the "press and hold" gesture must be enabled for that window. In order to detect this gesture, by necessity some delay is introduced to distinguish between a simple "press" (treated as a left-click) and a "press and hold" (right-click). Thus, it will take longer for left click events to be raised, and the application will seem less responsive. So, for this reason, the default behavior is to disable the "press and hold" gesture.
Without that gesture, a long press will not generate a WM_CONTEXTMENU
message, which the VCL uses to display popup menus.
If your application wants to enable the press-and-hold gesture, you must [handle the
WM_TABLET_QUERYSYSTEMGESTURESTATUS
message] in your [window] and return something that doesn't include the TABLET_DISABLE_PRESSANDHOLD flag.
Try subclassing the ListBox's WindowProc
property to catch that message:
private
PrevListBoxWndProc: TWndMethod;
procedure ListBoxWndProc(var Message: TMessage);
...
procedure TMyForm.FormCreate(Sender: TObject);
begin
PrevListBoxWndProc := ListBox1.WindowProc;
ListBox1.WindowProc := ListBoxWndProc;
end;
procedure TMyForm.ListBoxWndProc(var Message: TMessage);
const
WM_TABLET_QUERYSYSTEMGESTURESTATUS = 0x02CC;
begin
if Message.Msg = WM_TABLET_QUERYSYSTEMGESTURESTATUS then
Message.Result := 0
else
PrevListBoxWndProc(Message);
end;