Showing tag results for Code

Jul 27, 2005
Post comments count0
Post likes count0

When the normal window destruction messages are thrown for a loop

Raymond Chen
Raymond Chen

Last time, I alluded to weirdness that can result in the normal cycle of destruction messages being thrown out of kilter. Commenter Adrian noted that the WM_GETMINMAXINFO message arrives before WM_NCCREATE for top-level windows. This is indeed unfortunate but (mistake or not) it's been that way for over a decade and changing it now would intro...

Code
Jul 26, 2005
Post comments count0
Post likes count1

What is the difference between WM_DESTROY and WM_NCDESTROY?

Raymond Chen
Raymond Chen

There are two window messages closely-associated with window destruction, the WM_DESTROY message and the WM_NCDESTROY message. What's the difference? The difference is that the WM_DESTROY message is sent at the start of the window destruction sequence, whereas the WM_NCDESTROY message is sent at the end. This is an important distinction when y...

Code
Jul 22, 2005
Post comments count0
Post likes count0

The importance of passing the WT_EXECUTELONGFUNCTION flag to QueueUserWorkItem

Raymond Chen
Raymond Chen

One of the flags to the QueueUserWorkItem function is WT_EXECUTELONGFUNCTION. The documentation for that flag reads The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread. As noted in the documentation, the thread pool uses this flag to decide whether it should create a new thread...

Code
Jul 21, 2005
Post comments count0
Post likes count0

FindFirstFile is not a SQL query

Raymond Chen
Raymond Chen

The function is not a SQL query. It's a very simple directory enumerator. There is a slightly fancier version called , but even that function doesn't add much at present beyond filtering for directories or devices. You don't get to pass it sort criteria like or "return the files/directories sorted smallest file first", or "return the files/dir...

Code
Jul 13, 2005
Post comments count0
Post likes count0

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

Raymond Chen
Raymond Chen

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. Cus...

Code
Jul 12, 2005
Post comments count0
Post likes count0

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

Raymond Chen
Raymond Chen

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(pszBegi...

Code
Jul 11, 2005
Post comments count0
Post likes count0

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

Raymond Chen
Raymond Chen

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 followed ...

Code
Jul 6, 2005
Post comments count0
Post likes count1

What’s the point of DeferWindowPos?

Raymond Chen
Raymond Chen

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 static CO...

Code
Jul 5, 2005
Post comments count0
Post likes count0

Using script to query information from Internet Explorer windows

Raymond Chen
Raymond Chen

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 enumera...

Code
Jul 1, 2005
Post comments count0
Post likes count0

I hope you weren’t using those undocumented critical section fields

Raymond Chen
Raymond Chen

I hope you weren't using those undocumented critical section fields, because in Windows Server 2003 Service Pack 1, they've changed. Mike Dodd tells an interesting story of a vendor who used reserved fields and then complained when the system started using them!

Code