Showing tag results for Code

Jun 13, 2011
Post comments count0
Post likes count1

You don't need to steal focus if you can just arrange for someone to give it to you

Raymond Chen
Raymond Chen

Commenter doesn't matter proposes a scenario where focus-stealing is necessary: There are two applications A and B, Application B exposes an interface, and Application A connects to application B via that interface, When some sort of even occurs in application B, it notifies application A, which wants to steal fo...

Code
Jun 10, 2011
Post comments count0
Post likes count1

Generally speaking, if your function fails, you should return a failure code

Raymond Chen
Raymond Chen

A customer requested assistance with their shell namespace extension, and the request worked its way to me for resolution. The customer was at a loss because the customer's code was nowhere on the stack. What is wrong? The customer didn't provide a dump file or any other information beyond the stack trace. (Hint: When reporting a problem with...

Code
Jun 3, 2011
Post comments count0
Post likes count1

Swamping the thread pool with work faster than it can drain

Raymond Chen
Raymond Chen

This scenarios is real, but details have been changed to protect the guilty. Consider a window showing the top of a multi-page document. The developers found that when the user clicks the down-arrow button on the scroll bar, the program locks up for 45 seconds, over a dozen threads are created, and then suddenly everything clears up and the wind...

Code
Jun 2, 2011
Post comments count0
Post likes count1

How do I control X-Mouse settings (active window tracking)?

Raymond Chen
Raymond Chen

For quite some time, Windows has had a setting officially called active window tracking but which informally goes by the name X-Mouse, because that was the name of the PowerToy which first exposed the feature. (The PowerToy was in turn so-named because it made the mouse behave in a manner similar to many X window managers.) The setting is exposed ...

Code
Jun 1, 2011
Post comments count0
Post likes count1

How do I prevent users from pinning my program to the taskbar?

Raymond Chen
Raymond Chen

A customer wanted to prevent users from pinning their application to the taskbar. I have an application that is launched as a helper by a main application. Users shouldn't be launching it directly, but rather should be launching the main application. But since the helper shows up in the taskbar, users may be tempted to right-click on the taskbar...

Code
May 26, 2011
Post comments count0
Post likes count1

How do IsThemeActive, IsAppThemed, and IsCompositionActive differ?

Raymond Chen
Raymond Chen

There are three functions which test very similar things, and sometimes applications pick the wrong one. Here's the rundown: Note that these functions do not answer the question "Is the application using the visual-styles-enabled version of the common controls library?" That question is harder to answer because the decision to use the visual-sty...

Code
May 25, 2011
Post comments count0
Post likes count2

WinMain is just the conventional name for the Win32 process entry point

Raymond Chen
Raymond Chen

is the conventional name for the user-provided entry point in a Win32 program. Just like in 16-bit Windows, where the complicated entry point requirements were converted by language-provided startup code into a call to the the user's function, the language startup code for 32-bit programs also does the work of converting the raw entry point in...

Code
May 20, 2011
Post comments count0
Post likes count1

BeginBufferedPaint: It's not just for buffered painting any more

Raymond Chen
Raymond Chen

I covered the function in my 2008 PDC presentation, but one thing I didn't mention is that the buffered paint functions are very handy even if you have no intention of painting. Since the buffered paint functions maintain a cache (provided that you remembed to call ), you can use to get a temporary bitmap even if you have no intention of actu...

Code
May 16, 2011
Post comments count0
Post likes count1

Multithreaded UI code may be just as hard as multithreaded non-UI code, but the consequences are different

Raymond Chen
Raymond Chen

Commenter Tim Smith claims that the problems with multithreaded UI code are not significantly more than plain multithreaded code. While that may be true on a theoretical level, the situations are quite different in practice. Regardless of whether your multithreaded code does UI or not, you have to deal with race conditions, synchronization, cache...

Code