The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Microspeak: The plate
Apr 14, 2009
Post comments count 0
Post likes count 0

Microspeak: The plate

Raymond Chen
Raymond Chen

To have a lot on one's plate means to have a lot of tasks and responsibilities. We shouldn't give this task to Bob. He already has a lot on his plate. (Or: He already has a full plate.) At Microsoft, this common English language idiom is treated as a normal part of the language. The metaphorical plate has become a synonym for assigned tasks and responsibilities and can be used as a basis for new idioms. That feature moved off their plate onto ours. Feature X got postponed to the next release, so there's room on our plate for Feature Y. Update: Apparently there are some people who believe ...

Why is there no support in the window manager for mouse button chording?
Apr 13, 2009
Post comments count 0
Post likes count 0

Why is there no support in the window manager for mouse button chording?

Raymond Chen
Raymond Chen

Commenter Nekto2 asks why there is no mouse action associated with "click both buttons at the same time". The window manager doesn't fire a special event for both mouse buttons held down simultaneously like it does for double-clicks. As with higher-order clicks, mouse chording is something that you have to put together yourself from the basic mouse events that the window manager generates. Add these lines to our scratch program: void OnButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) { if ((keyFlags & (MK_LBUTTON | MK_RBUTTON)) == (MK_LBUTT...

When people ask to disable drag and drop, they often are trying to disable accidental drag and drop
Apr 10, 2009
Post comments count 0
Post likes count 0

When people ask to disable drag and drop, they often are trying to disable accidental drag and drop

Raymond Chen
Raymond Chen

We occasionally get customers who ask, "How do I disable drag and drop?" This is an odd request, so we ask the frequent follow-up question, "What are you really trying to do?" For many of these customers, the answer goes something like this: We've found that our employees often accidentally move or copy items around on the desktop and in Explorer windows because the act of pressing the mouse button causes the mouse itself to slide slightly across the table, resulting in a drag operation instead of a single click. We then have to spend a good amount of time searching for where those files ended up and trying to ...

Being able to call a function without using GetProcAddress is not a security vulnerability
Apr 9, 2009
Post comments count 0
Post likes count 0

Being able to call a function without using GetProcAddress is not a security vulnerability

Raymond Chen
Raymond Chen

Another genre in the sporadic category of dubious security vulnerability is people who find an unusual way of accomplishing something perfectly normal but declare it a security vulnerability because they found an unusual way of doing it. Security is important to all computers users, from families at home to employees of government agencies, and people who use Microsoft Windows are no exception. Trojans, backdoors, and spyware (collectively known as malware) have taken many forms, most recently those of so-called rootkits, which modify the operating system itself in order to prevent their detection. Firewalls a...

Let GDI do your RLE compression for you
Apr 8, 2009
Post comments count 0
Post likes count 0

Let GDI do your RLE compression for you

Raymond Chen
Raymond Chen

This is another trick along the lines of using DIB sections to perform bulk color mapping. GDI will do it for you; you just have to know how to ask. Today's mission is to take a 4bpp bitmap and compress it in BI_RLE4 format. Now, sure, there are programs out there which already do this conversion, but the lesson is in the journey, not in the destination. The secret is the GetDIBits function. You give this function a bitmap and a bitmap format, and out come the bits in the format you requested; GDI will convert as necessary. Note: I'm going to take a risk and write "sloppy" code. This is code that is not pro...

Clap and the filter graph claps with you
Apr 7, 2009
Post comments count 0
Post likes count 0

Clap and the filter graph claps with you

Raymond Chen
Raymond Chen

One of my colleagues was a fount of ideas, some of them crazy, some of them clever, and some of them both. I think this one counts as both. To render multimedia content with DirectShow, you build a so-called filter graph. A filter graph represents a series of transformations that are applied to data as it travels through the graph. For example, bytes from a video file may go through a splitter filter which separates the audio from the video data, then the two data streams each go through a respective audio and video decoder, which converts the compressed data into uncompressed sound or video data, and then to a...

There’s nothing wrong with making bold treeview items
Apr 6, 2009
Post comments count 0
Post likes count 0

There’s nothing wrong with making bold treeview items

Raymond Chen
Raymond Chen

Commenter Frans Bouma asks, Why is the text of a treenode chopped off when you switch the font from normal to bold? It apparently is for backwards compatibility but I fail to see why this is necessary for backward compatibility... Actually, bold treeview items work just fine. Watch: Start with our scratch program and make these changes: BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpcs) { g_hwndChild = CreateWindow( WC_TREEVIEW, NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT, 0, 0, 0, 0, hwnd, (HMENU)1, g_hinst, 0); TVINSERTSTRUCT tvis; ...

On the almost-feature of floppy insertion detection in Windows 95
Apr 3, 2009
Post comments count 0
Post likes count 0

On the almost-feature of floppy insertion detection in Windows 95

Raymond Chen
Raymond Chen

Gosh, that floppy insertion article generated a lot of comments. First, to clarify the table: The table is trying to say that if you had a Style A floppy drive, then issuing the magic series of commands would return 1 if a floppy was present, or 0 if the floppy was not present. On the other hand, if you had a Style B floppy drive, then issuing the magic series of commands would return 0 if a floppy was present, or 1 if the floppy was not present. That's what I was trying to say in the table. The answer was consistent within a floppy style, but you first had to know what style you had. The downsid...

Windows 95 almost had floppy insertion detection but the training cost was prohibitive
Apr 2, 2009
Post comments count 0
Post likes count 0

Windows 95 almost had floppy insertion detection but the training cost was prohibitive

Raymond Chen
Raymond Chen

One feature which Windows 95 almost had was floppy disk insertion detection. In other words, Windows 95 almost had the ability to detect when a floppy disk was present in the drive without spinning up the drive. The person responsible for Windows 95's 32-bit floppy driver studied the floppy drive hardware specification and spotted an opportunity. Working through the details of the specification revealed that, yes, if you issued just the right extremely clever sequence of commands, you could determine whether a disk was in the floppy drive without spinning up the drive. But there was a catch. T...