I was reading the documentation of RegisterClassEx function and found that the return type of the function is ATOM
.
ATOM RegisterClassEx(CONST WNDCLASSEX *lpwcx);
While creating a window using CreateWindowEx
we can either pass the classname or开发者_开发知识库 ATOM Class in lpClassName.
So is there any significance of passing ATOM over classname ? or is it just an alternate way?
Thanks.
ATOM
is an alias to a string, like an index to a system array of strings. In the context of window classes, it's an alias to the class name.
So, it's just a different way of doing the same thing, but in theory this is more efficient.
Where I think ATOMs make more sense to use is in GetProp
/ SetProp
, where you may be looking up that string for every windows message processed. Maybe you can gain some performance by using an ATOM; anyway it's so easy to use that you might as well.
Interestingly, ATOMs tables are system-wide as well, so if two processes register a window class of the same name, they will receive the same ATOM value, even though the class info will be different.
Its just an alternate way. On Windows 3, where this API was introduced (if not Windows 2.x even) string compares were slow operations. The ATOM allowed the rather frequent creation of windows to go that much faster.
精彩评论