|
Is fstream the usual way how people do file IO. In my case I wanted to save a string to a file. I didnt know whether htis should go into a CArchive object. in fact I havent got a clue when it comes to CArchive and serialisation. It seems a complicated subject.... Can I put strings/ints etc into archives and then pass them to serialize()
thanks in advance
|
|
|
|
|
If you're using MFC, just (typing from memory here, not pasting - so excuse any typos -the help for CFile::Write has examples I believe)
-----
CFile savestring;
savestring.Open("Myfile.txt", CFile::modeWrite);
size = myString.getLength()+1; //use whatever you need. Not sure if buffer rqd.
savestirng.Write( myString.getBuffer(size), size);
savestring.Close();
If you have a format for the line, you can just as easily write out your storage class in the 'Write'.
CArchive seemed like more of a hassle than just writing things out myself - I messed with it for awhile but had problems with the arrangement of the various macros for Implement_Dynamic and whatnot.
--Mark Terrano
www.ensemblestudios.com
(Creators of the Age of Empires series)
|
|
|
|
|
template < template < class TYPE > class COORD >
class vector : public COORD
{
public:
TYPE& operator[]( const int nIndex )
{
return ( ( TYPE *) this[ nIndex] );
}
};
|
|
|
|
|
|
Infinite recursion... the subscript operator (I think that’s what its called) calls itself over and over again...
BTW: Are you using the STL's? I don’t think you should be using ‘vector’ as a class name (unless you've wrapped it all in a common namespace).
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I think I find what is the problem.
The problem become from VC++ which doesn't support nested templates.
|
|
|
|
|
> The problem become from VC++ which doesn't support nested templates.
sure it does, how would the STL work? All the iterators declared within the class that they apply to. e.g. vector::iterator.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
> The problem become from VC++ which doesn't support
> nested templates.
Hmmm... Are you simply trying to derive vector from template class COORD?
If yes, it should look like this:
template <class T>
class vector : public COORD<T>
{
// vector members here
};
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
The problem is that I want different Dimension Coords
template < typename TYPE >
struct Coord3
{
TYPE x;
TYPE y;
TYPE z;
typedef TYPE TYPE_NAME;
};
template < typename TYPE >
struct Coord4
{
TYPE x;
TYPE y;
TYPE z;
TYPE w;
typedef TYPE TYPE_NAME;
};
template < class dimention >
class vector : public dimention
{
private:
typedef dimention::TYPE_NAME TYPE;
TYPE& operator[]( const int nIndex )
{
ASSERT( 0 >= nIndex && nIndex < sizeof(this ) / sizeof( TYPE ) );
return ( ( TYPE *) this)[ nIndex ];
};
};
typedef vector< Coord3< float > > vector3f;
typedef vector< Coord4< float > > vector4f;
|
|
|
|
|
> The problem is that I want different Dimension Coords
> [...]
> typedef vector< Coord3< float > > vector3f
So where's the problem related to nested templates?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hey,
I have a WTL MDI project and i search to implement Drag&drop.
Is it possible ??
Thanks,
Ptit Seb
|
|
|
|
|
WTL does not have any drag&drop support built-in.
There is a DragImg sample on the Platform SDK that may help if you are trying to get items onto the OLE clipboard:
Samples\WinUI\Shell\DragImg
For other WTL questions, in the future you may want to try the WTL newsgroup:
http://egroups.yahoo.com/group/wtl
|
|
|
|
|
I am encountering a problem when I try to append to the end of a CString, specifically in unicode. I can append several times, but it seems that there is some sort of limit to how long a CString can be? After I "+=" up to about 167 characters, it no longer displays the additional characters, yet continues to increase the size when I call GetLength(). Any ideas on what is going on?
|
|
|
|
|
What function are you using for output? Maybe it's ANSI variant and 167th character contains zero?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I found the problem. Important lesson: make sure you _T() EVERY literal and not just some, or in this case, all but one.
Thanks
|
|
|
|
|
Hi,
I previously posted a thread to ask how it is possible to detect that an application is launched.
Indeed I don't want to detect that a *particular* program is launched, but to detect that an application (not a specific one) has been launch.
This can allow to have a sleeping process that wakes-up only each time an application is launched, do something, then goes back sleeping.
This way the "monitoring" process does not consume CPU by always checking if there is something new among the list of the process.
--Francois
|
|
|
|
|
Seems that you need a global hook DLL. Windows will map your DLL into memory space of every process in the system, so you'll be able to detect new processes right after launching them - DllMain of hook DLL will receive DLL_PROCESS_ATTACH as dwReason. This should work on Win9X and NT.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi,
I have an MDI application, I like to open files with one one command.
my files are like MRI001.bmp ,MRI002.bmp ,MRI003.bmp, and so on.
I have a diolog box that will ask the user to input the fist file path (c:\MRI001.bmp) and the last file path(c:\MRI0010.bmp),
when the user clicks 'OK', I like to have all the files opened from MRI001.bmp to MRI0010.bmp
Any ideas how I can do this?
I'm a beginner, can someone write me a bit of the code..
Thanks
Ehsan Behboudi
|
|
|
|
|
|
I have already seen how to create an simple automation which could open known workbook and worksheet. But, after this step I would like to catch some cells.value, and after send those value as parameter to a function implement in c++.
If anybody know an article or have done this kind of exercise, I will appreciate his help.
Thanks
Gerald
|
|
|
|
|
|
Hi!
I need to get a notification message from my Doc/View RichEditCtrl. In order to use OnNotify, I need to know the ID of the control ( ON_NOTIFY( wNotifyCode, id, memberFxn ) ). I have been unable to find it.
Does anyone know how to solve this? Or get around it?
Thanks!!
Ilan Kleinberger
ilan25@hotmail.com
NOTE!!! my replay address is spam protected make sure you remove the extra junk, if you want to reply directly. Thanks
You're nobody, 'till you've been ignored by a cat.
|
|
|
|
|
The ID is AFX_IDW_PANE_FIRST if you don't use splitters. However, the best way to handle notifications is in CRichEditView-derived class itself. Just use ON_NOTIFY_REFLECT macro instead of ON_NOTIFY in the message map of your view:
ON_NOTIFY_REFLECT(EN_SELCHANGE, OnSelChange)
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hai
I want to put my structure containing two CPoint variables into VARIANT
array and assign to DISPPARAMS.I need variant array of this structure.
How can I do it?
Thanks
Pathi Gorantla
bhikshapathi_g@semanticspace.com
|
|
|
|
|
See http://msdn.microsoft.com/library/periodic/period96/activex0696.htm
Mh2!
|
|
|
|