Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
A problem with Trackbar OnKeyDown on a Form Posted by hadipardis on 22 May 2006 at 11:12 AM
Hi
I have a form and a Trackbar on it. Both of them has an OnKeyDown event. As you may know better, at the run-time, if we press a key, only the OnKeyDown of Trackbar occures. But how we can able to choose each of them to be active? For example if i=1 then we want to active the OnKeyDown of the Form and if i=0 we wan to active the relevant event of the trackbar. Please note that it is not possible to disable the trackbar. Now, Could you please help me by an example? Thanks

Report
Re: A problem with Trackbar OnKeyDown on a Form Posted by pritaeas on 22 May 2006 at 12:11 PM
You can set the KeyPreview property of the form to True. Then the form will get the event first.

: Hi
: I have a form and a Trackbar on it. Both of them has an OnKeyDown event. As you may know better, at the run-time, if we press a key, only the OnKeyDown of Trackbar occures. But how we can able to choose each of them to be active? For example if i=1 then we want to active the OnKeyDown of the Form and if i=0 we wan to active the relevant event of the trackbar. Please note that it is not possible to disable the trackbar. Now, Could you please help me by an example? Thanks
:
:

Report
Re: A problem with Trackbar OnKeyDown on a Form Posted by hadipardis on 23 May 2006 at 3:07 AM
: You can set the KeyPreview property of the form to True. Then the form will get the event first.
:
: : Hi
: : I have a form and a Trackbar on it. Both of them has an OnKeyDown event. As you may know better, at the run-time, if we press a key, only the OnKeyDown of Trackbar occures. But how we can able to choose each of them to be active? For example if i=1 then we want to active the OnKeyDown of the Form and if i=0 we wan to active the relevant event of the trackbar. Please note that it is not possible to disable the trackbar. Now, Could you please help me by an example? Thanks
: :
: :
:
:
Thank you very much for your help. But when I set the KeyPreview of the form to True, both the form and the trackbar receive the keyboard events.But Only the form receives it first. For example when I press the right arrow key , the OnKeyDown event of the form occures and the slider of the trackbar moves too! But I want to only the form recieves the keyboard events when for example i=1 (The Trackbar's Slider shouldn't change in this case)and when i=0 then the user can change the position of the Trackbar's Slider and so deactive the Form's OnKeyDown. Also please note that, Delphi help says that Navigation keys such as Arrow Keys are unaffected by KeyPreview. But I need them! In the other words, I need to change the focus or active control between the form itself and the trackbar or any another control. Now, what is your solution to do so? Thanks
Report
Re: A problem with Trackbar OnKeyDown on a Form Posted by zibadian on 23 May 2006 at 3:35 AM
: : You can set the KeyPreview property of the form to True. Then the form will get the event first.
: :
: : : Hi
: : : I have a form and a Trackbar on it. Both of them has an OnKeyDown event. As you may know better, at the run-time, if we press a key, only the OnKeyDown of Trackbar occures. But how we can able to choose each of them to be active? For example if i=1 then we want to active the OnKeyDown of the Form and if i=0 we wan to active the relevant event of the trackbar. Please note that it is not possible to disable the trackbar. Now, Could you please help me by an example? Thanks
: : :
: : :
: :
: :
: Thank you very much for your help. But when I set the KeyPreview of the form to True, both the form and the trackbar receive the keyboard events.But Only the form receives it first. For example when I press the right arrow key , the OnKeyDown event of the form occures and the slider of the trackbar moves too! But I want to only the form recieves the keyboard events when for example i=1 (The Trackbar's Slider shouldn't change in this case)and when i=0 then the user can change the position of the Trackbar's Slider and so deactive the Form's OnKeyDown. Also please note that, Delphi help says that Navigation keys such as Arrow Keys are unaffected by KeyPreview. But I need them! In the other words, I need to change the focus or active control between the form itself and the trackbar or any another control. Now, what is your solution to do so? Thanks
:
You can "remove" the key press by setting the Key parameter to 0. Then the scrollbar shouldn't recieve the key anymore.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.