Showing tag results for Code

Nov 15, 2012
Post comments count0
Post likes count1

If you're going to write your own allocator, you need to respect the MEMORY_ALLOCATION_ALIGNMENT

Raymond Chen
Raymond Chen

This time, I'm not going to set up a story. I'm just going to go straight to the punch line. A customer overrode the operator in order to add additional instrumentation. Something like this: This worked out okay on 32-bit systems because in 32-bit Windows, is 8, and is also 8. If you start with a value that is a multiple of 8, then add 8 ...

Code
Nov 13, 2012
Post comments count0
Post likes count1

Microsoft Money crashes during import of account transactions or when changing a payee of a downloaded transaction

Raymond Chen
Raymond Chen

Update: An official fix for this issue has been released to Windows Update, although I must say that I think my patch has more style than the official one. You do not need to patch your binary. Just keep your copy of Windows 8 up to date and you'll be fine. For the five remaining Microsoft Money holdouts (meekly raises hand), here's a patch...

Code
Nov 9, 2012
Post comments count0
Post likes count1

Thread affinity of user interface objects: Addendum

Raymond Chen
Raymond Chen

Some time ago, I discussed the thread affinity of device contexts, noting that the and functions must be called from the same thread. The same restriction also applies to printer DCs. Printer DCs must be created and destroyed on the same thread. The printing team imposed this additional rule in order to make it easier for printer driver vendors...

Code
Nov 5, 2012
Post comments count0
Post likes count1

How do I get the tabbed dialog effect on my own custom tabbed dialog?

Raymond Chen
Raymond Chen

CJ observed that the standard tabbed dialogs provide an effect on the tab pages and want to know how to get the tabbed dialog effect on custom dialogs. fds242 noted this as well and wanted to know why the automatic tabbed dialog effect doesn't kick in until you put a static control on the child dialog box. Let's look at the first question firs...

Code
Nov 2, 2012
Post comments count0
Post likes count1

How do I parse a string into a FILETIME?

Raymond Chen
Raymond Chen

Public Service Announcement: Daylight Saving Time ends in most parts of the United States this weekend. Other parts of the world may change on a different day from the United States. The NLS functions in Win32 provide functions to convert a into a string, but it does not provide any functions to perform the reverse conversion. Here are few t...

CodeTime
Nov 1, 2012
Post comments count0
Post likes count1

When you synthesize input with SendInput, you are also synthesizing the timestamp

Raymond Chen
Raymond Chen

A customer was reporting a problem when they used the function to simulate a drag/drop operation for automated testing purposes. I see the mouse move from one location to another, and the starting and stopping locations are correct on the screen, but the mouse moves instantaneously rather than waiting 500ms between operations. Here's how I'm s...

Code
Oct 25, 2012
Post comments count0
Post likes count1

Keyboard layouts aren't like Beetlejuice – they won't appear just because you say their name

Raymond Chen
Raymond Chen

A customer reported a bug in Windows Vista Home Editions: We are handling a Ctrl+V keyboard event and want to interpret it in the context of a US-English keyboard. On Windows XP and versions of Windows Vista other than Home editions, the three calls all succeed, whereas on Windows Vista Home Editions, the calls fail. On the other hand, ...

Code
Oct 24, 2012
Post comments count0
Post likes count1

You can't use the WM_USER message in a dialog box

Raymond Chen
Raymond Chen

Today, I'm not actually going to say anything new. I'm just going to collate information I've already written under a better title to improve search engine optimization. A customer reported that they did the following but found that it didn't work: "I send the message to my dialog, but the value doesn't stick. At random times, the value rese...

Code
Oct 23, 2012
Post comments count0
Post likes count1

Diversion: Generating a random color from JavaScript

Raymond Chen
Raymond Chen

A colleague posed a little puzzle for a fun little app he was writing in HTML: He wanted to generate a random color. If you search around the intertubes, you can find several possible attempts at a solution, like this collection, and an interesting example that has trouble with the pigeonhole principle. The original function to generate a ra...

Code
Oct 19, 2012
Post comments count0
Post likes count1

Using WM_COPYDATA to marshal message parameters since the window manager otherwise doesn’t know how

Raymond Chen
Raymond Chen

Miral asks for the recommended way of passing messages across processes if they require custom marshaling. There is no one recommended way of doing the custom marshaling, although some are hackier than others. Probably the most architecturally beautiful way of doing it is to use a mechanism that does perform automatic marshaling, like COM and MI...

Code