Showing archive results for 2013

Jun 24, 2013
Post comments count0
Post likes count1

Wait, this is not my regular bicycle commute home

Raymond Chen

I dreamed that I finished biking home and decided not to take the stairs. Instead I took my bicycle into the elevator to go to my dream-land 31st-floor high-rise condo. (As if.) For "security reasons" there were no buttons in the elevator. You had to open a secret panel and flip a circuit-breaker switch corresponding to the floor you want to go t...

Non-ComputerDream
Jun 24, 2013
Post comments count0
Post likes count1

Drawing content at a fixed screen position, regardless of window position

Raymond Chen

Today's Little Program draws content at a fixed screen position. The idea is that the window is really a viewport into some magical world. Unfortunately, our magical world just has a sign that says "Booga booga." Creating a more interesting magical world is left as an exercise. Start with our scratch program and make these changes: void OnMov...

Code
Jun 21, 2013
Post comments count0
Post likes count1

Of what use is the RDW_INTERNALPAINT flag?

Raymond Chen

For motivational purposes, let's start with a program that displays a DWM thumbnail. Start with the scratch program and add the following: #include <dwmapi.h> HWND g_hwndThumbnail; HTHUMBNAIL g_hthumb; void UpdateThumbnail(HWND hwndFrame, HWND hwndTarget) { if (g_hwndThumbnail != hwndTarget) { g_hwndThumbnail = hwndTarget; if (g...

Code
Jun 20, 2013
Post comments count0
Post likes count1

Solving the problem rather than answering the question: Why does somebody want to write an unkillable process?

Raymond Chen

Via their customer liaison, a customer wanted to know how to create a process that runs with the context of the user, but which the user cannot terminate without elevating to administrator. The customer is engaging in the futile arms race between programs and users (which is more properly a walls and ladders scenario). And we saw that Windows h...

Other
Jun 19, 2013
Post comments count0
Post likes count1

AttachThreadInput is like taking two threads and pooling their money into a joint bank account, where both parties need to be present in order to withdraw any money

Raymond Chen

Consider this code: // Code in italics is wrong foregroundThreadId = ::GetWindowThreadProcessId(::GetForegroundWindow(), 0); myThreadId = GetCurrentThreadId(); if (foregroundThreadId != myThreadId) { AttachThreadInput(foregroundThreadId, myThreadId, TRUE); BringWindowToTop(myWindowHandle); If you try to step ov...

Code
Jun 18, 2013
Post comments count0
Post likes count1

Microspeak: to family well

Raymond Chen

If you hang out with designers, you may hear the word family used as a verb, usually with the adverb well. The old icons now look dated and do not family well with the Web site. We renamed the feature from Auto Shape to Instant Shape so that it families well with other features like Instant Color. The authenticity certificate on the side of the...

OtherMicrospeak
Jun 17, 2013
Post comments count0
Post likes count1

I wonder if the Queen of England ever pulls this sort of prank in real life

Raymond Chen

I dreamed that I was playing doubles tennis. My partner was Boris Becker. Our opponents were the Queen of England and a policeman on a horse. The horse served his horseshoe, which I returned poorly. As the horseshoe bounced across the ground, it made huge divots. The game was called due to poor ground conditions. The Queen played a game with the ...

Non-ComputerDream
Jun 17, 2013
Post comments count0
Post likes count1

Displaying a property sheet for multiple files

Raymond Chen

Today's Little Program will show a property sheet that covers multiple files, just like the one you get from Explorer if you multi-select a bunch of files and right-click them all then select Properties. In fact, that description of how you do the operation interactively maps directly to how you do the operation programmatically! #define UNICO...

Code
Jun 14, 2013
Post comments count0
Post likes count1

A big little program: Monitoring Internet Explorer and Explorer windows, part 3: Tracking creation and destruction

Raymond Chen

Last time, we listener for window navigations. Today we'll learn about tracking window creation and destruction. The events to listen to are the DShell­Windows­Events. The Window­Registered event fires when a new window is created, and the Window­Revoked event fires when a window is destroyed. The bad news is that the paramet...

Code
Jun 13, 2013
Post comments count0
Post likes count2

A big little program: Monitoring Internet Explorer and Explorer windows, part 2: Tracking navigations

Raymond Chen

Okay, it's been a while since we set aside our Little Program to learn a bit about connection points and using dispatch interfaces as connection point interfaces. Now we can put that knowledge to use. Internet Explorer and Explorer windows fire a group of events known as DWeb­Browser­Events, so we just need to listen on those events ...

Code