Board index » delphi » No KeyDown/Up event while dragging???

No KeyDown/Up event while dragging???

This one has me baffled...

I have a TCustomGrid (D1) derived component, and while dragging from
this grid, it no longer recieves KeyDown/Up events! It is essential that
I can revieve KeyDown/Up during the drag, in order to change the cursor
(and eventually the operation performed, like Ctrl and Shift in win 9x
Explorer).

I can check ShiftState in OnMouseMove, but that is no good if the mouse
isn't moving.

What am I missing?

-- Erwin Dokter
   mailto:edok...@home.nl
   http://members.home.nl/edokter

 

Re:No KeyDown/Up event while dragging???


Quote
In article <3ACA6582.1...@home.nl>, Erwin Dokter <edok...@home.nl> writes:
>I have a TCustomGrid (D1) derived component, and while dragging from
>this grid, it no longer recieves KeyDown/Up events! It is essential that
>I can revieve KeyDown/Up during the drag, in order to change the cursor
>(and eventually the operation performed, like Ctrl and Shift in win 9x
>Explorer).

>I can check ShiftState in OnMouseMove, but that is no good if the mouse
>isn't moving.

>What am I missing?

Call GetKeyState in OnDragOver ...

  if GetKeyState(VK_SHIFT) < 0 then   // shift key pressed
    etc

For toggled keys (CapsLock, Insert etc) the test is "Odd(GetKeyState())".

Alan Lloyd
alangll...@aol.com

Re:No KeyDown/Up event while dragging???


Quote
In article <3ACA6582.1...@home.nl>, Erwin Dokter <edok...@home.nl> writes:
>I can check ShiftState in OnMouseMove, but that is no good if the mouse
>isn't moving.

After sending my last e-mail I realised that OnDragOver also only gets called
when the mouse moves. One way I have addressed this problem for a similar
(scrolling a treeview while dragging) problem is to "waggle" the mouse 1 pixel
in the OnDragOver, which causes the event to be re-called continously and hence
gives on-going monitoring ...

const
  MM : integer = 1;
begin
  Accept := true;
  if GetKeyState(VK_SHIFT) < 0 then   // shift key pressed
    etc
  Sleep(100);  / ... or some appropriate value
  MM := -MM;
  Mouse_Event(MOUSEEVENTF_MOVE, MM, 0, 0, 0);
end;

Alan Lloyd
alangll...@aol.com

Re:No KeyDown/Up event while dragging???


Quote
AlanGLLoyd wrote:

> After sending my last e-mail I realised that OnDragOver also only gets called
> when the mouse moves. One way I have addressed this problem for a similar
> (scrolling a treeview while dragging) problem is to "waggle" the mouse 1 pixel
> in the OnDragOver, which causes the event to be re-called continously and hence
> gives on-going monitoring ...

Delphi 1 has no Sleep. Initially, a RefreshCursor* function was called,
automatically triggering MouseMove, However, due to 16-bit multitasking,
it blocked the entire process, ie. not redrawing anything. Putting in a
Application ProcessMessages caused a GPF even...

I even went through the VCL source to see what was blocking the KeyDown
event, but I couldn't find anything. Maybe I'll just have to live with
it.

The weird thing is, MouseDown *does* still work.

* GetCursorPos(p);
  SetCursorPos(p.x, p.y);

-- Erwin Dokter
   mailto:edok...@home.nl
   http://members.home.nl/edokter

Other Threads