Showing tag results for Code

Nov 3, 2003
Post comments count0
Post likes count1

The long and sad story of the Shell Folders key

Raymond Chen
Raymond Chen

When you are attempting to architect an operating system, backwards compatibility is one of the ones you just have to accept. But when new programs rely on app hacks designed for old programs, that makes you want to scream.

CodeHistory
Oct 31, 2003
Post comments count0
Post likes count1

Why highlighting by inverting colors is a bad idea

Raymond Chen
Raymond Chen

Often people will say, "Oh, we can highlight by inverting the color." This may have worked great on two-color black-and-white displays, but in the world of 32-bit color this no longer is effective. Consider the following picture. See if you can guess which one is inverted. ...

Code
Oct 29, 2003
Post comments count0
Post likes count0

Drawing an active-looking caption even when not active

Raymond Chen
Raymond Chen

"Why would somebody ever want to do that?" you might ask. Well, this is a common appearance for floating toolbars. (But aside from that case, I can't think of any other valid reason to draw a window as active even though it isn't.) Fortunately this is easy to do. Just add this line to the of ...

Code
Oct 27, 2003
Post comments count0
Post likes count0

Getting a custom right-click menu for the caption icon

Raymond Chen
Raymond Chen

Explorer does it. Now you can too. It's a simple matter of detecting a context menu on the caption icon and displaying a custom context menu. Here are the simple changes to our scratch program to display a rather pointless one-item menu. When we receive a message, we check that...

Code
Oct 23, 2003
Post comments count0
Post likes count1

Writing a sort comparison function

Raymond Chen
Raymond Chen

When you are writing a sort comparison function (say, to be passed to or *gasp* to be used as an ), your comparison function needs to follow these rules: Reflexivity: . Anti-Symmetry: has the opposite sign of , where 0 is considered to be its own opposite. Transitivity: If and , then . Here are some logical consequences of these rules (all ...

Code
Oct 21, 2003
Post comments count0
Post likes count0

Using the TAB key to navigate in non-dialogs

Raymond Chen
Raymond Chen

The IsDialogMessage function works even if you aren't a dialog. As long as your child windows have the WS_TABSTOP and/or WS_GROUP styles, they can be navigated as if they were part of a dialog box. One caveat is that IsDialogMessage will send DM_GETDEFID and DM_SETDEFID messages to your window, which are messag...

Code
Oct 16, 2003
Post comments count0
Post likes count0

Scrollbars redux: Part 12

Raymond Chen
Raymond Chen

Reader Jeff Miller added Word-style scroll tips to our sample scrollbar program. Here's how he did it: A tracking tooltip is used to display the scroll tip because we don't want the tooltip to do automatic positioning or automatic show/hide. When a tracking scroll occurs (), we ...

Code
Oct 13, 2003
Post comments count0
Post likes count0

Why is there no WM_MOUSEENTER message?

Raymond Chen
Raymond Chen

There is a message. Why isn't there a message? Because you can easily figure that out for yourself. When you receive a message, set a flag that says, "The mouse is outside the window." When you receive a message and the flag is set, then the mouse has entered the window. (And cle...

Code
Oct 9, 2003
Post comments count0
Post likes count0

Other uses for bitmap brushes

Raymond Chen
Raymond Chen

Bitmap brushes used to be these little 8x8 monochrome patterns that you could use for hatching and maybe little houndstooth patterns if you were really crazy. But you can do better. CreatePatternBrush lets you pass in any old bitmap - even a huge one, and it will create a brush from it. The bi...

Code