The Old New Thing

Dragging a shell object, part 2: Enabling the Move operation

Let's say that we did want to support Move in our drag/drop program, for whatever reason. Let's do it with some scratch file instead of clock.avi, though. Create a file somewhere that you don't mind losing; let's say it's C:\throwaway.txt. Change the function OnLButtonDown as follows: void OnLButtonDown(HWND hwnd, BOOL fDoubleClick...

Why did Windows 95 run the timer at 55ms?

The story behind the 55ms timer tick rate goes all the way back to the original IBM PC BIOS. The original IBM PC used a 1.19MHz crystal, and 65536 cycles at 1.19MHz equals approximately 55ms. (More accurately, it was more like 1.19318MHz and 54.92ms.) But that just pushes the question to another level. Why 1.19...MHz, then? With that ...

What is the purpose of the bmPlanes member of the BITMAP structure?

Many bitmap-related structures in Windows have a field called "planes". For example the structure has a member (which must be set to 1). The structure has a field called . What's the deal with that field? The EGA video adapter supported 16 simultaneous colors. This was an enormous improvement over the CGA, which supported only four ...

What’s the difference between GetKeyState and GetAsyncKeyState?

I've seen some confusion over the difference between the function and the function. returns the virtual key state. In other words, reports the state of the keyboard based on the messages you have retrieved from your input queue. This is not the same as the physical keyboard state: When should you use and when should you use...

Why doesn’t the RunAs program accept a password on the command line?

The RunAs program demands that you type the password manually. Why doesn't it accept a password on the command line? This was a conscious decision. If it were possible to pass the password on the command line, people would start embedding passwords into batch files and logon scripts, which is laughably insecure. In other words, the ...

Simple things you can do with the ShellExecuteEx function

Here's a tiny little program: #include <windows.h> #include <shellapi.h> int __cdecl main(int argc, char **argv) { if (argc == 3) { SHELLEXECUTEINFO sei = { sizeof(sei) }; sei.fMask = SEE_MASK_FLAG_DDEWAIT; sei.nShow = SW_SHOWNORMAL; // added 27 Nov sei.lpVerb = argv[1]; sei.lpFile = argv[2]; ...

Why can’t you drop directly onto a taskbar button?

If you drag a object and drop it onto a taskbar button, you get an error message that says, You cannot drop an item onto a button on the taskbar. However, if you drag the item over a button without releasing the mouse button, the window will open after a moment, allowing you to drop the item inside the window. Why doesn't the taskbar ...