procedure TfrmMain.CreateTabSheet( myFormClass: TFormClass;var Reference: TForm);
var
MyForm : TForm;
begin
tabsheet := TRzTabSheet.Create(RpgcMain);
try
tabsheet.Caption := Reference.Caption;
tabsheet.PageControl := RpgcMain;
tabsheet.Name := stabsheetname;
MyForm := myFormClass.Create(tabsheet);
try
MyForm.Parent := tabsheet;
MyForm.BorderStyle := bsnone;
MyForm.WindowState := wsmaximized;
RpgcMain.ActivePage := tabsheet;
MyForm.Show;
except
FreeAndNil(MyForm);
end;
except
FreeAndNil(tabsheet);
end;
end;
把窗体放入PageControl后,actionlist 中设置的快捷键失灵了

解决方案 »

  1.   

    我也用过PageControl,出现在线程事件中往MEMO控件添加字符在程序启动时,如果MEMO不在当前显示的页面,MEMO控件不会显示了
      

  2.   

    测试一下focuse在哪?可以在pagecontrol所在form的keydown事件里检查(keypreview需先设为true)
      

  3.   

    keypreview需先设为true,
    keydown在edit中可以输入,但就是不对放入PageControl的窗体内的actionlist起作用,另主窗体的actionlist可以成功使用。
      

  4.   

    主窗体的keypreview=true
    放入PageControl的窗体内的除actionlist外,如Enter处理可以完成,edit输入也没有问题,但快捷键就是不起作用,郁闷中!help!
    主窗体的actionlist可以工作,去除后,也不行!
      

  5.   

    有没有关联呀?主窗体ACTIONLIST和你的控件有没有关联?
      

  6.   

    actionlist中的快捷键,之所以可以触发,依赖于form里的IsShortCut来派发。
    ----------------------
    pagecontrol中的form和pagecontrol所在的form,你认为哪个会是active的?答案是后者,因此收到快捷键的是后者,而前者并没有收到,故不会触发。所以,你可能要自己再转发一次
      

  7.   

    Avan_Lau ,期待详解!谢谢!新手!
      

  8.   


    放入PageControl的窗体内的actionlist不与主窗体关联,与放入PageControl的窗体关联!未放入PageControl时,以窗体打开,可以使用actionlist!
      

  9.   

    刚刚查了源代码,与form是否active无关。官方也有说明此状况:
    The first part of the method is fairly straightforward: starting with the current control on line 9, the method walks up the parent chain and looks for a popup menu that is willing to accept the key as a shortcut. If there are no takers the method next asks the control’s host form (if it has one; the control may in fact be a form) whether it wants to process the key as a shortcut (line 21). TCustomform.IsShortcut is an interesting method in itself, since it offers us not one but two intervention points:IsShortcut is a virtual method, so we can override it in our form classes to customize the form’s shortcut handling. Doing it this way allows us to completely bypass the built-in shortcut handling on the form level, if that is needed, including the form’s OnShortcut event.The first thing IsShortcut does is to fire the form’s OnShortcut event. This event is typically used by application programmers to modify the standard shortcut handling of a form. If the event handler’s Handled parameter is set to true any subsequent processing for the key will be skipped.If there is no handler for the OnShortcut event, or Handled returns False (the default), the next party asked to handle the key is the form’s main menu, if it has one. If the key is still unprocessed after that it gets passed to a local procedure called DispatchShortCut. This procedure is used to recursively iterate over the form’s components, starting on the form level and drilling down the ownership hierarchy. If the component under investigation is an action list (a TCustomActionlist descendent) its IsShortcut method is called to allow it to examine the key. This is the mechanism used to trigger actions through their shortcuts. Since DispatchShortCut recursively enumerates all components it will also find action lists owned by frames or embedded forms, if they are owned by the form or another component owned by the form. This may not be the case for an embedded form.详细消息处理过程参考这里
      

  10.   

    把快捷鍵 處理 放在  onshortcut事件里處理,如何?
      

  11.   


    pagecontrol中的form有自己的快捷键。我是新手,一般是如何处理的?谢谢!
      

  12.   

    目的是将form放入pagecontrol,界面不乱,但放入后,from中的快捷键不起作用了,主窗体内的快捷键正常,如何解决,眺高手援手!
      

  13.   

    有看了我的那篇說明嗎?
    若這樣的兩個form,有快捷鍵的沖突。
    1、要么改快捷鍵;
    2、要么你 在pagecontrol所在的form接收到快捷鍵時,判斷當前的焦點是否在pagecontrol中的form上,若是則轉發(判斷時機可以在pagecontrol所在的form.onshutcut)
      

  14.   


    可以再具体些吗,pagecontrol中的form不止一个,多个,每一个上有自已的快捷键,虽然决大多数是一致的,但个别有差异。另如何转发(很弱弱)的?谢谢!
      

  15.   

    大致這么做,具體代碼看你的實際情況procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
      function GetMyParentForm(Control: TControl): TCustomForm;
      begin
        Result := nil;
        while Control.Parent <> nil do
        begin
          Control := Control.Parent;
          if Control is TCustomForm then
          begin
            Result := TCustomForm(Control);
            Break
          end
        end;
      end;
    var
      ParentForm : TCustomForm;
    begin
      ParentForm := GetMyParentForm(ActiveControl);//避免取到最底端的form,最近的才是我們想要的
      if (ActiveControl is TCustomForm) and
         (ActiveControl.Parent is TTabSheet) then//form的容器應該是你的tabsheet
      begin
        ParentForm.IsShortCut(Msg);//這里傳進去
      end;
    end;
      

  16.   

    改一下procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
      function GetMyParentForm(Control: TControl): TCustomForm;
      begin
        Result := nil;
        while Control.Parent <> nil do
        begin
          Control := Control.Parent;
          if Control is TCustomForm then
          begin
            Result := TCustomForm(Control);
            Break
          end
        end;
      end;
    var
      ParentForm : TCustomForm;
    begin
      ParentForm := GetMyParentForm(ActiveControl);//避免取到最底端的form,最近的才是我們想要的
      if ParentForm <> nil then
      begin
        if (ParentForm is TCustomForm) and
         (ParentForm.Parent is TTabSheet) then//form的容器應該是你的tabsheet
        begin
          ParentForm.IsShortCut(Msg);//這里傳進去
        end;
      end;
      

  17.   

    另,pagecontrol中form的keydown事件不能处理,有方案吗?谢谢!