原文链接:https://devblogs.microsoft.com/oldnewthing/20060410-17/?p=32703
Last time, we saw one example of a “decoy” used in the service of application compatibility with respect to the Printers Control Panel. Today we’ll look at another decoy, this time for the Display Control Panel.
在上次的文章中,我们介绍了与打印机控制面板的有关的、一个为应用程序兼容性而设的“诱饵”控制面板的案例。今天我们来讲另一个案例,这次是为了显示(属性)控制面板的。
When support for multiple monitors was being developed, a major obstacle was that a large number of display drivers hacked the Display Control Panel directly instead of using the documented extension mechanism. For example, instead of adding a separate page to the Display Control Panel’s property sheet for, say, virtual desktops, they would just hack into the “Settings” page and add their button there. Some drivers were so adventuresome as to do what seemed like a total rewrite of the “Settings” page. They would take all the controls, move them around, resize them, hide some, show others, add new buttons of their own, and generally speaking treat the page as a lump of clay waiting to be molded into their own image. (Here’s a handy rule of thumb: If your technique works only if the user speaks English, you probably should consider the possibility that what you’re doing is relying on an implementation detail rather than something that will be officially supported going forward.)
早先开发多显示器支持的时候,我们遇到的一大问题是有为数众多的显示驱动程序是直接“黑”进显示控制面板(做修改)的,而没有使用文档中给出的扩展机制。
例如,某款驱动可能没有选择在显示控制面板的属性页里多加一页的方式,来增加对诸如虚拟桌面之类功能的支持,而是选择直接“黑”进显示控制面板的“设置”页面,然后在里面加上一个按钮。有些选手则更是重量级,选择干脆把整个“设置”页面重写一遍,把所有的控件挪来挪去、放大缩小、藏起这个、显示那个,再把自家的按钮大大方方地摆上台面。
基本上,这些驱动拿着“设置”页面当成了一块粘土,爱怎么揉全看它们自己的喜好。(这里有一条经验法则:如果你的做法只在用户的语言是英语的前提下才会起效,那你多半应该考虑你的所作所为是依赖实现细节、而不是会得到官方支持的做法。)
In order to support multiple monitors, the Settings page on the Display Control Panel underwent a major overhaul. But when you tried to open the Display Control Panel on a system that had one of these aggressive drivers installed, it would crash because the driver ran around rearranging things like it always did, even though the things it was manipulating weren’t what the developers of the driver intended!
为了开发多显示器支持,“设置”页面经历了大量的重构。但(在这之后,)如果你尝试在安装了上文所述的那种激进派驱动的系统上尝试打开显示控制面板的时候,页面会崩溃,因为那些驱动还在照例跑进控制面板里去大闹天宫,却发现他们要改造的那个世界已经不是那样了!
The solution was to create a “decoy” Settings page that looked exactly like the classic Windows 95 Settings page. The decoy page’s purpose in life was to act as bait for these aggressive display drivers and allow itself to be abused mercilessly, letting the driver have its way. Meanwhile, the real Settings page (which is the one that was shown to the user), by virtue of having been overlooked, remained safe and unharmed.
(对此的)解决方案是造一个跟 Windows 95 传统的(显示控制面板)设置页面一样的“诱饵”页面,它的存在意义则是当成香饽饽,让那些激进派驱动们进去按自己的想法大闹一番,同时又确保躲过一劫的、真正向用户展示的设置页面安然无恙。
There was no attempt to make this decoy Settings page do anything interesting at all. Its sole job was to soak up mistreatment without complaining. As a result, those drivers lost whatever nifty features their shenanigans were trying to accomplish, but at least the Display Control Panel stayed alive and allowed the user to do what they were trying to do in the first place: Adjust their display settings.
作诱饵的那个设置页面,除了默默承受驱动的胡搅蛮缠之外什么用处也没有。最后的结果是,驱动们想要通过诡计实现的那些花哨功能一个也没有展现出来,但至少(真正的)显示控制面板好好地活了下来,使用户得以实现它们本来的愿望:修改显示设置。
当年驱动厂家自己在Windows控制面板上套皮,
如今Microsoft自己在Windows控制面板上套皮。