|
i want to convert the string "2003-8-27 20:30:26" to a CTime
object.how can i do?
thanks!
Habbit--Beginner In MFC
|
|
|
|
|
COleDateTime::ParseDateTime()
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I posted this in the FAQ section but didnt receive a reply, assuming that no one really visits that message board, I decided to post here, PLEASE feel free to delete that post, I am NOT cross-posting(at least I dont intend to anyways, )
I read FAQ 2.5[C++ Faqs] as well as the relevant topics on MSDN but didn't get this:
1) What is the difference between using *automatic pre compiled headers* and *creating/using pre compiled headers*[presumably only through using stdafx.h and stafx.cpp]
2) Which is better and why?
3) *When* is it advisable to use either and why.
Sorry I can't be more specific , but this is all I know at this time and am going crazy reading MSDN which offers little to me at this time.
Thanks in advance!
Any help will be appreciated.
|
|
|
|
|
My personal opinoin - I always use the "Automatic" option. It is nice because if a source file has the precompiled header (e.g., "stdafx.h") as its first include, it uses it. If not, it doesn't use precompiled headers for that file. You don't have to worry about any funky build steps to make the PCH either (I seem to recall running into situations where I have to build the PCH separately or specially if I use the "Use precompiled headers" option.
And for really small projects, with say one or two CPP files, I don't use precompiled headers at all.
I know that's not very comprehensive, but it's what works for me.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Thanks for the reply.
Please allow me to rephrase my question and ask a few more as well.
1) I do know *how* to use the stdafx.h/cpp files and hence the *Creating/using precompiled headers * options.
What I do now is that I include all Window and STL Headers that I need in the project in the stdafx.h file and then include this file as the firstinclude in every other file of the project and using the options, I select *Using precompiled headers * for all these files and *Create precompiled headers * for the stdafx.cpp.
So far so good.. or is it? Can someone please comment.
2) I include the statement
using namespace std;
within the stdafx.h file! Is that right?
3) When if at all would it be beneficial(implying reduced compile time and all the other benefits of using precompiled headers.....which are......? ) to use the *automatic precompiled header* option?
4) How does one use the automatic precompiled header option,
i)Select the option from the avialble compiler options
ii)Use the default or otherwise specify the name for the.pch file
iii)Use the
#pragma hdrstop
directive after including each and every header file that you need in eachand every file that needs to include them,
Can someone please confirm if this is right.
5) Is it better to have ONE header file [as I get currently] that has ALL the includes that might be needed by the entire project OR should one include each and eevry header file explicitly in the source files. Which in your opinion is a better option and why!
THANKS again.
|
|
|
|
|
1.
I use the "Automatic" becuase every now and then a file I need won't have "#inclue stdafx.h" in it. "Automatic" simply means, if a CPP File has, say "#inclue stdafx.h" then it assumes it is using a precompiled header. If not, go on and compile the file 'normally'. This also means you never have to go file by file and set up precompiled header info - you just have one setting for the whole project. The way you're doing it will work though, I just have my own preference.
2.
I probably wouldn't put "using std;" in there simply because that defeats the whole purpose of having "std" in a namespace. Although I suppose it is a convenience issue, really, it won't hurt anything if you konw you will never have name clashes with any of the std stuff.
3. See the answer to 1.
4. As far as "pragma hdrstop", I've never seen that in VC code, I do remember using it in Borland C++ (ah, remember those days ). The only stuff that gets precompiled is what's in "stdafx.h" (AFAIK.)
5. Here's the kind of stuff I put in my stdafx.h (or equivilant):
MFC and STL headers
My own headers for stable classes that rarely change but are included a lot
Any funky defines and such that should apply to every file in the project
It's a bad idea to have every header in your project in there, or to have one big header that includes everything. Two reasons:
It makes it very difficult to sort out components that you may someday move to another project or a common area.
If *any* include changes, you'll have to rebuild your WHOLE project.
I usually have one class per CPP/H pair. And just include whatever stuff is necessary when it is necessary. stdafx.h gets stuff that truly is common across all (or at least many) modules.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Other opinions vary;
1. Yes, that's fine.
2. I wouldn't necessarily have the 'using namespace', but I might put it in the top of selected sources that use 'std' stuff. I almost never have a 'using namespace' in a header.
3. No difference in terms of compile time etc between automatic and using/create.
4. I don't. Occasionally to include a C/C++ file from some legacy code this means having to turn off 'use precompiled headers' for the odd file, but hey, that's what the project settings are for.
5. Depends. I tend to have Win32, standard, STL, ATL and WTL headers only in stdafx, as they aren't going to change. Individual modules (CPP files) then have only the extra '#include's that they need. That way, altering a project specific header doesn't recompile the whole project.
Unrelated to the question but relevant, unless you're happy to waste hours -- use a source code management system.
Steve S
|
|
|
|
|
Guys, Anyone knows where I can download the Microsoft 'C' Compiler 6.00?
I need to make some changes to an old project built using this compiler and I need to recompile the project using the MS C 6.0 compiler.
I know that with some changes I could compile with MS VC++ or even Turbo C++, but my client _requires_ me to use MS C 6.0 compiler because of (reasons)...
modified 25-May-20 21:47pm.
|
|
|
|
|
Legally, you can't. It isn't part of MSDN (they only go back to VC++ 1.52c which is v7 or v8. I faced a similar problem here with a client who had source/executables but no compiler and they needed some changes, but fortunately, I've been using MS C since 5.00, and every time I upgraded, I kept the old disks. As time has gone by, I've had to copy them all to CD so that my newer machines can still access them, since 5 1/4" floppies aren't too common these days.
You *should* be able to use VC1.5 to do the work, then a final build with C6 if someone near you has a copy. I certainly ported a lot of stuff from 6 to VC++ 1.5 with very little work. Hardest was figuring out the right project settings.
I can understand why they want you to use C6. They probably feel it's safer, since that was the original tool, and unless you use C6, C7 (aka VC++1.0) or 1.5, you can't produce a DOS application.
Steve S
|
|
|
|
|
Hi Steve, thank you for getting back to me.
The changes to the project are already being done, I'll just need the compiler
Is there anyway I can buy it from Microsoft? I've searched MS site, but can't find anything.
modified 25-May-20 21:46pm.
|
|
|
|
|
We need to pass a struct from CMyapp to CMyDoc. Is it possible to do
this, and how painfull will it be.
Thanks in advance
-Fred
|
|
|
|
|
The app could (selectively) allow the doc could access it by exposing a getAtComplexData() API. Your doc would do:
CMyApp* pMyApp = (CMyApp *) AfxGetApp();
ASSERT (pMyApp != NULL);
ComplexData* pComplexData = pMyApp->getAtComplexData (this);
if (pComplexData != NULL) {
...
}
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
You have a few options available.
As the structure exists in the application class (CMyApp), you can create a member function that returns the address of this structure.
Now, if this method is called from inside CMyDoc, the document has the address of the structure, and can operate on it freely, providing that both objects reside on the same thread. If they do not, things get more complicated.
Alternatively, taking an advanced step from the section above, you can create a structure into CMyDoc as well, then get a pointer from CMyApp and use memcpy to copy the structure data from CMyApp to CMyDoc. Now, CMyDoc contains a copy of the structure.
The previous posted created an example piece to show you how to access the application object at run-time. Use this method to call the function that returns the structure address.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi everyone I get an assertion error when I try to iniatialize the contents of the controls of CDialog derived class of Edit boxes and Combo boxes. I try to initialise them at the constructor. Of course I have attached member variables to each control.
The initialization code works well when for instance I trigger, execute it by a button click.
Can anyone help?
|
|
|
|
|
One solution is to initialize the controls in OnInitDialog().
Kuphryn
|
|
|
|
|
The assertion is probably something like ASSERT( ::IsWindow( m_hWnd ) );
This happens because while in the constructor, your dialog is not actually a real window yet. The MFC classes, such as CDialog, are wrappers around the real windows which are represented by HWNDs. This means that there is two stage initialisation: firstly the CDialog (or equivalent) object must be created, and then secondly, the real window must be created, or the MFC object must be attached to an existing real window. The consequence of this is that within the object's constructor, you cannot call any methods or use any member variables that expect the dialog to be created as yet. The member variables for the edit boxes get attached to the real edit controls during the first call to DoDataExchange(), but this is not called until somewhere inside CDialog::OnInitDialog(). Until that has been called, your member variables are not yet attached to real windows, and so will assert if you try to call methods that assume otherwise.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Can anyone think of a reason why
keybd_event(45,NULL,KEYEVENTF_KEYUP,NULL);//for keyup message
would work, but not
keybd_event(45,NULL,NULL,NULL);//for keydown message
?
halblonious
|
|
|
|
|
Anyone know what a game engine is and what it does?? HELP??
<marquee>Universal Project
|
|
|
|
|
Well google is your friend, but I'll have a go anways
A game engine is typically a library of code that is dedicated to handling the low level graphics functionality, and then packaging this up with nice easy to use high level function calls. They typically are 3D oriented, and allow for building a full scenegraph, managing the graph, rendering the shapes, adding textures, animating the shapes, and possibly add extra things like collision detections, a set of physics rules for objects, etc. Some engines may even include rudimentary AI that can be assigned to characters.
Basically the game engine takes care of the graphics basics so you can concentrate more on the specifics of your game rather than worrying how to display a 3D toroid.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
(as far as I understand )
a game engine is exactly what the name implies, it is what makes the game run, usually provide the basic framework for animation, level designs, weapons, game sequences, rendering, maybe some physics.
it helps you focus on the meat of the game, instead of the skeleton of the game.
google for unreal game engine or Bioware Infinity Engine
or have a look at http://www.gamasutra.com/[^] for computer game programming issues.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
hi.,
I have a MDI program with a few dialog boxes,
whenever i call the UpdateData() function within the dialog box
i get an ASSERT error,
is there any other way to update my data in the dialog box??
Ehsan Behboudi
|
|
|
|
|
Avoid using UpdateData() unless you really understand it and know that an alternative does not exist. Use control variables instead and things will be much smoother.
What is the file/line that is firing the assertion? Chances are that it is in the DoDataExchange() function of your dialog class. Have you stepped into the code to see what is happening?
|
|
|
|
|
i use UpdateData() in my other dialog box with in the same program, and it never gave me any problems,
The part/line that fires the ASSERT is within the UpdateData() code.
you mentioned that I can use control variables !!!
what is that? and how can I use that?
in my dialog, i have 5 boxes that i just need to update their numbers (double)
Ehsan Behboudi
|
|
|
|
|
Problems aren't guaranteed, but they can appear if precautions aren't taken.
http://flounder.com/updatedata.htm
double d1, d2, d3;
CString strText;
strText.Format("", d1);
m_edit1.SetWindowText(strText);
strText.Format("", d2);
m_edit2.SetWindowText(strText);
strText.Format("", d3);
m_edit3.SetWindowText(strText);
is the easiest, most straightforward, and doesn't mess with any of the other controls/variables like UpdateData() does.
|
|
|
|
|
okay,,, thanks, i read the website too
but what i don't get is,, what is m_edit1???
in my dialog i have few edit box,, and assigned a double variable to each.
i don't really get what m_edit1 is?
Ehsan Behboudi
|
|
|
|
|