The Old New Thing

Converting from traditional to simplified Chinese, part 3: Highlighting differences

One of the things that is interesting to me as a student of the Chinese languages is to recognize where the traditional and simplified Chinese scripts differ. Since this is my program, I'm going to hard-code the color for simplified Chinese script: maroon. To accomplish the highlighting, we take advantage of listview's custom-draw feature...
Comments are closed.0 0
Code

Converting from traditional to simplified Chinese, part 2: Using the dictionary

Now that we have our traditional-to-simplified pseudo-dictionary, we can use it to generate simplified Chinese words in our Chinese/English dictionary. class StringPool { public: StringPool(); ~StringPool(); LPWSTR AllocString(const WCHAR* pszBegin, const WCHAR* pszEnd); LPWSTR DupString(const WCHAR* pszBegin) { return AllocString(...
Comments are closed.0 0
Code

Converting from traditional to simplified Chinese, part 1: Loading the dictionary

One step we had glossed over in our haste to get something interesting on the screen in our Chinese/English dictionary program was the conversion from traditional to simplified Chinese characters. The format of the hcutf8.txt file is a series of lines, each of which is a UTF-8 encoded string consisting of a simplified Chinese character ...
Comments are closed.0 0
Code

What’s the point of DeferWindowPos?

The purpose of the DeferWindowPos function is to move multiple child windows at one go. This reduces somewhat the amount of repainting that goes on when windows move around. Take that DC brush sample from a few months ago and make the following changes: HWND g_hwndChildren[2]; BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpcs) { const ...
Comments are closed.0 0
Code

Using script to query information from Internet Explorer windows

Some time ago, we used C++ to query information from the ShellWindows object and found it straightforward but cumbersome. This is rather clumsy from C++ because the ShellWindows object was designed for use by a scripting language like JScript or Visual Basic. Let's use one of the languages the ShellWindows object was designed for to ...
Comments are closed.0 0
Code

What’s the difference between My Documents and Application Data?

The most important difference between My Documents and Application Data is that My Documents is where users store their files, whereas Application Data is where programs store their files. In other words, if you put something in CSIDL_MYDOCUMENTS (My Documents), you should expect the user to be renaming it, moving it, deleting it, emailing ...
Comments are closed.0 2
Code

Beware of roaming user profiles

One of the less-known features of Windows is the roaming user profile. I know that this is not well-known because I often see suggestions that fail to take the roaming user profile scenario into account. Indeed, if your program behaves badly enough, you can cause data loss. (More on this later.) What is a roaming user profile? Well, your ...
Comments are closed.0 0
Code

Why can't I get the pixels of a window that isn't visible on screen?

If the window isn't visible on the screen, then the pixels simply don't exist. The Windows painting model follows the principle of "Don't save anything you can recalculate". Consider: You have a 640x480 display in 16-color mode. That's 150KB of video memory. Take four copies of Notepad and maximize each one. If each of those copies of ...
Comments are closed.0 0
Code

Why does the Run dialog autocorrect but not the Run key?

In an earlier comment, Aswin Gunawan asked why the Run dialog does autocorrection but not the Run key? One is a programmatic interface and the other is an end-user control. End users are not expected to be understand how computers do things. They want, and even expect, the computer to help them out with what they're typing. This means spell...
Comments are closed.0 0
Code