DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   Watched TopicsWatched Topics     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

component key events not triggered?

 
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
HPW
Senior Member


Joined: 25 Feb 2006
Posts: 131
Location: Germany

PostPosted: 28/02/06 08:08    Post subject: component key events not triggered? Reply with quote

I have a problem with the keyevents when I use the SimpleGraph component in my plugin.
I have tested that they work in a normal Testapp with no problem.

The plugin is a DLL which is called by the host-app.
The DLL has form where the SG is on.
When I define a SG-OnKeyDown event I can see that it is called:

Code:

procedure ThpwForm.SimpleGraph1KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);
begin
if  Key=VK_TAB then
      showmessage('Key=Tab')
    ELSE IF Key=VK_DELETE then
      showmessage('Key=Delete')
    ELSE IF Key=VK_LEFT then
      showmessage('Key=Left')
    ELSE IF Key=VK_RIGHT then
      showmessage('Key=Right')
    ELSE IF Key=VK_UP then
      showmessage('Key=Up')
    ELSE IF Key=VK_DOWN then
      showmessage('Key=Down');
end;


Edit-mode is on cmEdit.
But why is the components key handling not called?
Any idea what can cause this?

_________________
Hans-Peter
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1113
Location: Tehran, Iran

PostPosted: 28/02/06 15:45    Post subject: Reply with quote

For keys supported by the component, OnKeyDown event doesn't generate. It's because the default Delphi's event handler is very slow and it causes the objects receive key sequences with lot of delay delay.

If you want to manage all key events by yourself, set DefaultKeyMap property to False.

_________________
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
HPW
Senior Member


Joined: 25 Feb 2006
Posts: 131
Location: Germany

PostPosted: 28/02/06 16:12    Post subject: Reply with quote

>If you want to manage all key events by yourself, set DefaultKeyMap property to False.

I do not want to manage them myself, but your component's key events does not get triggered. Since it does work in standalone, it may not a problem with your component, instead it is my unusual use of it. I ask for ideas what can cause this behaviour.

_________________
Hans-Peter
Back to top
View user's profile Send private message
HPW
Senior Member


Joined: 25 Feb 2006
Posts: 131
Location: Germany

PostPosted: 01/03/06 06:36    Post subject: Reply with quote

With the help from Dave from neosoft I got the problem solved.

Here his comment:

Quote:

In the SimpleGraph.pas file change the following two lines from:

procedure CNKeyDown(var Msg: TWMKeyDown); message CN_KEYDOWN;
procedure CNKeyUp(var Msg: TWMKeyUp); message CN_KEYUP;

to:

procedure CNKeyDown(var Msg: TWMKeyDown); message WM_KEYDOWN;
procedure CNKeyUp(var Msg: TWMKeyUp); message WM_KEYUP;

The CN_KEYDOWN or CN_KEYUP events don't seem to be documented, so I don't know why they would be using them.
However, changing the declaration to the more common WM_ equivalents seemed to solve the problem.


This change work for me. So any reason against it?

_________________
Hans-Peter
Back to top
View user's profile Send private message
HPW
Senior Member


Joined: 25 Feb 2006
Posts: 131
Location: Germany

PostPosted: 01/03/06 06:50    Post subject: Reply with quote

Oops, just noticed that it does not work anymore in standalone!
So one configuration for standalone and one for plugin!

_________________
Hans-Peter
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1113
Location: Tehran, Iran

PostPosted: 01/03/06 07:49    Post subject: Reply with quote

You found yourself why I've used CN_KEYDOWN and CNKEYUP messages. Smile

Controls receive dialog keyboard messages. Using WM_KEYDOWN and WM_KEYUP messages cause default behavior of TAB and ARROW keys, but SimpleGraph needs these keys.

_________________
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1113
Location: Tehran, Iran

PostPosted: 01/03/06 07:53    Post subject: Reply with quote

If your host application is a Delphi application, and you have access to its TApplication.Handle property, I think the following assignment solves the problem.

Code:
Application.Handle := HostApplication.Handle;

_________________
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
HPW
Senior Member


Joined: 25 Feb 2006
Posts: 131
Location: Germany

PostPosted: 02/03/06 09:38    Post subject: Reply with quote

Quote:

Application.Handle := HostApplication.Handle;


I tested it but it does not work for me.
Anyway with mychange above I get it working with arrows,tab and delete key.
But I still have problems to get CTRL-C,CTRL-V and CTRL-X to work.
Any idea?
Are they triggered by the component itself of how are this hotkeys attached to TSimpleGraph. In the demo I see them in the mainmenu, but my plugin has no mainmenu. In SimpleGraph.OnKeyDown I get all combinations with ALT+SHIFT but not with CTRL. I can make a ALT-C to copy to the clipboard, but not with CTRL-C. The CTRL-key alone gets through, but not the other key?

_________________
Hans-Peter
Back to top
View user's profile Send private message
HPW
Senior Member


Joined: 25 Feb 2006
Posts: 131
Location: Germany

PostPosted: 02/03/06 10:25    Post subject: Reply with quote

Oops, got it working. My error was is keycode-conversion.
_________________
Hans-Peter
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

Add to favorites

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group