Date: | March 9, 2006 / year-entry #88 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20060309-09/?p=31983 |
Comments: | 26 |
Summary: | Some people may have noticed that the WS_CAPTION is defined as the combination of WS_BORDER and WS_DLGFRAME: #define WS_CAPTION 0x00C00000L /* WS_BORDER | WS_DLGFRAME */ #define WS_BORDER 0x00800000L #define WS_DLGFRAME 0x00400000L Since WS_CAPTION includes WS_BORDER, it is impossible to get a caption without a border. Sometimes people don't quite get this and keep asking the... |
Some people may have noticed that the #define WS_CAPTION 0x00C00000L /* WS_BORDER | WS_DLGFRAME */ #define WS_BORDER 0x00800000L #define WS_DLGFRAME 0x00400000L
Since Sometimes people don't quite get this and keep asking the question over and over again, and I have to keep trying to explain the laws of logic in different ways until one of them finally sinks in.
"I noticed that if I set the
"If you look at the definition, "But I see other controls that don't have a border. Static controls on a dialog box, for example, don't have a border, so obviously it's possible to remove the border. How do I do that?" "They don't have borders, but then again, they don't have captions either. Caption implies border." "But I want a window with a caption and no border. What window styles do I need to use to get that? Do I have to implement it some other way?" "Caption implies border. Contrapositive: No border implies no caption. If you don't like that, you'll have to take it up with Russell and Whitehead." Of course, you can just choose to leave the system entirely and use none of the styles at all and just paint a custom caption. What you get isn't a real caption, though with enough work you can make it look and act like one. Or at least, make it look and act like one up to the present time. If you have the power of clairvoyance, you might be able to make it look and act like a caption in future versions of the operating system, but I suspect your psychic powers are not quite powerful enough to pull that off. |
Comments (26)
Comments are closed. |
"and just paint a custom caption"
I actually had to do this once. A horrendous amount of work, for, as far as I am concerned, very little return. I’m not sure who I hate more – whoever decided that "if you ask for a caption you must have a border" or the woever made that requirement for the application I was writing.
It does bring up the question though – why is this so?
Once again, some developers are confused by another retarded design decision by Microsoft, and Mr. Chen blames the victim.
Would somebody care to enlighten me as to what a window would look like if it had a title bar but no border?
A little like this, I’d imagine:
<a href="http://img79.imageshack.us/my.php?image=noborder7mj.png">Window with no border</a>
A maximised window has no border (that you can see, anyway!)
Fixed link:
http://img79.imageshack.us/my.php?image=noborder7mj.png
ringzero: Nowhere did I argue that the design was a good one. But even if you don’t like something, you still have to obey the rules of boolean logic.
It’s because: if you don’t have a border, the edges will fray.
While I certainly understand the frustration when the thing one is working with does not do EXACTLY what I want it to, if the fallback is not so bad, then where’s the beef? So you get a border … at least it does not mean its a sizeable window. Hey – your competitor’s windows have borders too!
What I cannot get is why there is no DrawCaptionBar (and the needed GetCaptionBarSize, etc) or similar API to aid the developer who needs to draw a custom caption bar.
Oh, you mean DrawCaption()?
Seems to me that the repeated occurrence of this conversation suggests the need for an additional API of some sort.
D’oh! That will teach me to comment without refreshing. Maybe.
<i>Oh, you mean DrawCaption()?</i>
There you go, Raymond. The next time somebody says "I want a window with a caption, but no border", you tell them to use a frame and DrawCaption().
Arguably, this indicates a usability problem. As does a large subset of the "psychic debugging". I’m not pointing any fingers; I’m guilty of that myself. In my heart of hearts I don’t believe that we’ll ever fix those bugs. It’s not sexy work and it doesn’t drive revenue.
But what do I know? I’m just some schmuck tester.
– Drew
Style flags and condensed MFC description edited by me:
WS_DLGFRAME: The frame that dialog boxes get, which by recent convention is thick and possibly beveled. No caption though.
WS_BORDER: a border.
WS_CAPTION: a caption. But ‘implies’ WS_BORDER.
It’s hard to help explain this with the bit values, because WS_DLGFRAME is a border, and so is WS_BORDER, but OR’ing two borders gives you a caption. Russell and Whitehead surely are not taking sides here. But really you should be describing it as an enum field in the middle of the style word. Four options, none of which are what the particular user wants, because someone back in the mists of time exercised some discretion.
"Or at least, make it look and act like one up to the present time. If you have the power of clairvoyance, you might be able to make it look and act like a caption in future versions of the operating system, but I suspect your psychic powers are not quite powerful enough to pull that off."
Perhaps you’d better tell that to the Office team:
http://blogs.msdn.com/jensenh/archive/2006/03/09/547281.aspx
Tim:
Many of us are not wearing our mind-reading hats. What exactly should be told to Office and why?
Or if you want to get really fancy, you can set the window region to crop off the border…
"if you don’t have a border, the edges will fray"
Okay, thanks for the explanation ;)
IANAL, but the caption bar is PART OF the border. A maximised window actually still has a border! Try maximising a window with fixed width/height, and drag it away from the edge of the screen. You see, there’s still a border.
And there are definately useability problems with creating a title bar in a client area. Besides from more obvious problems, you don’t know what accessibilty programs a user might have running, and you have no idea how you’ll break them.
@Chris Becke "Then, even worse, my boss comes to me, particularly enamored with some new office widget and wants it in the app im developing. Can I drop in a standard implementation of the widget from user32 or shell32 or even a standard OCX? NO"
Well… I thought the same but then I saw SmartFTP letting me choose a "drawing manager" for the UI and the list seemed to match what was installed on the PC (‘Standard Windows’ style , ‘Office 2000’ style, ‘Visual Studio’ style etc.). So there has to be a (maybe) ‘deeply buried and misdocumented for the competitors’-way to use the UI from Office and other MS tools.
@Vince: At a guess, simply the observation that of any App on my grandfathers PC, the one app most likley to deviate from the "normal" is Office.
Ironically its the same reason I despise open source applications on Win32. They *never* use the windows widgets. Simple standard things like menu’s and file open dialogs always have to be "improved".
But I can never complain, because while the OOS apps are wasting their time re-inventing a the wheel, the Office team is doing the same damned thing.
Much to the confusion of my grandfather.
Then, even worse, my boss comes to me, particularly enamored with some new office widget and wants it in the app im developing. Can I drop in a standard implementation of the widget from user32 or shell32 or even a standard OCX? NO. The damn thing is hardcoded into office. So I have to (a) re-implement it from scratch, (b) fail to get the behaviour exactly the same anyway, and (c) know that I – unlike the office team – wont have the benefit of being able to re-write it per OS flavor and that its going to look really crap on any newer (or older) OS versions I get run on.
@Nawak: No, these are from 3rd party libraries such as those created by companies like BCGSoft, CodeJock and FOSS Software.
>> Ironically its the same reason I despise open source applications on Win32. They *never* use the windows widgets. Simple standard things like menu’s and file open dialogs always have to be "improved". But I can never complain, because while the OOS apps are wasting their time re-inventing a the wheel, the Office team is doing the same damned thing.
OOS does this using GTK, Qt or WXWidgets to keep (as much as possible) compatibility of GUI code across all the supported operative systems. BTW most commercial software does this too, just thinking of 3dsmax, photoshop, office, etc.
8’s got it. Freecell is an app with a fixed maximum width; you can use that to see what’s up.
Vorn
So when calling DrawCaption how do you tell if your caption is active or not (not forgetting to take FlashWindow into account, of course)?