Showing tag results for Code

Nov 19, 2007
Post comments count0
Post likes count1

If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Raymond Chen
Raymond Chen

Commenter praful asks what to me is a rather confused question, but I'll try to guess what the real question is. If you drag My Computer to the Start button in XP, you get an expanding menu that lets you see all files and folders as submenus. Is this menu available to applications via an API, or do you have to build it yourself? For example, c...

Code
Nov 12, 2007
Post comments count0
Post likes count1

I don't know what the Lotus internal clipboard formats are either

Raymond Chen
Raymond Chen

Apparently some people think my psychic powers extend to being able to steal trade secrets by sheer force of concentration. I've been trying to write an application which allows to drag and drop documents from lotus notes. If I just drag and drop a document from lotus notes to Windows explorer, it creates a .shb file (regular windows document li...

Code
Nov 9, 2007
Post comments count0
Post likes count1

You just have to accept that the file system can change

Raymond Chen
Raymond Chen

A customer who is writing some sort of code library wants to know how they should implement a function that determines whether a file exists. The usual way of doing this is by calling , but what they've found is that sometimes will report that a file exists, but when they get around to accessing the file, they get the error . The lesser questi...

CodeThings I've written that have amused other people
Nov 6, 2007
Post comments count0
Post likes count0

VirtualLock only locks your memory into the working set

Raymond Chen
Raymond Chen

When you lock memory with it locks the memory into your process's working set. It doesn't mean that the memory will never be paged out. It just means that the memory won't be paged out as long as there is a thread executing in your process, because a process's working set need be present in memory only when the process is actually executing. (Ear...

Code
Nov 5, 2007
Post comments count0
Post likes count2

Why do we even have the DefWindowProc function?

Raymond Chen
Raymond Chen

Some time ago, I looked at two ways of reimplementing the dialog procedure (method 1, method 2). Commenter "8" wondered why we have a function at all. Couldn't window procedures have followed the dialog box model, where they simply return to indicate that they want default processing to occur? Then there would be no need to export th...

Code
Nov 1, 2007
Post comments count0
Post likes count1

Why does GetDiskFreeSpaceEx return the wrong amount of free space?

Raymond Chen
Raymond Chen

One customer discovered that viewing the properties of a drive from Explorer shows the amount of disk free space significantly lower than the actual amount of free disk space as resported by the disk management snap-in. The command prompt agrees with Explorer and shows the incorrect result. What's going on? Not surprisingly, both Explorer and the ...

Code
Oct 26, 2007
Post comments count0
Post likes count0

If you pass enough random numbers, eventually one of them will look valid

Raymond Chen
Raymond Chen

One customer traced a problem they were having to the way they were calling a function similar in spirit to this one: This function takes a clipboard format and looks for it on the clipboard. If found, it returns a copy of the data. Looks great, huh? The problem is that the customer would sometimes call the function as . The clipboard form...

Code
Oct 24, 2007
Post comments count0
Post likes count0

What's the difference between LVM_HITTEST and LVM_INSERTMARKHITTEST?

Raymond Chen
Raymond Chen

One customer was confused by the two list view hit-test messages and . What is the difference between the two? The message tries to find the item the point is over. The message tries to find the item the point is next to. For example, suppose you have two 32×32 items, item zero at (0, 0) and item one at (0, 32). You use whe...

Code
Oct 22, 2007
Post comments count0
Post likes count0

The best way to process Unicode input is to make somebody else do it

Raymond Chen
Raymond Chen

Andrew M asks via the Suggestion Box: I was hoping you could address how to properly code Unicode character input. It seems like a lot of applications don't support it correctly. I'm not sure I understand the question, but the answer is pretty easy: Don't do it! Text input is hard. It should be left to the professionals. This means you should...

Code
Oct 19, 2007
Post comments count0
Post likes count0

Other problems traced to violating COM single-threaded apartment rules in the shell

Raymond Chen
Raymond Chen

Probably the biggest category of problems that can be traced to violating COM single-threaded apartment rules in the shell is using an object from the wrong thread. Of course, nobody admits to doing this up front, They just report that the shell is broken. We can't enumerate the items on the desktop any more. We take the pointer returned by and...

Code