|
Hello,
For years I was using a methodology described in Ellemtel Code Conventions and Rules[^], but lately I had a discussion with a collegue about the order of #include files on a C/C++ source file.
The header files contain:
- All header files contain a technique for preventing multiple inclusion
- All modules contain a public header file for providing prototypes and other dirty stuff towards the world. (most of the cases all the modules contain a pair of files: header and implementation)
- Some modules have also a private header file.
- Any header file can contain preprocessor stuff, type definitions, global variables. and function prototypes
What is the order you think these include files should appear on any implementation file? (pick them out of the list below)
- Group A: System header files(
#include <....> ) - Group B: Public header file for the file.
- Group C: Private header file for the module if any.
- Group D: Other header files from your code.
In your oppinion, what is the correct include order? (Based on your experience/knowledge)
I
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
|
|
|
|
|
Typically (for me), it would be...
#include "stdafx.h"
#include <afxtempl.h>
#include <string>
etc.
#include <Utilities.h>
#include <<a href = "http://www.codeproject.com/buttonctrl/LedButton.asp">LedButton.h</a>[<a href = "http://www.codeproject.com/buttonctrl/LedButton.asp" target = "_blank">^</a>]>
#include <ThisDll.h>
#include "ThisClass.h"
#include "resource.h"
I make sure headers files I've written come after "system" ones, to make sure I
don't mess up any defines, etc. In practise, it matters very rarely. But it has
mattered in the past, so I try to be good!
Iain.
|
|
|
|
|
Hi
Although is not strictly what you are asking it may be a usefull information.
Order usually matters when a header file is not well written. This means that either it does not contain required definitions (thus relies on a accidental inclusion of another header file above to be completed) or two headers contain the same definition and when they are both included may produce problems. Thus, despite the chosen order a good advice is to write your private headers carefully.
Personaly when I write them I follow the following style: Assyme that I write a header called myheder.h. It would be in the style
// A unique symbol to protect my code
#ifndef MY_APP_MY_HEADER_H
#define MY_APP_MY_HEADER_H 1
..... include headers required for that header file
.... write here the actual header code
#endif /* MY_APP_MY_HEADER_H */
Headers written this way are guaranteed to be included once and be self contain. Their inclusion then is order independant.
|
|
|
|
|
Hi, this is my first post so I'll try to sound like I know what I'm talking about... :->
I want to make an application in VC++ to emulate a drive on windows (ex H: ) and use it to access files that are stored on an ftp server (like South River Technologies' WebDrive does). I just don't know where to find documentation on how to emulate a drive on windows OS. Any pointers would be appreciated
Matt
|
|
|
|
|
Have a look at Shell Namespace Extensions. There's a few articles around here that should help, particularly the ones by Michael Dunn.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks, that's exacly what I was looking for
|
|
|
|
|
I really have no experience when it comes to creating documents for printing. Actually, I do not know anything when it comes to writing code for printing. For example, in a database application which I wrote about a year and half ago I would like to add the capability of creating reports similar to those in Access. I do not know from where to begin. Do I just create a window and then I add text and lines to it and then send that window to a printer? This is the only idea that pops into my head but it sounds so inefficient.
Is there a place online where I can read some tutorials? It doesn't really have to be about creating reports but something similar about creating documents and printing them.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
You've got lots of choices, but it depends on what dependancies you can afford to introduce into your software.
If you already have the reports in access how about using access via the COM automation interfaces. Alternatively word automation is probably easier to get started with, especially if you want to construct temporary html files and then load them in word, or use ShellExecute api to print. If clients can't be guaranteed to have office you could also use IWebBrowser2 and related interfaces (perhaps IHTMLWindow3) to provide a low dependancy (only the standard internet explorer control) printing method - I haven't used this approach but I don't see it being too hard.
Another report generation idea is to convert the results of queries to xml and then use xslt as a flexible and extensible formatting system.
Alternatively MFC has extensive documentation on printing.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Printing is very similar to drawing on the screen - you use a device context and draw to it. The only thing you really have to watch out for is separating the documents into pages (CDC::BeginPage() and CDC::EndPage() in MFC) and remember that the printing resolution is a lot higher than the screen, so use CDC::GetDeviceCaps() to get the DPI of the printer. Use CPrintDialog to show the print dialog to the user, and the dialog also returns a device context for the printer which is already setup, so all you'll need to do is draw to the DC. Have a look at the documentation for more info, but it really is actually quite easy.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
In addition to the previous advice, you would do well to search for articles on codeproject
by its defacto printing guru Roger Allen[^]. He has quite a few printing articles, with and
without views, etc. He's also a nice chap, but tell him I said that. He'll get big headed.
Iain.
|
|
|
|
|
Hi Toni
If you want to make more complex reports, i would suggest to check the functionality of some report systems like list&label or crystal reports. I especially know list&label and you can create your reports almost with drag and drop and fill them with data.
|
|
|
|
|
Thank you very much for your replies everyone.
// Afterall, I realized that even my comment lines have bugs
|
|
|
|
|
What is difference between "true" and "TRUE" key words in vc++.Like wise with "false" and "FALSE".
Can any help me regarding this matter.
Philip
|
|
|
|
|
Actually I think you going for Difference Between bool and BOOL.
Let See what MSDN say about bool
"
the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0 and later, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0 and later, the same call yields 1.
"
and BOOL is defined as int in WinDef.h
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
bool is a C++ native type, which is taking 1 byte memory, and that can only take true or false .
BOOL is a type redefined by the VC++ library, like this :
<font color=#0000FF>typedef enum </font> {
FALSE = 0,
TRUE
} BOOL;
this last case equals in memory to an int, so, weights 4 bytes...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
int, so, weights 4 bytes
Isn't this value dependant of the OS and the hardware?
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
of course, but unless you use an atari....... i consider we can think about 4 bytes integers here
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I know, I'm "cutting hair in 4 pieces" ( ) but with the new 64bits CPU and OS, there will be some nice surprises with softwares which made the assumption int variables have a size of 32 bits.
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
On this topic, I have to add this bit;
Some developers prefer to use the following syntax;
bool bFlagIsSet = false;
if (bFlagIsSet == true)
// do something
else
// do something else
instead of;
bool bFlagIsSet = false;
if (bFlagIsSet)
// do something
else
// do something else
fair enough - each to their own. But doing this with the BOOL type, since TRUE is defined as -1, could cause unexpected behaviour;
BOOL Func()
{
return 1; // return true
}
BOOL bFlagFromFunctionThatReturnsBOOL = Func();
if (bFlagIsSet == TRUE)
// this won't happen, but is expected to
else
// stuff
So, the easy rule to remember there is, always check against FALSE, since it's value is always 0, like so;
BOOL Func()
{
return 1; // return true
}
BOOL bFlagFromFunctionThatReturnsBOOL = Func();
if (bFlagIsSet != FALSE)
// this will now work properly
else
// stuff
That's my 2p
(and maybe not related at all)
Martin
|
|
|
|
|
hi,anyone here,i want Powerpoint's presentations to be displayed in my program's window,and can control its "Slides" ,"Scale" ,"Display Position" and so on...i think the OLE can resolve that,but i don't know how to do.If you have a good idea please reply at here ,or mailto: sdcgc@yahoo.com
thanks in advance!
|
|
|
|
|
I've tried to do that before. Basically, you can't. You can't tell PowerPoing where to show its presentation, and if you try to change the parent/owner of the PowerPoint slide show window, PowerPoint exits (it doesn't crash, but immediately exits). You can change the position of the window to make it appear that it's in your window, but you also need to do some pretty horrible hook work to allow your application to capture the mouse events.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
There is a way to fake it. Interested in hearing it ?
|
|
|
|
|
Use the Web Browser control and tell it to navigate to the document you want to open. When the navigation completes you get the iDisp and you can control everything you want.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
thanks for your advices
How to fake it? please give more details,thanks:->
Now i use OLE container application which can open the PPT file,but only the first page was displayed.What methods can be used to let it slide on?please help me
|
|
|
|
|
On Windows XP sp1, I use these three Directshow filters: DV Video Encoder, Stream Buffer Sink and Stream Buffer Source to implement the timeshifting function, and it works well, But on the Windows XP sp2, it has serious delays. I don’t know why and how to solve the problem ,Please give me some advice .Thanks
|
|
|
|