Showing tag results for Code

Dec 20, 2012
Post comments count0
Post likes count1

Why do I sometimes get classic buttons and sometimes themed buttons depending on the host process?

Raymond Chen
Raymond Chen

A customer reported that their printer configuration property sheet page looked different depending on the host process. In some processes, the printer configuration dialog had the classic look of Windows 2000, but in other processes it has the themed look of Windows XP and later versions. The printer driver calls the to create the prop...

Code
Dec 19, 2012
Post comments count0
Post likes count1

Why doesn't SHGetKnownFolderPath return the customized path?

Raymond Chen
Raymond Chen

A customer reported that the function was not working correctly. They moved their Videos folder to a new location, but when they called , they got the old path rather than the new one. A quick check of the code they provided showed why: Um, you're passing the flag. That flag means "Tell me where this folder would have been if its location h...

Code
Dec 17, 2012
Post comments count0
Post likes count1

Like the cake, WS_EX_TRANSPARENT is a lie, or at least not the entire truth

Raymond Chen
Raymond Chen

There is an extended window style known as . Explaining what this style does is kind of difficult, but it's been on the list of future topics since 2003. Better late than never, I guess. First of all, there are two unrelated senses of transparent in play. One is visual transparency: Pixels beneath the window can show through. The other is hit-te...

Code
Dec 14, 2012
Post comments count0
Post likes count1

Why is it possible to create a toolbar with the wrong HINSTANCE? And what's the right HINSTANCE anyway?

Raymond Chen
Raymond Chen

A customer observed that all of the following code fragments are successful in creating a toolbar common control: Furthermore, the customer observed that works regardless of whether you pass the process instance or for the parameter. First of all, what's going on? And second of all, which of the three methods above is most correct? We ...

Code
Dec 12, 2012
Post comments count0
Post likes count1

How am I supposed to free the information returned by the GetSecurityInfo function?

Raymond Chen
Raymond Chen

The function returns a copy of the security descriptor for a kernel object, along with pointers to specific portions you request. More than once, a customer has been confused by the guidelines for how to manage the memory returned by the function. Let's look at what the function says: ppsidOwner [out, optional] A pointer to a variable that ...

Code
Dec 10, 2012
Post comments count0
Post likes count2

Why do some shortcuts not support editing the command line and other properties?

Raymond Chen
Raymond Chen

Ben L observed that some shortcuts do not permit the command line and other options to be edited. "Where is this feature controlled? Is there a way to override this mode?" This question is echoed by "Anonymous (Mosquito buzzing around)" (and don't think we don't know who you are), who in a huge laundry list of questions adds, "Why does the Gam...

Code
Dec 6, 2012
Post comments count0
Post likes count1

Replaying input is not the same as reprocessing it

Raymond Chen
Raymond Chen

Once upon a time, there was an application that received some input and said, "Okay, this input cancels my temporary state. I want to exit my temporary state, but I also want the input that took me out of the temporary state to go to whatever control would have received the input if I hadn't been in the temporary state in the first place." (For exa...

Code
Dec 5, 2012
Post comments count0
Post likes count1

Why do I get notified for changes to HKEY_CLASSES_ROOT when nobody is writing to HKEY_CLASSES_ROOT?

Raymond Chen
Raymond Chen

A customer had a question about the function. We are using it to monitor the tree as follows: If I understand the documentation correctly, this registers for notifications when subkeys are added, deleted, or when values are changed. However, it seems that my event becomes signaled at many other times, for example, when I switch folders in ...

Code
Nov 29, 2012
Post comments count0
Post likes count1

Various ways of performing an operation asynchronously after a delay

Raymond Chen
Raymond Chen

Okay, if you have a UI thread that pumps messages, then the easiest way to perform an operation after a delay is to set a timer. But let's say you don't have a UI thread that you can count on. One method is to burn a thread: Less expensive is to borrow a thread from the thread pool: But both of these methods hold a thread hostage for the d...

Code