如果我尝试使用 TRibbonCombobox 更改功能区样式,则会发生访问冲突

发布于 2024-08-06 17:05:53 字数 2665 浏览 3 评论 0原文

如果我尝试使用 TRibbonCombobox 更改功能区样式,则会出现访问冲突。

然后,我修改了delphi功能区演示以提供一个组合框方法来设置样式:

  1. 在功能区栏上添加了一个TRibbonCombobox
  2. 添加了一个事件处理程序

这里是事件代码:

procedure TfrmRibbonDemo.RibbonComboBox1Change(Sender: TObject);

begin

  if RibbonComboBox1.Text='Luna' then

    Ribbon1.Style:=RibbonLunaStyle

    else

    Ribbon1.Style:=RibbonSilverStyle;

end;

当我使用TRibbonCombobox更改样式(尤其是多次)时,我得到:

date/time         : 2009-10-02, 11:11:29, 843ms
operating system  : Windows XP Service Pack 3 build 2600
physical memory   : 583/2047 MB (free/total)
free disk space   : (C:) 71.72 GB
display mode      : 1280x1024, 32 bit
allocated memory  : 23.59 MB
executable        : RibbonDemo.exe
exec. date/time   : 2009-10-02 11:11
compiled with     : Delphi 2009
madExcept version : 3.0k
exception class   : EAccessViolation
exception message : Access violation at address 0054767C in module 'RibbonDemo.exe'. Read of address 0000005F.

main thread ($ed0):
0054767c +054 RibbonDemo.exe RibbonActnCtrls           TCustomRibbonComboBox.SetBounds
00546e52 +0a2 RibbonDemo.exe RibbonActnCtrls           TRibbonComboControl.SetBounds
00516f39 +0f1 RibbonDemo.exe ActnMan                   TCustomActionControl.CalcBounds
0051853d +005 RibbonDemo.exe ActnCtrls                 TCustomButtonControl.CalcBounds
00546482 +00a RibbonDemo.exe RibbonActnCtrls           TRibbonComboControl.CalcBounds
00516754 +030 RibbonDemo.exe ActnMan                   TCustomActionControl.SetSpacing
0051a243 +01b RibbonDemo.exe ActnCtrls                 TCustomActionToolBar.CreateControl
00557f16 +01a RibbonDemo.exe Ribbon                    TCustomActionControlBar.CreateControl
0056205a +006 RibbonDemo.exe Ribbon                    TCustomRibbonGroup.CreateControl
0051243f +087 RibbonDemo.exe ActnMan                   TCustomActionBar.CreateControls
00519b35 +005 RibbonDemo.exe ActnCtrls                 TCustomActionDockBar.CreateControls
0051a2c6 +022 RibbonDemo.exe ActnCtrls                 TCustomActionToolBar.CreateControls
00557fcb +027 RibbonDemo.exe Ribbon                    TCustomActionControlBar.CreateControls
00562075 +005 RibbonDemo.exe Ribbon                    TCustomRibbonGroup.CreateControls
00514542 +05e RibbonDemo.exe ActnMan                   TCustomActionBar.RecreateControls
0050e081 +04d RibbonDemo.exe ActnMan                   TCustomActionManager.SetStyle
0055dac3 +02f RibbonDemo.exe Ribbon                    TCustomRibbon.SetStyle
0056720c +04c RibbonDemo.exe RibbonDemoMainForm 387 +3 TfrmRibbonDemo.RibbonComboBox1Change

如果我使用功能区栏上的按钮进行样式更改,它就可以正常工作。

感谢您的帮助!

i get an Access Violation if i try to change the ribbon style using a TRibbonCombobox.

then, i modified the delphi ribbon demo to provide a combobox method to set the style:

  1. added a TRibbonCombobox on the ribbon bar
  2. added an event handler

here is the event code:

procedure TfrmRibbonDemo.RibbonComboBox1Change(Sender: TObject);

begin

  if RibbonComboBox1.Text='Luna' then

    Ribbon1.Style:=RibbonLunaStyle

    else

    Ribbon1.Style:=RibbonSilverStyle;

end;

when i change the style (especially more than once) with the TRibbonCombobox, i get:

date/time         : 2009-10-02, 11:11:29, 843ms
operating system  : Windows XP Service Pack 3 build 2600
physical memory   : 583/2047 MB (free/total)
free disk space   : (C:) 71.72 GB
display mode      : 1280x1024, 32 bit
allocated memory  : 23.59 MB
executable        : RibbonDemo.exe
exec. date/time   : 2009-10-02 11:11
compiled with     : Delphi 2009
madExcept version : 3.0k
exception class   : EAccessViolation
exception message : Access violation at address 0054767C in module 'RibbonDemo.exe'. Read of address 0000005F.

main thread ($ed0):
0054767c +054 RibbonDemo.exe RibbonActnCtrls           TCustomRibbonComboBox.SetBounds
00546e52 +0a2 RibbonDemo.exe RibbonActnCtrls           TRibbonComboControl.SetBounds
00516f39 +0f1 RibbonDemo.exe ActnMan                   TCustomActionControl.CalcBounds
0051853d +005 RibbonDemo.exe ActnCtrls                 TCustomButtonControl.CalcBounds
00546482 +00a RibbonDemo.exe RibbonActnCtrls           TRibbonComboControl.CalcBounds
00516754 +030 RibbonDemo.exe ActnMan                   TCustomActionControl.SetSpacing
0051a243 +01b RibbonDemo.exe ActnCtrls                 TCustomActionToolBar.CreateControl
00557f16 +01a RibbonDemo.exe Ribbon                    TCustomActionControlBar.CreateControl
0056205a +006 RibbonDemo.exe Ribbon                    TCustomRibbonGroup.CreateControl
0051243f +087 RibbonDemo.exe ActnMan                   TCustomActionBar.CreateControls
00519b35 +005 RibbonDemo.exe ActnCtrls                 TCustomActionDockBar.CreateControls
0051a2c6 +022 RibbonDemo.exe ActnCtrls                 TCustomActionToolBar.CreateControls
00557fcb +027 RibbonDemo.exe Ribbon                    TCustomActionControlBar.CreateControls
00562075 +005 RibbonDemo.exe Ribbon                    TCustomRibbonGroup.CreateControls
00514542 +05e RibbonDemo.exe ActnMan                   TCustomActionBar.RecreateControls
0050e081 +04d RibbonDemo.exe ActnMan                   TCustomActionManager.SetStyle
0055dac3 +02f RibbonDemo.exe Ribbon                    TCustomRibbon.SetStyle
0056720c +04c RibbonDemo.exe RibbonDemoMainForm 387 +3 TfrmRibbonDemo.RibbonComboBox1Change

if i make a style change with a button on the ribbon bar, it works fine.

thank you for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

活泼老夫 2024-08-13 17:05:53

您正在修改功能区的样式,这也会修改触发事件的组合框。

为了使其发挥作用,编程接口必须是“可重入的”,而功能区系统显然不是。

有几种可能的解决方案:

  • 不要从功能区修改功能区,将配置 GUI 移至其他位置。
  • 让组合框将所需的操作存储在某处,并触发另一个事件,该事件将在组合框事件终止后执行。例如,您可以设置一个非常小的间隔(1)的 TTimer,然后在组合框事件中启用该计时器,这样当触发 TTimer 事件时,功能区系统可以根据新的选择进行修改,而不需要可重入 API。

You are modifying the styles of the ribbon, which also modifies the combobox that triggers the event.

In order for this to work, a programming interface must be "re-entrant", and the ribbon system obviously isn't.

There are several possible solutions:

  • Do not modify the ribbon from a ribbon, move the configuration GUI to somewhere else.
  • Make the combobox store the desired action somewhere and trigger another event that will be executed after the termination of your combobox event. For instance, you can set a TTimer with a very small interval (1), and then enable that timer in the combobox event, so that when the TTimer event is fired, the ribbon system can be modified according to the new choice without requiring a reentrant api.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文