|
You're far better off with CW2A() et al (ATL7 and later). USES_CONVERSION is a biiiiiiig cludge. (Take a peek under the hood, and you'll see...)
--
Mr. Bender's Wardrobe by ROBOTANY 500
|
|
|
|
|
|
Do you have to use CComBSTR? If not, why are you using it? _bstr_t is a much more complete wrapper for BSTRs.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
If you want to eliminate CRT dependencies, CComBSTR is the way to go.
--
Broadcast simultaneously one year in the future
|
|
|
|
|
I have created a Child Window with its style set to WS_VSCROLL. This child window houses some CEdit and CStatic Windows. Now I have set up the Vertical Scroll bar, but when I scroll the child Window, the controls on it do not get repainted properly. Can anyone explain why?
I am using WTL 7.1. Thanks.
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
Did you try to set clipchildrens style bit (forgot the actual name), if that doesn't work try calling UpdateWindow for all the controls after scrolling.
My sins are bloody red, my coffee is a black hole.
|
|
|
|
|
Thank You for taking the time to reply to my woe. Well, I have set the WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles to my control and UpdateWindow() also doesn't work. In the End, I tried Invalidate on all the child controls and it worked. although the scrolling is not smooth as expected, but it scrolls. Any other way that I can make the scrolling experience better?
Thank You once again.
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
how to trap tab change event in IE7 or how to get active tab ?
|
|
|
|
|
i found the way to get tab change event and get the active tab.
|
|
|
|
|
Would you mind sharing it with us?
|
|
|
|
|
Hello,
I create a COM componet with ATL, but when I test it , by CoCreateInstance(),
the result value is always E_OUTOFMEMORY, who can tell me why? Thanks a lot!
|
|
|
|
|
chenxiujie wrote: I create a COM componet with ATL, but when I test it , by CoCreateInstance(),
the result value is always E_OUTOFMEMORY
Search the Support Knowledge Base[^]
|
|
|
|
|
Hi,
I'm creating dll using VS2005 ATL project. I'm using third party SDK API's which extracts data into a *string variable. Now I'm facing problem with converting the *string to _bstr_t and *BSTR.
Please guide me whether is it possible to convert *string to _bstr_t and *BSTR, if so how to do it. If possible with a sample piece of code.
thanking you,
Arun
|
|
|
|
|
Hello agarunk,
By "*string", do you mean a pointer to a STL string ?
By "*BSTR", do you mean a pointer to a BSTR ?
- Bio.
|
|
|
|
|
Hi Bio,
Its "std::string* ", i.e., pointer to std string.
and yes "BSTR* " is pointer to a BSTR.
-Arun
|
|
|
|
|
Both the _bstr_t wrapper class and BSTR expect the text to be UNICODE, rather than ANSI or MBCS. While _bstr_t can convert from LPCSTR, BSTR on it's own can't.
You will need to use the c_str() member function of the std::string to get your LPCSTR in the first place (unlike MFC/ATL/WTL CString class, there's no LPCTSTR operator). Like I say, you can then use this pointer with something like A2W or MultiByteToWideChar.
Steve S
Developer for hire
|
|
|
|
|
Hi Steve,
Below is the implementation which I'm using now....
BSTR* TargetBSTR ;<br />
string *SourceStr=new string;<br />
string StrBuff;<br />
const char *CharBuff;<br />
<br />
StrBuff=*SourceStr;<br />
CharBuff=StrBuff.c_str();<br />
*TargetBSTR = _com_util::ConvertStringToBSTR(CharBuff);
Is this what you are asking me to do???
It is working fine for me for time being... I would like to know if I'm doing any mistake.
Is there any issues with it???
-Arun
|
|
|
|
|
agarunk wrote: BSTR* TargetBSTR ;
string *SourceStr=new string;
string StrBuff;
const char *CharBuff;
StrBuff=*SourceStr;
CharBuff=StrBuff.c_str();
*TargetBSTR = _com_util::ConvertStringToBSTR(CharBuff);
That is far more code than you need to do for this. See my response below.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Steve S wrote: Both the _bstr_t wrapper class and BSTR expect the text to be UNICODE, rather than ANSI or MBCS. While _bstr_t can convert from LPCSTR, BSTR on it's own can't.
This isn't completely accurate. _bstr_t has a constructor that takes a const char* . It will do the conversion for you.
Basically, if you need to convert std::string* to a _bstr_t* (or even to a BSTR* ), here is a simple way to do it:
std::string* pStlString = new string("my stuff");
_bstr_t* pBstrWrapper = new _bstr_t(pStlString->c_str());
BSTR* pBstr = pBstrWrapper->GetAddress();
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I sit corrected
I confess that these days I very rarely use ANSI/MBCS, since I no longer do stuff for Win9x/ME platforms. Lucky me, my end-customers all use W2K or later...
Steve S
Developer for hire
|
|
|
|
|
Since I'm in the Linux world at my new job, I'm a bit rusty myself. I do find that using the T-functions (along with classes that can use both char* and wchar_t*) alleviates much of those headaches.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
Hi All,
I want to return a Class pointer from ATL Dll.Currently I am trying method using IDispatch * but giving problem, return pointer is invalid . Please give me a solution for this.
Thanks in Advance.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
-- modified at 8:30 Monday 24th July, 2006
|
|
|
|
|
You don't return class pointers in COM: It violates the whole concept of COM. COM components are meant to be (programming) language neutral so you can't be returning classes from COM objects: What good is a C++ class to VB, for example? Can you be more specific with what (exactly) you're trying to achieve?
|
|
|
|
|
Thanks For the Reply.
Details : I have used one class in COM Interface. This class gets manipulated in the com method. Further I need the class pointer so that I can access the values of that class which are modified by the COM. I want the pointer in the function from where I invoked the COM method.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|