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 中设置的快捷键失灵了
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 中设置的快捷键失灵了
解决方案 »
- 电脑启动后不登录自动运行程序,只能写ServiceApplication吗?ServiceApplication中为何很多控件不能用?
- 怎么连接远程数据库。。
- 高分请教,如何实现自定义单据?
- 关于日期函数FormatDateTime的问题。
- delphi中如何使用dll
- 如何根据数据库的内容刷新treeview树形结构
- 所需數據庫連接文件!!!
- 为什么listview不能输入数据?有什么别的控件类似listview,但是能输入数据。
- sendmessage里的属性索引如何在msdn按功能和效果查找出来
- Delphi 类互相引用问题!有什么办法!?
- 在fastreport3脚本中如何让frxdataset滚动到下一行,
- 关于输入一个数的问题
keydown在edit中可以输入,但就是不对放入PageControl的窗体内的actionlist起作用,另主窗体的actionlist可以成功使用。
放入PageControl的窗体内的除actionlist外,如Enter处理可以完成,edit输入也没有问题,但快捷键就是不起作用,郁闷中!help!
主窗体的actionlist可以工作,去除后,也不行!
----------------------
pagecontrol中的form和pagecontrol所在的form,你认为哪个会是active的?答案是后者,因此收到快捷键的是后者,而前者并没有收到,故不会触发。所以,你可能要自己再转发一次
放入PageControl的窗体内的actionlist不与主窗体关联,与放入PageControl的窗体关联!未放入PageControl时,以窗体打开,可以使用actionlist!
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.详细消息处理过程参考这里
pagecontrol中的form有自己的快捷键。我是新手,一般是如何处理的?谢谢!
若這樣的兩個form,有快捷鍵的沖突。
1、要么改快捷鍵;
2、要么你 在pagecontrol所在的form接收到快捷鍵時,判斷當前的焦點是否在pagecontrol中的form上,若是則轉發(判斷時機可以在pagecontrol所在的form.onshutcut)
可以再具体些吗,pagecontrol中的form不止一个,多个,每一个上有自已的快捷键,虽然决大多数是一致的,但个别有差异。另如何转发(很弱弱)的?谢谢!
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;
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;