|
LiYS wrote: That was confirmed!
I am lil Confused! what was confirmed?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
to complete alok's answer, don't use the cast operator to LPCTSTR this way.
change the LPCTSTR(...) into (LPCTSTR)... .
refer this[^] to understand...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
-- modified at 4:42 Tuesday 27th December, 2005
|
|
|
|
|
toxcct wrote: change the LPCTSTR(...) into (LPCTSTR)....
I'll try that, thanks!
But here's another Que I encountered!
I can't use GetCurrentDirectory(...), I always get compiler error saying "identifier not found". Is it because of the project I started.
I started the project as VC++/SmartDevice
|
|
|
|
|
toxcct wrote: change the LPCTSTR(...) into (LPCTSTR)....
if ( ! file.Open( (LPCTSTR)"C:\\Test.xml", CFile::modeRead ) )
doesn't works either!
|
|
|
|
|
try
if ( ! file.Open( _T("C:\\Test.xml"), CFile::modeRead ) )
<hr<span style="color:gray;size:15px;">Prakash
Prakash
|
|
|
|
|
Is the file been used by another application
i tried a code similer to the above one and it worked fine
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Are you sure there is a file with that name. Check the extension,name etc... to make sure
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
LiYS wrote: CFile file;
if ( ! file.Open(LPCTSTR ("C:\\Test.xml"), CFile::modeRead ) ) { return; }
If this code is in function X, then as soon as you leave function X, the CFile object is destroyed (it goes out of scope). Thus the file will be closed.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
hi friends
i have created one object called pIImage. I have to give the object pIImage as A argument to AddImage(). IN VARIANT type. how to convert one object to VARIANT type
eg.
hr = CoCreateInstance(CLSID_Image,NULL,CLSCTX_INPROC_SERVER,IID_IImage,(void **)&pIImage);
pDoc->AddImage(pIImage)
error C2664: 'AddImage' : cannot convert parameter 1 from 'struct XYZ5::IImage *' to 'struct tagVARIANT'
Shadrach
|
|
|
|
|
If you look more closely at VARIANT constructors (more precisely, at _variant_t , you'll notice that one of them accepts IUnknown* and bool arguments. This is exactly what you need:
pDoc->AddImage(_variant_t(pIImage, true));
|
|
|
|
|
Hi,
I created a template class, just like:
template < typename TYPE, typename TYPE_ARG = TYPE > class DataList
{
public:
void AddNode( TYPE_ARG val_i )
{
SetVal( val_i, valNew );
}
protected:
struct NODE
{
NODE* pNext;
TYPE val;
};
virtual void SetVal( TYPE_ARG valSrc_i, TYPE& valDst_o )
{
val = val_i;
}
};
This is only a model. I use this class for a general purpose linked list.
I derived a class for string handling, just like:
class StringDataList : public DataList < LPTSTR, LPCTSTR >
{
private:
void SetVal( LPCTSTR valSrc_i, LPTSTR& valDst_o )
{
valDst_o = new TCHAR[ lstrlen( valSrc_i ) ];
lstrcpy( valDst_o, valSrc_i );
}
};
Thus I can use the template class for both numeric data handling and string handling.
For example:
DataList < int, int > intDataList;
StringDataList strDataList;
The real problem is, we assume that the input parameters should be const, especially for pointers (that's why I use LPCTSTR as TYPE_ARG in StringDataList).
So the compiler shows error in the base class while compiling StringDataList.
The error is error C2440: '=' : cannot convert from 'const char *' to 'char *'
If I change the TYPE_ARG to TYPE in the SetVal of template class, another problem arises. That is in the AddNode. It is written as to pass the const input value to the SetVal. To clear it, I have to change the input from TYPE_ARG to TYPE. It is OK for all the classes passing value, but for string type, it is not advisable.
One solution is, I think, use type cast in SetVal, just like
val = TYPE( val_i )
Is there any other better solution?
Thank you.
- NS -
|
|
|
|
|
I think we had a discussion on constant string
when u had put up a question before few days.
I have already lost that data but will try again
for the same
but the changes u have done in the class are
quiet good.
Pls put up ur class on codeproj when u acomplish it
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi
Is the GUID of a COM object unique through out the network or unique through out the world
|
|
|
|
|
Theoretically, it's unique, as they call it, 'both in time and in space', but it depends on the actual algorithm used to generate UUIDs. However, you can be reasonably confident that these are unique.
|
|
|
|
|
I have code like this:
<br />
BOOL f() {<br />
...<br />
__try {<br />
...<br />
}__except(EXCEPTION_EXECUTE_HANDLER)<br />
{<br />
...<br />
}<br />
<br />
Object o;<br />
}<br />
The object declaration of variable 'o' is outside the __try/__except construct. I get the error:
warning C4509: nonstandard extension used: 'f' uses SEH and 'o' has destructor
Why is this so? I was thinking this should not be an issue as even if an exception is thrown, it will be handled by the __except block, and the exception stuff would end there. The object o is then created.
What can I do to fix this error?
thanks!
|
|
|
|
|
firstly, it is not an error, it is a warning. that means that the compiler saw that there is some coude that may cause some trouble, but non blocking for the execution of the program.
i have one question however. why are you using __try /__except instead of try /catch ?
refering to the MSDN[^], you have to declare o before the exception handling... (SEH means structured exception handling).
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
-- modified at 4:56 Tuesday 27th December, 2005
|
|
|
|
|
I am writing a C/C++ code using EXPAT parser which convert a text file to XML file. Can someone pls let me know how to go about, sample application is appreciated?
Anil
|
|
|
|
|
I have a question?
Are static members automatically removed from the HEAP or do we have to remove it manually.
Thanks.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I think your question is invalid.
Static members are never allocated on heap.
Vipin - MVP
|
|
|
|
|
Is there any good article on net
for the allocation for memory .
regarding diffrent variables and fuctions .
thank u
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
asdfkjsodifuweior wrote: Static members are never allocated on heap.
Then where are they allocated buddy. Tell me.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
-- modified at 0:58 Tuesday 27th December, 2005
|
|
|
|
|
|
JIANG, Sheng[MVP] wrote: on the stack.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
|
JIANG, Sheng[MVP] wrote: depends on the compiler
Thanks for that.
But now if it is allocated on the HEAP do we have to do the cleaning by ourselves.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|