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
how to Make a TActionMainMenuBar on a secondary form work correctly 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
06-Feb-04
Category
Others
Language
Delphi 4.x
Views
95
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

On my main form, I have a TActionMainMenuBar with an ActionManager. On my subform, 
which is placed on the main form, I have a TActionToolbar with a second 
Actionmanager. Both works fine, but when then second form is active, only the 
(distinct) shortcuts of the main form are working, the ones of the client form are 
not.

Answer:

Solve 1:

In order to use a TActionMainMenuBar component on a second form, use the following 
code in the second form. This overcomes the problem where pressing "ALT" causes the 
first forms menu bar to appear.
1   
2   procedure TForm2.WMSysCommand(var message: TWMSysCommand);
3   begin
4     if (message.CmdType = SC_KEYMENU) then
5     begin
6       message.Result := SendMessage(ActionMainMenuBar.Handle, message.Msg,
7         message.CmdType, message.Key);
8       if (message.Result = 0) then
9         inherited;
10    end
11    else
12      inherited;
13  end;



Solve 2:

Try this code in you application's main form (duplicate it for CMActionUpdate):

14  { ... }
15  
16  procedure CMActionExecute(var message: TMessage); message CM_ACTIONEXECUTE;
17  { ... }
18  
19  procedure TForm1.CMActionexecute(var message: TMessage);
20  var
21    bPerformed: Boolean;
22    i: Integer;
23    Form: TCustomForm;
24  begin
25    bPerformed := False;
26    for i := 0 to Pred(Application.ComponentCount) do
27    begin
28      if Application.Components[i] is TCustomForm then
29      begin
30        Form := TCustomForm(Application.Components[i]);
31        if Form.Active then
32        begin
33          message.Result := Form.Perform(message.Msg, 0, message.LParam);
34          {Check the result.}
35          bPerformed := message.RESULT = S_OK;
36          if bPerformed then
37          begin
38            exit;
39          end;
40        end;
41      end;
42    end;
43    if not bPerformed then
44    begin
45      {If we havent sent the message anywhere then  perform the usual}
46      inherited;
47    end;
48  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