Showing tag results for Code

Jan 6, 2006
Post comments count0
Post likes count0

Why do image lists and tool bars use horizontal strips if vertical is so much better?

Raymond Chen
Raymond Chen

Two people pointed out that the function and toolbars use horizontal strips even though we learned that vertical strips are much more efficient. While it's true that the images are passed to the and functions in horizontal strips, the image list and toolbar code copy them to a vertical strip. In other words, the horizontal strip is merely an...

Code
Jan 5, 2006
Post comments count0
Post likes count0

Converting between LCIDs and RFC 1766 language codes

Raymond Chen
Raymond Chen

Occasionally, I see someone ask for a function that converts between LCIDs (such as 0x0409 for English-US) and RFC 1766 language identifiers (such as "en-us"). The rule of thumb is, if it's something a web browser would need, and it has to do with locales and languages, you should look in the MLang library. In this case, the IMultiLanguage:...

Code
Jan 4, 2006
Post comments count0
Post likes count0

Taxes: Detecting session state changes, such as a locked workstation

Raymond Chen
Raymond Chen

Another developer tax is playing friendly with Fast User Switching and Terminal Services. When the workstation is locked or disconnected, you should turn off non-essential timers, minimize background activities, and generally send your program into a quiet state. If you already used the technique of painting only when your window is visible on th...

Code
Jan 3, 2006
Post comments count0
Post likes count0

Taxes: Remote Desktop Connection and painting

Raymond Chen
Raymond Chen

An increasingly important developer tax is supporting Remote Desktop Connection properly. When the user is connected via a Remote Desktop Connection, video operations are transferred over the network connection to the client for display. Since networks have high latency and nowhere near the bandwidth of a local PCI or AGP bus, you need to adapt to...

Code
Jan 3, 2006
Post comments count0
Post likes count0

The world's slowest RET instruction

Raymond Chen
Raymond Chen

Occasionally, somebody will ask I'm debugging a hang, and I see that many threads are stuck at a RET instruction. When I try to trace one instruction from that thread, the trace breakpoint never fires. It's as if the RET instruction itself is wedged! I've found the world's slowest RET instruction. (A common variation on this theme is that the th...

Code
Jan 3, 2006
Post comments count0
Post likes count0

On the abuse of properties

Raymond Chen
Raymond Chen

One thing that I see occasionally is the abuse of property syntax. IDispatch and CLR objects (and C++ objects if you want to avail yourself of a Microsoft-specific extension) support "properties", which syntactically look like fields but internally are treated as a pair of methods ("get" and "put"). An important principle is that given an object ...

Code
Jan 3, 2006
Post comments count0
Post likes count0

There's more to calling a function than just getting the types to match

Raymond Chen
Raymond Chen

Here's a classic novice error. You want to call a function, say GetBinaryType. What should you write for those question marks? Well, the prototype says that the second parameter is an LPDWORD, so let's pass it one. Hm, but that crashes. Well, maybe we can pass it an LPDWORD this way: Hm, that still crashes. Oh wait, it's because of the...

Code
Dec 14, 2005
Post comments count0
Post likes count0

On the ambiguity of uniqueness

Raymond Chen
Raymond Chen

The MSDN documentation for says [T]he implementation of GetHashCode provided by the String class returns unique hash codes for unique string values. This is another case of ambiguous use of the word "unique". The intended meaning is "for each string value, the same hash code is returned". Even though "unique" means "one and only one", the...

Code
Dec 12, 2005
Post comments count0
Post likes count0

Your debugging code can be a security hole

Raymond Chen
Raymond Chen

When you're developing your debugging code, don't forget that just because it's only for debugging doesn't mean that you can forget about security. I remember one customer who asked (paraphrased) We have a service, and for testing purposes we want to be able to connect to this service and extract the private data that the service is managing, ...

Code
Nov 29, 2005
Post comments count0
Post likes count0

Taxes: Geopolitics

Raymond Chen
Raymond Chen

One frequently-overlooked software "tax" is geopolitics. We've alread seen that the time zone and regional settings dialogs created international unrest. It appears that Google Maps failed to recognize the extremely sensitive issue of naming the body of water that lies between Korea and Japan, as well as stirring up international tensions with ...

Code