Showing tag results for Code

Dec 19, 2008
Post comments count0
Post likes count1

What is the mysterious fourth message box button?

Raymond Chen
Raymond Chen

When you call the MessageBox function, you pass flags specifying which of a fixed set of button patterns you want (for example, Yes/No and OK/Cancel) and which button you want to be the default (MB_DEFBUTTON1 through MB_DEFBUTTON4.) Wait a second. What's with this MB_DEFBUTTON4? None of the button patterns are four-button patterns. The highest n...

Code
Dec 18, 2008
Post comments count0
Post likes count1

How do I obtain the computer manufacturer’s name?

Raymond Chen
Raymond Chen

One customer wanted a way to determine the name of the computer manufacturer. For example, they wanted to make some function call and get back "IBM" or "Compaq" or "Dell". I don't know why they wanted this information, and for the moment, I don't care. And of course, when you're looking for information, you don't search MSDN; that's for crazy pe...

Code
Dec 11, 2008
Post comments count0
Post likes count1

Don’t use global state to manage a local problem

Raymond Chen
Raymond Chen

We've seen a few instances where people have used a global setting to solve a local problem. For example, people who use the function to prevent a window from redrawing, toggle a global setting to see what its value is, or who change the system time zone as part of an internal calculation. To this, I'll add as an example a program which figures...

Code
Nov 28, 2008
Post comments count0
Post likes count1

Just because a method is called Refresh doesn’t mean that it refreshes what you want

Raymond Chen
Raymond Chen

Here's a question from a customer: I made some changes related to my shell extension [details omitted], but the changes don't show up in the Explorer window when I refresh it. Any suggestions on how to solve this problem? When we asked how they were refreshing the Explorer window, we were expecting something like pressing F5 or calling with ,...

Code
Nov 24, 2008
Post comments count0
Post likes count1

Consequences of the Explorer view model: If you create a view, then you succeeded, even if you’d rather fail

Raymond Chen
Raymond Chen

Commenter Anonymous asked why navigating to a drive with no media displays a dialog instead of showing the error message in the view. This is an unfortunate consequence of Explorer's browser/view model. The shell browser binds to the and asks for the view by calling . The view window calls to figure out what to show in the view—and here ...

Code
Nov 17, 2008
Post comments count0
Post likes count1

Why bother with RegisterWaitForSingleObject when you have MsgWaitForMultipleObjects?

Raymond Chen
Raymond Chen

Commenter kokorozashi wonders why you should bother with when you have already. If you want to pump messages and wait for a kernel object, then you can change all calls to , , and to replacement functions that use . Isn't that enough? Why waste an entire thread just to wait for that object? If you're so clever that you can modify every call t...

Code
Nov 6, 2008
Post comments count0
Post likes count1

Does version 6 of the common controls support ANSI or not?

Raymond Chen
Raymond Chen

I mentioned in passing a few years ago that version 6 of the common controls supports only Unicode. And then other people stepped in to say, "Well, XYZ uses ANSI and that works for me." So does it support ANSI or doesn't it? It does and doesn't. All of the controls in the common controls library are internally Unicode. But not all controls in...

Code
Nov 3, 2008
Post comments count0
Post likes count1

If there’s already a bug, it’s not surprising that there’s a possibility for error

Raymond Chen
Raymond Chen

It's great to think about all the things that can go wrong but you also have to think about the situations that could lead to those bad things. In particular, you have to recognize when you are trying to avoid a bug that is ultimately outside your component and which you can't fix anyway. For example, consider this multithreaded race condition: ...

Code
Oct 31, 2008
Post comments count0
Post likes count1

Working with ambiguous and invalid points in time in managed code

Raymond Chen
Raymond Chen

Public Service Announcement: Daylight Saving Time ends in most parts of the United States this weekend. I pointed out some time ago that Win32 and .NET deal with daylight saving time differently. Specifically, Win32 always deals with the time zone you are currently in (even if it's not the time zone that corresponds to the timestamp you are mani...

CodeTime