请注意:本页内容发布于 1716 天前,内容可能已经过时,请注意甄别。
原文链接:https://devblogs.microsoft.com/oldnewthing/20050207-00/?p=36513
You may have noticed that the numerical value of the DS_SHELLFONT flag is equal to DS_FIXEDSYS | DS_SETFONT.
你可能曾注意到 DS_SHELLFONT 这个 flag 的数字值是与 DS_FIXEDSYS | DS_SETFONT 相同的。
#define DS_SETFONT 0x40L /* 用于对话框控件的用户指定字体 */
#define DS_FIXEDSYS 0x0008L
#define DS_SHELLFONT (DS_SETFONT | DS_FIXEDSYS)
Surely that isn’t a coincidence.
这当然不是巧合。
The value of the DS_SHELLFONT flag was chosen so that older operating systems (Windows 95, 98, NT 4) would accept the flag while nevertheless ignoring it.
DS_SHELLFONT 这个 flag 的值这样设计,是为了让旧版操作系统(Windows 95、98、NT 4)可以接受这个值的同时忽略它。
This allowed people to write a single program that got the “Windows 2000” look when running on Windows 2000 and got the “classic” look when running on older systems. (If you make people have to write two versions of their program, one that runs on all systems and one that runs only on the newer system and looks slightly cooler, they will usually not bother writing the second one.)
这样的设计,使得人们可以在编写程序时,一次性做到程序在 Windows 2000 下运行时获得『Windows 2000 样式』的同时,在旧版系统上运行时获得『经典样式』。(如果你非要人们编写两个版本的程序,一个可以在所有版本的系统上运行,但另一个只是在新版系统上运行时看上去漂亮一些的话,估计人们根本就不会考虑去写后一个版本。)
The DS_FIXEDSYS flag met these conditions. Older systems accepted the flag since it was indeed a valid flag, but they also ignored it because the DS_SETFONT flag takes precedence.
DS_FIXEDSYS 这个 flag 就可以同时适应这两种情况。旧版系统可以接受这个值,因为它的确是个有效的 flag,但同时也会忽略它,因为 DS_SETFONT 这个 flag 会被优先使用。
This is one of those backwards-compatibility exercises: How do you design something so that it is possible to write one program that gets the new features on new systems while at the same time degrading gracefully on old systems?
这就是向下兼容措施的其中之一:如何设计一种机制,使得只需撰写一个版本的程序,便可以在新系统上获得新功能,同时又在旧系统上可以优雅地降级呢?
远嚣 Comment