Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
ow to make shortcuts on a secondary TFrame work Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
02-Sep-03
Category
VCL-General
Language
Delphi 5.x
Views
77
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Lou Adler

I am using multiple instances of a frame in my application. On the frame there are 
a couple of TActions that have shortcuts. If I have only one frame on the form, 
everything works fine and the shortcuts work. But if I am adding a secondary frame, 
it is always only one of the two frames that executes the TAction (eg. one of them 
will never have their TAction executed). The function I would like to see is, that 
when pressing the shortcut, the frame with the active component should execute its 
corresponding TActions. Is this possible with TFrames?

Answer:

With a bit of work. Override the host form's IsShortcut function. Pass the trapped 
message to the active frame's Actionlist.IsShortcut method first, if it returns 
true return True as result as well, otherwise return the result of the inherited 
IsShortcut function. This can be made fairly generic:
1   
2   function TMyform.IsShortcut(var message: TWMKey): Boolean; {override}
3   var
4     ctrl: TWinControl;
5     comp: TComponent;
6     i: Integer;
7   begin
8     ctrl := ActiveControl;
9     if ctrl <> nil then
10    begin
11      repeat
12        ctrl := ctrl.Parent
13      until
14        (ctrl = nil) or (ctrl is TCustomFrame);
15      if ctrl <> nil then
16      begin
17        for i := 0 to ctrl.ComponentCount - 1 do
18        begin
19          comp := ctrl.Components[i];
20          if comp is TCustomActionList then
21          begin
22            result := TCustomActionList(comp).IsShortcut(message);
23            if result then
24              Exit;
25          end;
26        end;
27      end;
28    end;
29    result inherited IsShortcut(message);
30  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC