Showing results for Code - The Old New Thing

Apr 16, 2010
Post comments count0
Post likes count0

The mysterious stock bitmap: There's no way to summon it, but it shows up in various places

Raymond Chen
Raymond Chen

A number of stock GDI objects are made available by the function, but one stock GDI object that is mysteriously missing is the stock bitmap. You can't summon the stock bitmap, but it manages to show up in various places, some of them perhaps unexpected. The stock bitmap is a monochrome 1×1 bitmap which GDI uses in various places where it ...

Code
Apr 14, 2010
Post comments count0
Post likes count0

When you create an object with constraints, you have to make sure everybody who uses the object understands those constraints

Raymond Chen
Raymond Chen

Here's a question that came from a customer. This particular example involves managed code, but don't let that distract you from the point of the exercise. I am trying to create a object using the constructor that takes an as input. In my .cs file, I create the native file handle using , as shown below. Then I create the object as so: ...

Code
Apr 12, 2010
Post comments count0
Post likes count1

How do I switch a window between normal and fullscreen?

Raymond Chen
Raymond Chen

Frederic Delhoume wants to know if there is a simple example of code that switches an application from windowed to fullscreen. He then included a code fragment that did some crazy things with parent windows and hiding and showing. You're making it way, way harder than it needs to be. Let's start with our scratch program and make these changes:...

Code
Apr 9, 2010
Post comments count0
Post likes count0

Why can't you use WM_CTLCOLORSTATIC to change the color of a SS_BLACKRECT?

Raymond Chen
Raymond Chen

If you specify one of the static control styles which draw a frame or rectangle the control will be drawn with the corresponding color (which, as we saw last time, isn't actually black, gray, or white). If you try to customize the color by handling the message, you'll find that it has no effect. Well, yeah, because you said you wanted a black ...

Code
Apr 2, 2010
Post comments count0
Post likes count0

Why do non-folders in my shell namespace extension show up in the folder tree view?

Raymond Chen
Raymond Chen

A customer was having trouble with their shell namespace extension: When we click the [+] button next to our shell namespace extension in the folder tree view, the tree view shows both files and folders, even though it's supposed to show only folders. Our does return the correct values for (including it for the folders and omitting it for the n...

Code
Mar 29, 2010
Post comments count0
Post likes count0

What happens to the control names in the IDE when my program is running?

Raymond Chen
Raymond Chen

nick_journals demonstrates some confusion about names in source code and their relationship to runtime behavior. A topic I am particularly interested in is the naming of controls, how it works... Every control gets a name from a developer...via the IDE (e.g btnOK) When using this function: GetWindowLong(handle,GWL_ID) it doesn't return the n...

Code
Mar 26, 2010
Post comments count0
Post likes count0

WaitForInputIdle waits for any thread, which might not be the thread you care about

Raymond Chen
Raymond Chen

We saw last time that the function waits only once for a process to go input idle. Even if the process later stops processing messages, will return immediately and say, "Yeah, he's idle." The way a process is determined to be input idle is that it is waiting for user input when there is none. This translates into the process sitting in a functi...

Code
Mar 25, 2010
Post comments count0
Post likes count0

WaitForInputIdle should really be called WaitForProcessStartupComplete

Raymond Chen
Raymond Chen

The function waits for a process to finish its initialization, which is determined when it reaches a state where it is just sitting around waiting for messages. The documentation for doesn't even get around to the initialization part until the Remarks section. If all you read is the one-sentence summary, Waits until the specified process is wait...

Code
Mar 19, 2010
Post comments count0
Post likes count0

How does delay-loading use binding information?

Raymond Chen
Raymond Chen

In the documentation for delay-loading, there's a remark that says that the call to can be avoided if there is binding information. A customer who received the explanation of why you can't delay-load pointed out that paragraph and asked whether this means that you can delay-load if you bind to it. (Getting around to answering this question wa...

Code
Mar 18, 2010
Post comments count0
Post likes count0

What is DLL import binding?

Raymond Chen
Raymond Chen

Last time, we saw how hinting is used to speed up the resolving of imported functions. Today, we'll look at binding. Recall that the module loader resolves imports by locating the function in the export table of the linked-to DLL and recording the results in the loaded module's table of imported function addresses so that code from the module ...

Code