Showing tag results for Code

Oct 4, 2013
Post comments count0
Post likes count0

What's the difference between CopyIcon and DuplicateIcon?

Raymond Chen
Raymond Chen

There are two functions that can be used to create one icon that is identical to another. One of them is . The other is . What's the difference? There isn't any difference. Both functions clone an icon. In fact, their implementations are basically line-for-line identical. Originally, there was just one function to clone an icon: . Windows 3...

Code
Oct 3, 2013
Post comments count0
Post likes count0

The relationship between module resources and resource-derived objects in 32-bit Windows

Raymond Chen
Raymond Chen

Last time, we saw how 16-bit Windows converted resources attached to an EXE or DLL file (which I called module resources for lack of a better term) to user interface resources. As a refresher: During the conversion from 16-bit Windows to 32-bit Windows, some of these rules changed. Specifically, icons, cursors, and accelerator tables are no long...

Code
Oct 2, 2013
Post comments count0
Post likes count0

The relationship between module resources and resource-derived objects in 16-bit Windows

Raymond Chen
Raymond Chen

As we saw last time, in 16-bit Windows, resources attached to an EXE or DLL file (which I called module resources for lack of a better term) were recorded in memory as discardable global memory blocks, and the window manager accessed them directly as needed. For example, if you had an icon or a cursor, the or was really a resource handle, and wh...

Code
Sep 30, 2013
Post comments count0
Post likes count0

Playing a sound every time the foreground window changes

Raymond Chen
Raymond Chen

Today's Little Program plays a little sound every time the foreground window changes. One of my colleagues wondered if such a program was possible, "so that I stop accidentally typing the second halves of paragraphs into windows that pop up and steal focus." It's not clear whether this program will actually solve the bigger problem, but it was fun...

Code
Sep 27, 2013
Post comments count0
Post likes count0

How can I determine how responsive my application is to input?

Raymond Chen
Raymond Chen

A customer was adding diagnostics to their application and wanted to know if there was a way to detect that the application was being slow in processing its input. These sorts of delays manifest themselves to the end user as a sluggish application which is slow to respond to input events. They already had a watchdog timer that was reset every time...

Code
Sep 26, 2013
Post comments count0
Post likes count0

Don't forget, Unicode includes formatting characters which can be used to influence output formatting

Raymond Chen
Raymond Chen

Consider this simple function: Depending on your screen resolution and font choices, this may end up displaying like this: That line break was awfully unfortunate, stranding the number 2 on a line by itself. (In publishingspeak, this is known as a orphan.) You can't control where the function will insert line breaks, but you can try to i...

Code
Sep 25, 2013
Post comments count0
Post likes count0

How can I tell that somebody used the MAKEINTRESOURCE macro to smuggle an integer inside a pointer?

Raymond Chen
Raymond Chen

Many functions and interfaces provide the option of passing either a string or an integer. The parameter is formally declared as a string, and if you want to pass an integer, you smuggle the integer inside a pointer by using the macro. For example, the function lets you load an resource specified by integer identifier by passing the identifier in...

Code
Sep 23, 2013
Post comments count0
Post likes count0

Providing a custom autocomplete source for an edit control

Raymond Chen
Raymond Chen

Today's Little Program shows a custom source for autocomplete. It's nothing exciting, but at least's it's something you can use as a starting point for your own customizations. We start with a dialog template, whose edit control will be the target of a custom autocomplete. Just for fun, I wrote the program in ATL. Instead of complaining that ...

Code
Sep 20, 2013
Post comments count0
Post likes count0

How can I tell that I have a shell folder that represents My Computer?

Raymond Chen
Raymond Chen

You have in your hands an , and you want to know whether this is an that represents My Computer. There are a few ideas that may occur to you. One is to ask the folder for its current location and compare it to . Okay, we have a lot of moving parts here. Let's look at them one at a time. The function takes an object and asks what folder it r...

Code
Sep 19, 2013
Post comments count0
Post likes count0

When a program is launched via DDE, and there are multiple servers, which one is used?

Raymond Chen
Raymond Chen

Although you are more than welcome to stop using DDE (please oh please stop using it), there are still many applications which still use it (cough), and as a result, customers still have questions about it. One customer wanted to know why, if multiple copies of a DDE-based application are running, Windows 7 will send the command to the earli...

Code