Welcome to MSDN Blogs Sign in | Join | Help

February 2004 - Posts

The correct order for disabling and enabling windows

If you want to display modal UI, you need to disable the owner and enable the modal child, and then reverse the procedure when the modal child is finished. And if you do it wrong, focus will get all messed up. If you are finished with a modal dialog,
Posted by oldnewthing | 42 Comments
Filed under:

Why do timestamps change when I copy files to a floppy?

Floppy disks use the FAT filesystem, as do DOS-based and Windows 95-based operating systems. On the other hand, Windows NT-based systems (Windows 2000, XP, 2003, ...) tend to use the NTFS filesystem. (Although you can format a drive as FAT on Windows
Posted by oldnewthing | 17 Comments
Filed under: ,

Why can't I put hotlinks in notification icon balloon tips?

The short answer: "Because there is no NIF_PARSELINKS flag." The long answer: When balloon tips were first developed, there was no ability to embed links. Consequently, programs were free to put insecure text in balloon tips, since there was no risk that
Posted by oldnewthing | 34 Comments
Filed under:

What's so special about the desktop window?

The window returned by GetDesktopWindow() is very special, and I see people abusing it all over the place. For example, many functions in the shell accept a window handle parameter to be used in case UI is needed. IShellFolder::EnumObjects , for example.
Posted by oldnewthing | 26 Comments
Filed under:

Invalid thread and process IDs

Perhaps you want a value to use as a sentinel, which you want to be guaranteed is never a valid thread ID or process ID. What values can you use? Nothing is explicitly written about this topic, but you can put on your logic cap and figure it out. If you
Posted by oldnewthing | 21 Comments
Filed under:

And we will build a processor with... ONE MILLION TRANSISTORS!

A friend of mine decided to recaption this picture which is in the rotation on Intel's Hardware Design Home Page : "And we will build a processor with... ONE MILLION TRANSISTORS!" Who knew that Dr. Evil designed CPUs, too!
Posted by oldnewthing | 14 Comments
Filed under:

Raymond's comment policy

Okay, I was hoping it wasn't going to be needed but it takes only one bad apple... Here are the ground rules. I reserve the right to edit, delete, or ignore any comment. If I edit your comment in any significant way, I promise to make that fact clear
Posted by oldnewthing | 8 Comments
Filed under:

Why do I get a QueryInterface(IID_IMarshal) and then nothing?

A common problem when trying to get your new COM object off the ground is that you can't seem to be able to get it created. The object comes out of the class factory, and it gets a QueryInterface for IMarshal, and then nothing. What's going on? This is
Posted by oldnewthing | 8 Comments
Filed under:

Sorry the posts are late lately

Somehow the server is in a wonky state and my autopilot script that posts a new article at 7 every morning is getting error 500 back (internal server error). So I'm posting manually for the nonce. Expect erratic posting times until the problem is resolved
Posted by oldnewthing | 11 Comments
Filed under:

No code is an island

Norman Diamond noted in a comment that on Windows 2003 Server, the Display Adapter Troubleshooting slider still lists "full acceleration" as the recommended setting even though the default for Server is "full minus one". This is one of those "Oh, that's
Posted by oldnewthing | 13 Comments
Filed under:

Why are RECTs endpoint-exclusive?

Endpoint-exclusive RECTs and lines are much easier to work with. For example, the width of a rectangle is right - left , and its height is bottom - top . If rectangles were endpoint-inclusive, then there would be annoying +1's everywhere. End-point exclusive
Posted by oldnewthing | 38 Comments
Filed under:

GetDialogBaseUnits is a crock

There are two functions that let you convert dialog units (DLUs) to pixels. One is GetDialogBaseUnits , which returns the base units directly (leaving you to do the math), and another is MapDialogRect , which takes a rectangle in DLUs and returns a rectangle
Posted by oldnewthing | 27 Comments
Filed under:

The social skills of a thermonuclear device

Somebody@somewhere.else described me as having the social skills of a thermonuclear device . I don't remember the incident in question, but I'll have to accept that it happened. I have a very low tolerance for laziness. If you come to me for help, I expect

The arms race between programs and users

There is a constant struggle between people who write programs and the people who actually use them. For example, you often see questions like, "How do I make my program so the user can't kill it?" Now, imagine if there were a way to do this. Ask yourself,
Posted by oldnewthing | 69 Comments
Filed under:

So what's to do in Sweden?

Here is where Raymond gets to abuse his power as a blogger to get some free travel advice. I will likely travel to Sweden in mid-March, with a whopping total of five months of Swedish under my belt. I'm sure I will embarrass myself horribly, but that's
Posted by oldnewthing | 104 Comments
Filed under:

The Seattle Improbable Show (2004)

An overflow crowd attended The Seattle Improbable Show . It was, as expected, a rollicking good time. Mark Abrahams emceed and gave presentations, one on each of last year's Ig Nobel Prize winners , another chronicling various stages in the development
Posted by oldnewthing | 0 Comments
Filed under:

Bad version number checks

Version numbers. Very important. And so many people check them wrong. This is why Windows 95's GetVersion function returned 3.95 instead of 4.0. A lot of code checked the version number like this: UINT Ver = GetVersion(); UINT MajorVersion = LOBYTE(uVer);
Posted by oldnewthing | 33 Comments
Filed under:

Stories of going through airport security

I went through security three times at Seattle-Tacoma International Airport before my flight to Newark . My original flight was cancelled due to inclement weather in Newark , so I get rescheduled onto another flight that arrived three hours later. I thought
Posted by oldnewthing | 13 Comments
Filed under:

TEXT vs. _TEXT vs. _T, and UNICODE vs. _UNICODE

So what's with all these different ways of saying the same thing? There's actually a method behind the madness. The plain versions without the underscore affect the character set the Windows header files treat as default. So if you define UNICODE, then
Posted by oldnewthing | 40 Comments
Filed under:

Improbable Research comes to Seattle

The lunatics behind The Annals of Improbable Research and The Ig Nobel Prize will be in Seattle tomorrow night, Feburary 13 . The meeting schedule lists the AIR presentation as "8:00PM-10:30PM, Special Event: Annals of Improbable Research (open to all
Posted by oldnewthing | 1 Comments
Filed under:

Sure, we do that

The DirectX video driver interface for Windows 95 had a method that each driver exposed called something like "DoesDriverSupport(REFGUID guidCapability)" where we handed it a capability GUID and it said whether or not that feature was supported. There
Posted by oldnewthing | 50 Comments
Filed under:

Dunkin Donuts vs. Krispy Kreme

Having grown up on the east coast, I imprinted on Dunkin Donuts . Once a month we would stop at DD on the way home and buy a shoebox of doughnuts. Toasted coconut and butternut, those were my favorites. Ironically, Dunkin Donuts is really a coffee shop
Posted by oldnewthing | 70 Comments
Filed under:

Answer to exercise: Pointer to member function cast

Yesterday's exercise asked you to predict and explain the codegen for the following fragment: class Base1 { int b1; void Base1Method(); }; class Base2 { int b2; void Base2Method(); }; class Derived : public Base1, Base2 { int d; void DerivedMethod();
Posted by oldnewthing | 3 Comments
Filed under:

Orkut's privacy policy and terms of service

It was bound to happen sooner or later. I was invited to join Orkut. But before clicking Submit, I always read the fine print: their Terms of Service and their Privacy Policy . (Oh great, you have to have scripting enabled just to read their Terms of
Posted by oldnewthing | 23 Comments
Filed under:

I think this counts as having come full circle

First, A B BA rises to stardom in their native Sweden with Ring, Ring . They then win the Eurovision Song Contest with Waterloo , which is also recorded in English, French, German, and probably Spanish. Twenty-five years later, the English-language musical
Posted by oldnewthing | 4 Comments
Filed under:

Pointers to member functions are very strange animals

Pointers to member functions are very strange animals. Warning : The discussion that follows is specific to the way pointers to member functions are implemented by the Microsoft Visual C++ compiler. Other compilers may do things differently. Well, okay,
Posted by oldnewthing | 19 Comments
Filed under:

Adjustor thunks

Yesterday we learned about the layout of COM objects and I hinted at "adjustor thunks". If you find yourself debugging in disassembly, you'll sometimes find strange little functions called "adjustor thunks". Let's take another look at the object we laid
Posted by oldnewthing | 15 Comments
Filed under:

The layout of a COM object

The Win32 COM calling convention specifies the layout of the virtual method table (vtable) of an object. If a language/compiler wants to support COM, it must lay out its object in the specified manner so other components can use it. It is no coincidence
Posted by oldnewthing | 39 Comments
Filed under:

Answers to exercises - mismatching new/delete

Answers to yesterday's exercises : What happens if you allocate with scalar "new" and free with vector "delete[]" ? The scalar "new" will allocate a single object with no hidden counter. The vector "delete[]" will look for the hidden counter, which isn't
Posted by oldnewthing | 13 Comments
Filed under:

The Glass Engine and Ishkur's Guide to Electronic Music

The Glass Engine is an interactive guide to the music of Philip Glass, organized by... um... at least they're organized. By something. Bizarre yet oddly compelling. (Perhaps if we ask nicely, we can get Marc Miller to tell the story of the time he actually
Posted by oldnewthing | 4 Comments
Filed under:

Mismatching scalar and vector new and delete

In a previous entry I alluded to the problems that can occur if you mismatch scalar "new" with vector "delete[]" or vice versa. There is a nice description of C++ memory management in C++ Gotchas: Avoiding Common Problems in Coding and Design on www.informit.com
Posted by oldnewthing | 16 Comments
Filed under:

The management of memory for resources in 16-bit Windows

In a previous entry I threatened to discuss the way resources were managed in 16-bit Windows. In 16-bit Windows, resources were not loaded until explicitly requested. The FindResource function located the entry for the resource in the resource directory
Posted by oldnewthing | 13 Comments
Filed under:

What goes wrong when you add "Copy To" to the context menu

Lockergnome tipped people off to this page which talks (among other things) about adding "Copy To" to the context menu . I considered adding this tweak to Tweak UI but ultimately decided against. Here's why: The "Copy to Folder" and "Move to Folder" options
Posted by oldnewthing | 17 Comments
Filed under:
 
Page view tracker