Board index » delphi » Ctrl-key down, slows windows messages

Ctrl-key down, slows windows messages

What happens when you drag with the ctrl key pressed?  Why does windows
message handling slows down that much? What is VCL doing when the ctrl,
shift or alt keys are pressed?

I've made an application that maintains some drawings on a canvas...
When the user drags in this drawing, it is moved and repainted posting a
message to the form, that the drawing became "dirty".
 When the message is handled, it just repaints the canvas with the new
position.

Everything works fine, but if you drag with the ctrl, Alt or Shift key
pressed, this messages get a huge overhead, hence the painting is slowed
down....

It seems that something on the VCL is doing something when those keys are
pressed and wastes a lot of processing time... why!? how can i prevent this?
  I need to use this keys to make different functions, i can't replace
them... ( drag+shift = zoom ,  drag+ctrl = panning , drag+alt=moves an
object)

Emiliano Sosa
Software dep.
Sierra S.R.L. www.gosierra.com
Buenos Aires Argentina

 

Re:Ctrl-key down, slows windows messages


Quote
In article <3caccb98_1@dnews>, Emiliano Sosa wrote:
> What happens when you drag with the ctrl key pressed?  Why does windows
> message handling slows down that much? What is VCL doing when the ctrl,
> shift or alt keys are pressed?

The keys have an autorepeat function, so in between the mouse messages you
also get heaps of key down messages put into the message queue, each of which
is passed through the whole machinery of key message processing done by the
VCL. THat may well have an effect on total performance. You should be able to
drastically reduce this effect with an Application.OnMessage handler that just
discards any key messages when dragging is in progress.

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Re:Ctrl-key down, slows windows messages


Quote
> The keys have an autorepeat function, so in between the mouse messages you
> also get heaps of key down messages put into the message queue, each of
which
> is passed through the whole machinery of key message processing done by
the
> VCL.

This is true, but it doesn't affect performance that much... I've made an
Application.OnMessage handler, and there was no significant improvement...
  You can see this overhead even without a delphi application... Just open
the PaintBrush with a big bitmap, then open the windows explorer above it,
and resize it moving the mouse in fast circles...
  Doing this with the ctrl, shift or alt key pressed, is much slower. You
will see an asynchronous behavior beetween the mouse position and the
window. This is because paint messages are slowed down when these keys are
pressed....

  Just for research, i've tried to fix it by implementing a Keyboard hook in
a separate DLL, and disabled these keys when dragging was in effect... I
manage to make this keys stop working in any opened application, but it
still didn't work.. It seems that windows does something first.... I run out
of resources, i donno what else to do but to NEVER use these keys again....

Emiliano Sosa
Software dep.
Sierra S.R.L. www.gosierra.com
Buenos Aires Argentina

Re:Ctrl-key down, slows windows messages


Quote
In article <3cadc782$1_1@dnews>, Emiliano Sosa wrote:
> Doing this with the ctrl, shift or alt key pressed, is much slower. You
> will see an asynchronous behavior beetween the mouse position and the
> window. This is because paint messages are slowed down when these keys are
> pressed....

WM_PAINT is rather low on the priority totem pole for messages, as long as
there are other messages in the queue a WM_PAINT is not delivered. That may
explain the effect, at least contribute to it.

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Other Threads