|
i would say off hand it's because it doesn't really matter.
I put the braces where ever I feel like at the given time.
hey
|
|
|
|
|
I line the braces up such as in:
class Cat
{
//blah
};
It is much easier for me to follow. The other thing I do is get a good code editor and customize the "Beautify Source" option to my liking. I then run that and it usually barfs if I have a missing brace. Which is too often.
Another thing I always do is use braces for my if statements and loops. Even if it is a simple if statement that does not require braces I use them. It makes it so much easier when I have to return to the code to figure out exactly what I was trying to put into that if statement.
|
|
|
|
|
The primary reason that you see code written like this in books is to save page space:
void foo {
// stuff
}
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Do you mean you use line up method too?
Do you do the following too?
class Cat
{
// codes
};
|
|
|
|
|
Yes, I code like this:
class Cat
{
// codes
};
I liberally use newlines and I like to organize my braces vertically.
I have seen a variety of ways that people organize their code, especially when it comes to the use of braces. I think the bottom line is what is most readable to you and your team of developers that you work with.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
If it's correct, you may want to declare a class like:
Class Cat { Cat(); ~Cat(); //some other code};
I don't think only saving page space is assumed!
|
|
|
|
|
i appreciate your code: save many lines
includeh10
|
|
|
|
|
I always do it the first way.
It takes up a few more lines, but the matching pairs are much easier to see, much neater.
Elaine
The tigress is here
|
|
|
|
|
The One True Way to put the braces is the one used by Kernighan&Ritchie, and all other styles are heretic abominations.
|
|
|
|
|
markkuk wrote:
The One True Way to put the braces is the one used by Kernighan&Ritchie, and all other styles are heretic abominations.
that's fine for C code but C++ does it properly
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
I do as :
class Cat
{
// codes
};
I think this form is better.
|
|
|
|
|
|
I have seen many discussions about this subject on this site. You may try a search to see if you can find them. Anyways, I use the first method for classes annd functions but the second for just about everything else. To me it is a matter of saving space.
John
|
|
|
|
|
I've used both styles, read code using both styles, debugged code using both styles, and as far as I'm concerned, I have no problem with either form. It's not really brace matching I have problems with -- it's parens (I once spent almost a day trying to debug a parser written in Scheme that boiled down to a missing end paren... paren matching? What's that?)
- Mike
|
|
|
|
|
The only reasonable reason for formating you code like this
class Cat {
// codes
};
is because the amount of space in published works (a.k.a books) is limited and you need to squeese the code so you can display it in less space. But formating your like this can lead to problems when debuging your code. I used this format some years back and I need to appoligise to anyone who is required to maintain it.
Trust in the code Luke. Yea right!
|
|
|
|
|
1. MFC dialog app is created
2. 2nd modeless dialog is created with extended style WS_EX_APPWINDOW, it's then shown and updated. The parent is set to null or desktop with SetParent(NULL) or SetParent(GetDesktopWindow())
3. Main dialog window is minimized, and as it is, the taskbar space for the non-modal disappears and the non-modal dialog is also minimized
4. NO, i repeat NO messages at all are sent to the non-modal dialog such as you would expect (ex. WM_SIZE message).
My Question is simple, what the heck is going on? How does one stop MFC from stealing the non-modal dialog's messages and reducing it automatically and removing it's taskbar space?
So far no one has been able to answer this
hey
|
|
|
|
|
Is it possible to customize the windows task bar (not the system tray) items so that you can change the text that appears next to the task bar icon for an application? Also could you replace the text that appears next to the icon by a bitmap.
That is instead of having "<mfc icon=""> MyApp.exe" appear in the windows task bar, you could have "<mfc icon=""> MyApplication" or "<mfc icon=""> 'A Bitmap'".
There seem to be a lot of articles on the system tray, but I havent seen any on the task bar.
Many thanks
3green
|
|
|
|
|
AFAIK Windows displays the Main Window title and it's icon on the task bar.
The title can be set with SetWindowText
in MFC, it's taken from the resource string IDR_MAINFRAME and optionally the current document name is added. The icon is the IDR_MAINFRAME icon resource.
Helped?
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
For a dialog-based app:
* Use SetWindowText of the main dialog to set the dialog's title - this text will also appear in the task bar
* Design two dialog resources, one 16x16, the other 32x32, use LoadImage to load them, then use the Dialog's SetIcon to set both the small and the large icon (the small one will be displayed as the dialog's system emnu, and in the taskbar. the large one will be displayed when Alt-Tabbing between apps, as EXE icon in IE, etc.)
There is no documented method (at least none I'm aware of) to show something else in the task bar than in the dialog title. However, there were one or two samples at CP showing how the Taskbar can be rearranged (it's really only a group of radio buttons) - they could have tips how you can customitze them.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
What is the *real* purpose of this file and how to use it? Please tell me the secret (if somebody knows).
|
|
|
|
|
is there any function or idea which can monitor direcrory (delete, copy, replace, edit files and sub-directory) of windows 95?
thx
includeh10
|
|
|
|
|
One solution is FindFirstChangeNotification().
Kuphryn
|
|
|
|
|
you may want to go to amazon.com and looking up windows shell programming by dino espisito. They still sell it new on e-book
hey
|
|
|
|
|
When writing a MFC app (typically MDI type), how do people usually store the configuration options ? The samples I've looked at usually don't save them so you have to reset any option whe nyou restart the application.
Preferred methods or any to avoid ?
Thanks.
Elaine
The tigress is here
|
|
|
|
|
One solution is the registry.
Kuphryn
|
|
|
|