|
The solution is much easier than you think. Just modify the default parameter of CMAPIEx::OpenMessageStore by removing the value MAPI_NO_CACHE and leaving anly MAPI_MODIFY and everything will work just fine with Outlook2003 too and WindowXP or a newer version.
|
|
|
|
|
Hi,
May i know really when "this" pointer is helpful and how...if possible with sample....Please don"t mind as im a beginner for c++.....
and if i made dynamic memory allocation using stack pointer is it necessary to delete it.. because when the function ends it is automatically freed right...?
Please let me know....
|
|
|
|
|
This is usefull to pass the "current" object to a function/method.
for example :
void DoSomething(MyClass* pMyClass )
{
}
void MyClass::MyMethod()
{
DoSomething(this);
}
It's also usefull (because of laziness), when finding methods with intellisense:
in a method
void MyClass::MyMethod()
{
this->(press-ctrl-space to find/list methods of MyClass )...
}
other than that, I don't see much use.
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: other than that, I don't see much use.
Because you don't overload the assignment operator [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
pradeep455 wrote: May i know really when "this" pointer is helpful and how...if possible with sample....Please don"t mind as im a beginner for c++.....
It may be useful to avoid name conflicts, as in the following example
class A
{
int items;
public:
A(int items){ this->items = items;}
};
It is needed, however when overloading some operators, see, for instance, [^].
pradeep455 wrote: and if i made dynamic memory allocation using stack pointer is it necessary to delete it.. because when the function ends it is automatically freed right...?
If you allocate (statically: dynamic allocation happens only in the heap) objects on the stack then you don't have to release memory for them.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Do not listen to Maximilien, he is wrong.
pradeep455 wrote: and if i made dynamic memory allocation using stack pointer is it necessary to delete it.. because when the function ends it is automatically freed right...?
Not able to answer due to the words you choose. Dynamic Memory would normally be used in reference to heap allocations, not stack memory. Based on what you posted I can't be sure what you mean but all heap allocations require freeing of the allocated memory.
Most importantly, I strongly urge you not to try and learn C++ from internet forums. There are decent tutorials available on the internet. However books would be far superior. If you decide on books, I recommend you take some time to read the intended audience of a book to see if it is appropriate for you, then if it is, do some research on reviews of the book.
|
|
|
|
|
completly or partially ?
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: other than that, I don't see much use.
That is wrong, so are you partially or completely wrong? You will have to answer that for yourself.
I'm outa here, have a great weekend!
|
|
|
|
|
Well, I caved myself in.
This signature was proudly tested on animals.
|
|
|
|
|
Hi all,
i tried of a calendar control always focusing on month
but if we change the year/date, while getting back focus again on year/date
but actually i need the focus on month
i tried using SetCaretPos(); method but i didn't get the result
is there any other way to handle it
Thanks in advance,
Jeeva
|
|
|
|
|
Hi,
In my apllication , iam having a propertypage
In that I hide the Help,Ok,CANCEL and APPLY Button. (GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE); …)
But I cant do like this in “x” close button ,which was in propertypage TitleBar Right.
Through Net I got the help for Enable the “x” button , but iwant to hide it.
Give u’r suggestion for remove the “x” close button from property page.
Thanks in Advanc
Regards
shakumar
shakumar
|
|
|
|
|
Try removing the WS_SYSMENU[^] style from the window you want to hide the 'X' of using CWnd::ModifyStyle[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks for u'r Reply
I tryied like this
PreCreateWindow(CREATESTRUCT& cs)
{
if ( !CSampleDlg::PreCreateWindow(cs) )
return FALSE;
// Remove the system menu style bit from the window
cs.style &= ~WS_SYSMENU;
return TRUE;
}
then also it is not remove the "X" Close Button.
Give any suggestion on this.
shakumar
|
|
|
|
|
Are you sure your PreCreateWindow actually gets called? Also you can try using ModifyStyle in PreSubclassWindow AFTER you have called the 'super version' or right after you have created your window using CreateWindow (if you did)...where did you hide the buttons you wanted to get rid of? Also, are you sure you are trying to modify the style of the correct window?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I am attempting to do the following:
template <class T>
class Measure {
public:
double Value;
T::UnitList Units;
virtual const T& Convert(const T::UnitList destUnits) = 0;
};
class Length : public Measure<Length> {
public:
enum UnitList {
METERS,
MILES,
};
}; Now, when I try to compile, I am getting the message,
"warning C4346: 'T::UnitList': dependent name is not a type"
which leads to the following error:
"error C2146: syntax error : missing ';' before identifier 'Units'"
I am getting all kinds of warnings/errors like this every time I refer to T::UnitList, which I believe are due to the fact that the compiler is attempting to resolve the template parameter prior to declaring the class. More specifically, I think that once the compiler begins interpreting "public Unit<length>", all that it knows about "Length" is that it is a class. The fact that the Length class contains an enum called "UnitList" is unknown to the compiler (I think). My question is, how can I go about strongly typing the "Units" variable to T::UnitList (I'm trying to avoid accepting the ambiguous int or unsigned int types)? Any help is greatly appreciated.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Replace
T::UnitList Units;
with
typename T::UnitList Units;
You need to tell the compiler that T::UnitList is actually the name of a type.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for your quick reply. That did resolve the errors/warnings I mentioned in my initial post, but I am still getting exceptions related to the underlying problem. The new exception is:
"error C2039: 'UnitList' : is not a member of 'Length'"
I believe this is related to the order in which the code is compiled, as mentioned in my original post, but am not entirely certain.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I think the g++ error messages are clearer - given a file b.cpp:
template <class T>
class Measure
{
public:
double Value;
typename T::UnitList Units;
virtual const T& Convert(const typename T::UnitList destUnits) = 0;
};
class Length : public Measure<Length>
{
public:
enum UnitList
{
METERS,
MILES,
};
virtual const Length& Convert(const UnitList destUnits)
{
}
};
I get these error messages
b.cpp: In instantiation of ‘Measure<Length>’:
b.cpp:12: instantiated from here
b.cpp:5: error: invalid use of undefined type ‘class Length’
b.cpp:12: error: forward declaration of ‘class Length’
b.cpp:7: error: invalid use of undefined type ‘class Length’
b.cpp:12: error: forward declaration of ‘class Length’
It's trying to instantiate the base class before defining Length . But that requires the compiler to have a definition for Length::UnitList ...but it can't have that until Length is defined. Which can't happen until Measure<Length> is defined!
So yeah, that's not gonna work!
You can use the CRTP[^] idiom for static polymorphism, like this - Measure will call the Flip method of the template parameter. It's really useful for implementing mix-ins[^], as used by ATL and WTL.
template <class T>
class Measure
{
public:
double Value;
virtual const T& Convert(const int destUnits)
{
static_cast<T*>(this)->Flip();
}
};
class Length : public Measure<Length>
{
public:
enum UnitList
{
METERS,
MILES,
};
virtual const Length& Convert(const UnitList destUnits)
{
Measure<Length>::Convert(1);
}
void Flip() {}
};
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Once again, thank you for your help. Your responses inspired the following solution, although it is not as clean of a solution as I would like:
template <class Derived, class UnitType>
class Measure {
public:
double Value;
UnitType Units;
virtual const Derived& Convert(const UnitType destUnits) = 0;
};
class LengthUnits {
public:
enum List {
METERS,
MILES,
};
};
class Length : public Measure<Length, LengthUnits> {
public:
};
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
One other thing...are you deriving classes from Length? If not, you're probably better off using static polymorphism (like I showed in my earlier e-mail) than dynamic polymorphism (virtual methods) if only because it could be a tad more efficient.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the advice... I never knew there was an efficiency difference between virtual vs. static casting methods.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I've got a code segment below that converts the block of chars read in from an RSS XML file and converts it to the unicode equivalent using a code page (the code page ID is determined beforehand by scanning for the the encoding ID in the XML).
Sometimes it works, sometimes it crashes the application. I'm using the buffer requirement returned by 'MultiByteToWideChar' to allocate the buffer required (+1 because the block of chars I'm passing does not include the 0 terminator). What's really odd is that on small strings it works fine, but on a 216 character string it crashes. If I extend the buffer allocation by 1 then it works all the time. I should not have to kludge buffer allocation to make things work.
int nSizeReq = MultiByteToWideChar(m_nCPID,0,(const char* m_pChars,nBlockLength,0,0);
TCHAR* pszConverted = new TCHAR[nSizeReq+1];
_tcsnset(pszConverted,0,nSizeReq+1);
MultiByteToWideChar(m_nCPID, 0, (const char*)m_pChars,nBlockLength, pszConverted, nSizeReq);
//up to here it always works, but the next step crashes because pszConverted has damage
//past its memory allocation
CString strConverted = pszConverted
Any ideas why this could be happening?
ps. it runs just great in debug, and if I run it in release mode whilst in visual studio it also works. Run the release by itself and *boom*
[edit]
Coded in C++ (MFC application) using Visual Studio 2008
Unicode is defined
Testing on Vista.
modified on Friday, March 13, 2009 10:51 AM
|
|
|
|
|
First thing I notice is the code you posted does not check the return value of MultiByteToWideChar. Therefore your next operations are running on blind faith. This is not usually considered a Software Development Best Practice.
|
|
|
|
|
Yep, you make a good point, I updated the code to check the value:
int nSizeReq = MultiByteToWideChar(m_nCPID,0,(const char* m_pChars,nBlockLength,0,0);
TCHAR* pszConverted = new TCHAR[nSizeReq+1];
_tcsnset(pszConverted,0,nSizeReq+1);
int nConverted = MultiByteToWideChar(m_nCPID, 0, (const char*)m_pChars,nBlockLength, pszConverted, nSizeReq);
int nTest = wcslen(pszConverted);
the results: nConverted = 214. nSizeReq = 214, but nTest = 206. Weird.
|
|
|
|