[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

Simulating keyboard actions with delphi

Hi experts!

I have this problem: In a program I am working on, I have some custom Listbox with items. I can click on one item and the item will be selected... So I use the information of the item and process it. As soon I process this item, I want to simulate the action of doubleclick to go to the next item. Because this is a custom made listbox, I don't have access to indexitems. So I guess is a good idea to simulate the click (or double click) over the next item.

Is there a way to do this thru delphi 7?

regards
Manuel Lopez (lopem)
0
lopem
Asked:
lopem
1 Solution
 
2266180Commented:
use mouse_event for mouse or keybd_event for keyboard
see the following for examples and explanatiosn:
mouse: http://delphi.about.com/od/vclusing/a/mouseadvanced.htm
keyboard: http://delphi.about.com/od/adptips2004/a/bltip0604_4.htm
0
 
Geert GruwezOracle dbaCommented:
you are developping a Delphi application
and by stating  "Because this is a custom made listbox"
what do you mean ?

surely it is a Delphi component with events ?
and if so it should have properties too
maybe like FocusedIndex or ItemIndex
i couldn't guess why these properties are unavailable
but if so, it is a poor component
how do you know what item was clicked or dblclicked ?

there should be an event too : OnDblClick
if nothing is assigned then the code is in the component ?

and maybe you can subclass so you have acess to all properties (including private and protected) with

type
  TMagicListbox = class(TYourListbox)
  end;

and when you use the TYourListbox cast it to the new type:
TMagicListbox(YourListbox)
and you will have all properties

TMagicListbox(YourListbox).ItemIndex := 0; // for the first element

TMagicListbox(YourListbox).ItemIndex := TMagicListbox(YourListbox).ItemIndex +1;
to focus the next element

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
2266180Commented:
>>  you can subclass so you have acess to all properties (including private and protected)

that is half true. with subclassing yuo get access to protected stuff only. not private :) in order to get access to private stuff, you need to declare the subclassing calss in teh same unit as the subclassed class. (I say stuff so to include: properties, members and methods)
0
 
Geert GruwezOracle dbaCommented:
>>ciuly
i stand corrected about that stuff :D

0
 
lopemAuthor Commented:
Hi, Geertz,

I am using some components to build some chess application. They are very well written but some of the components have few peculiar behaviour, for instance, the custom Listbox I was talking about (a way to load a PGN file to a listbox. A PGN file is a collection of chess games in some format called Portable Game Notation).

Of course teh component has OnDoubleclick, OnClick, etc. methods but they don't work as usual. For instance, if you want to see a chess game, there is not enough just to go to PGN1.Items[PGN1.ItemIndex]. For some reason you have to push the [enter]  key over the item selected or double click on it.  If you dont do this, you can't have access to a particular chess game. If I put the onDoubleClick method in my procedure, it always gives to me some sort of error saying the parameters are incorrect. Of course, I am doing something wrong but I couldn't figure out was wrong. To make things worst, the help file is in german  so I can actually understand some of it using altavista online translator.

I found that the simple way to accomplish my task and to get rid of the error was just to insert some [enter] key thru programming or simulate a doubleclick over the item I selected.  I know this is not the best thing to do but I was really fed up with the error...

When I read your remark I was thinking how it is possible to have some simple problems with these components? In any case, I actually solved my problems but I know I have to dig a little bit more around the chess components I am using.

best regards and thanks for your comments.

Manuel López (lopem)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now