|
Greetings,
I am porting existing MFC based ActiveX controls to ATL based ActiveX controls which support MFC internally. I am using Visual Studio 7.1 and in this version MFC has aparently been merged with ATL. However I am getting compilation errors for some of the MFC based functions.
For example,
TranslateColor(), GetBackColor(), and GetForeColor() all give the following error:
"identifier not found, even with arguement-dependent lookup"
If MFC is merged with ATL then why don't these MFC functions get recognised?
Has anybody come such a problem? How does one get the compiler to understand what these functions are, or what the equivelant ATL functions are?
Thanks!
Aristotel
|
|
|
|
|
Hi All,
I am trying to invoke execute a piece of javascript code from C++, here below are my code piece
//m_spDoc is defined as CComPtr(IHTMLDocument2)
bool CWebPage::execJScirpt(CString scriptCode)
{
CHECK_POINTER(m_spDoc);
CComPtr<ihtmlwindow2> m_pHW;
HRESULT hr = m_spDoc->get_parentWindow((struct IHTMLWindow2 **)&(m_pHW));
ATLASSERT(SUCCEEDED(hr));
CHECK_POINTER(m_pHW);
CComVariant varResult;
varResult.Clear();
hr = m_pHW->execScript(BSTR(scriptCode), BSTR("JScript"), &varResult);
if (!SUCCEEDED(hr))
{
void* pMsgBuf;
::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
hr,
MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
(LPTSTR) &pMsgBuf,
0,
NULL);
cout << "Error (" <<(LPTSTR)pMsgBuf << endl;
LocalFree(pMsgBuf);
}
return SUCCEEDED(hr);
}
However, this function always reports error "Invalid class string", no matter what kind of javascript code I tried to invoke. I tried the following javascript code piece:
1. To provide a javascript code directly
execJScirpt("alert('Hello, World!')")
2. To invoke a javascript function define in the webpage, you can open the webpage
http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm
and execJScript("Welcome()")
All the running results the error message "Invalid class string".
Any idea?
Thanks a lot for your help!
-Paul
|
|
|
|
|
Use the CComBSTR (or _bstr_t) class instead of the simple BSTR casting.
With best wishes,
Vita
|
|
|
|
|
Hello,
How to make IE Add-on for translating text?
During opening page I need to convert text to another language and show it in IE instead of original text.
Any idea, some example?
|
|
|
|
|
Hi,
I have two processes running simultaenously. Process#1 sends a message using "SendMessage" API to Process#2.
Process#2 on recieving this message makes a call to an objects method that resided in COM Local server. This Local server is "Apartment" threaded.
On this method call I am getting OLE error- RPC_E_CANTCALLOUT_ININPUTSYNCCALL
I found MS KB article regarding this situation @ http://support.microsoft.com/kb/131056/EN-US/
[^]
and they say this is by design in such scenario and we should use PostMessage to avoid it
But I want to make Synchronous call using Send Message API. Can some one help me with designing apporpriate solution/ workaound for this situation.
Thanks in advance
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I think a multi threaded apartment would solve that particular problem. But that's probably not a good idea if you haven't prepared for concurrency.
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
I know the problem is due to Apartment threaded server and MTA will solve my issue. But friend, the COM server is not developed by me so I have to use that Apartment threaded server and now need a work around to solving the error I am getting.
I know of few alternate solutions but things are not working the way they should
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I have this iterator:
class CFileIterator :
public std::iterator<std::input_iterator_tag, const std::wstring>
{
public:
CFileIterator(const std::wstring& pathWithWildcard);
...
}; which I instantiate like this:
CFileIterator it(SomePathWithWildcard), end; I was hoping to be able to fill a vector using the iterator, like this:
std::vector<std::wstring> filenames(it, end); but the compiler spits this into my face:
error C2664:
'std::vector<_Ty>::vector(std::vector<_Ty>::size_type,const _Ty &,const _A &)'
: cannot convert parameter 1 from 'CFileIterator' to 'std::vector<_Ty>::size_type' Apparently, the compiler believes I want to call the vector ctor
vector(size_type, const Type&, const Allocator&); instead of
template<class InputIterator>
vector(InputIterator, InputIterator, const Allocator&); I use the aged and all but standards compliant Dinkumware STL bundled with Platform Builder 5 - it's probably the same that shipped with old Visual C++ 6.
Any ideas what I might try to get resolve the ctor call correctly?
--
The Blog: Bits and Pieces
|
|
|
|
|
The VC6 documentation for vector contains this note:
In this implementation, if a translator does not support member template functions, the template:
template<class InIt>
vector(InIt first, InIt last, const A& al = A());
is replaced by:
vector(const_iterator first, const_iterator last,
const A& al = A());
Does this apply to Platform Builder (it does to the STL provided with VC6)?
[edit]A possible workaround. Use the default vector constructor and initialise with std::copy[/edit]
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Stuart Dootson wrote:
Does this apply to Platform Builder (it does to the STL provided with VC6)?
Yes, it does apply to PB also. I read that note, but didn't understand its implications. Is that the reason why my try fails?
Crappy stuff from the dark ages...
Stuart Dootson wrote:
A possible workaround. Use the default vector constructor and initialise with std::copy
Yes, I had already tried that and it works perfectly on the emulator, byt seems to segfault in std::copy on a device. I must have done something wrong in the implementation of my iterator.
Meanwhile, I've resorted to brute force
for(; it != end; ++it)
filenames.push_back(*it); which is ugly but functional.
--
The Blog: Bits and Pieces
|
|
|
|
|
Yep, that's why your try fails - the only constructor provided which takes iterators for vector is takes the vectors const_iterator type. It's not templated.
The std::copy issue can be fixed using a std::back_insert_iterator . You can get one of these using the std::back_inserter function. You would then do something like:
std::copy(sourceBegin, sourceEnd, std::back_inserter(filenames);
HTH!!!
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Stuart Dootson wrote:
The std::copy issue can be fixed using a std::back_insert_iterator
Sorry for being unclear in my last post - I did try std::copy with std::back_inserter and it worked fine on the emulator, but something breaks on the device, so I have to debug that later. Meanwhile I go for the brute force method do have at least something.
Thanks anyway, Stuart
--
The Blog: Bits and Pieces
|
|
|
|
|
I am a beginer of learning programming by ATL ,I have writen a interface as below:
HRESULT GetBSTR1([out,retval]BSTR* bstrInfo)
{
CComBSTR b(L"hello,you have called GetBSTR1");
*bstrInfo=b.Copy();
return S_OK;
}
HRESULT GetBSTR2([out]BSTR* bstrInfo)
{
CComBSTR b(L"hello,you have called GetBSTR2");
*bstrInfo=b.Copy();
return S_OK;
}
and VB Client Codes as below:
Private Sub Command1_Click()
Dim a As New ATLTESTLib.TestOne
Dim str1, str2 As String
str1 = a.GetBSTR1
MsgBox (str1)
a.GetBSTR2(str2)
MsgBox (str2)
End Sub
problem is str1 is OK,but str2 is empty,why?
|
|
|
|
|
CALL a.GetBSTR2(str2)
or
a.GetBSTR2 str2
With best wishes,
Vita
|
|
|
|
|
thanks a lot. a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason?
|
|
|
|
|
I also have a problem about BSTR Parameter,codes as below:
HRESULT GetBSTR3([out]BSTR* bufName1,[out,retval]BSTR* bufName2)
{
USES_CONVERSION;
CComBSTR b(L"hello,you have called GetBSTR3");
*bufName1=b.Copy();
TCHAR buf[]=TEXT("it is return value");
*bufName2=T2BSTR(buf);
}
VB Client as below:
Private Sub Command1_Click()
Dim a As New ATLTESTLib.TestOne
Dim str1, str2 As String
str2 = a.GetBSTR3(str1)
MsgBox (str1)
MsgBox (str2)
End Sub
running these codes, runtime error
if I write codes as below:
str2 = a.GetBSTR3 str1
compile error
how can I do it?
|
|
|
|
|
Listen Borther
Instead of using this
yingkou wrote:
str2 = a.GetBSTR3 str1
use this
str2 = a.GetBSTR3(str1)
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
str2 = a.GetBSTR3(str1)
if I use this method, str1 and str2 are both empty.
could you tell me the difference between a.GetBSTR2 str1 and a.GetBSTR2(str1)
|
|
|
|
|
Q: a.GetBSTR2(str2) is error but a.GetBSTR2 str2 Is OK,why? could you tell me the reason?
A: This is a VB syntax requirement. Look at "Call Statement" in MSDN.
Q: runtime error
Dim str1, str2 As String
str2 = a.GetBSTR3(str1)
A: Variable "str1" is a Variant type here, because VB treats the Dim statement as:
Dim str1 As Variant, str2 As String
You should specify the type for each variable.
With best wishes,
Vita
|
|
|
|
|
I do it just like what you have said
Dim str1 as String
Dim str2 As String
str2 = a.GetBSTR3(str1)
but str1 and str2 are both empty
|
|
|
|
|
what is MFC, WTL, ATL, CTL?? could nayone tell me. If i were to write a windows application using c++.NET what would i use
|
|
|
|
|
You can use any thing.it depends upon project
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
MFC, ATL, WTL are unmanaged code... if you want to write managed code I recommend that you use C#. If you really need to, you can use C++ / CLI.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
MFC = Microsoft Foundation Classes. It's a class library with functionality ranging from GUI to linked lists. Probably the most popular toolkit to write Windows applications in. At least it used to be.
ATL = Active Template Library. A class library aimed to ease developing COM applications. Since COM implies ActiveX controls, it's got some limited GUI functionality in it as well. With limited I mean that there are no CListCtrl or CEdit classes.
WTL = Windows Template Library. Is a complement to ATL. Since ATL's GUI support is quite rudamentary - it's enough to cover ActiveX control development, WTL was created to make the development of ordinary Windows apps. WTL builds on the same design principles as ATL, thus WTL code fits like a glove in ATL projects. As it's name implies, it makes heavy use of C++ templates. In my opinion a better mini MFC (MFC has a lot more functionality than ATL/WTL, hence "mini MFC").
CTL = I have no idea. Did you mean STL? STL = Standard Template Library. A standard class and function library, defined in the C++ standard. Contains containers, algorithms, I/O manipulation routines and memory management. Not only is it an excellent library to use, it's also excellently extensible due to its use of templates. Boost[^] is the proof of that.
Since you don't seem to have any idea about these toolkits, I suggest you start at the bottom first, and then work your way up. I'd like to think that STL is a strong foundation of any C++ application, and is thus located at the bottom. Learn it, and you won't have to reinvent the wheel more than twice or thrice. After that it all kind of depends on what you want to do. ATL is good if you are into COM stuff. But then you'd have to learn COM first. You don't need to know the COM stuff in ATL if you are going to use it in conjunction with WTL though. The windowing code is well separated from the COM stuff.
Whether you should choose WTL over MFC, or vice versa, is mostly a matter of taste. I prefer WTL over MFC because it's not as bloated as MFC, and of its (in my opinion) much better design. MFC may do much more for you than WTL alone, but that's easily cured with STL and Boost (see link above).
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
I am reading Michael Dunn's WTL for MFC Programmers,he said"Also unlike CWnd when a CWindow object goes out of scope, the associated window is not destroyed...",So I don't understand Why the associated window is not destroyed,PLS show me . Thanks
|
|
|
|
|