|
|
Can somebody explain the following construct and when would you use it?
GetSize().foo = NULL;
thanks...
Happy New Year...
sun.lcr
|
|
|
|
|
When GetSize() returns a reference to an object, and .foo is a pointer?
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
Thank your Jorgen,
Could you show me a sample of how you would set that in a class and its use...
Thanks again...
Happy New Year...
sun.lcr
|
|
|
|
|
struct Y {
void* foo;
};
class X {
Y obj;
public:
Y& GetX();
};
X x;
x.GetX().foo = NULL;
--
I got nasty habits. I take tea at three.
-- Mick Jagger
I blog too now[^]
|
|
|
|
|
Who can help me?
#include "stdafx.h"
template<class T>
struct S
{
int qqq;
friend bool operator< (const S<T>&t1,const S<T>&t2);
};
template <class T>
bool operator< (const S<T>&t1,const S<T>&t2)
{
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
S<int>s;
S<int>s2;
bool uintb = s2<s;
return 0;
}
compler tell me
TestSTL.obj : error LNK2019: 无法解析的外部符号 "bool __cdecl operator<(struct S<int> const &,struct S<int> const &)" (??M@YA_NABU?$S@H@@0@Z) ,该符号在函数 _main 中被引用
Debug/TestSTL.exe : fatal error LNK1120: 1 个无法解析的外部命令
~_~
|
|
|
|
|
|
|
Hi all,
I have developed a ATL in-proc server (dll) that exposes some COM objects, and these have some events. I have to fire events in a separate working thread I spin when the library is loaded. So the event consumer is serviced in another thread. When I use this in a VB6.0 application all works well but if I attempt to debug the event, placing a breakpoint in the event sub, the breakpoint is hit, but then the VB IDE crashes and suddenly disappear.
I registered the COM object apartment as BOTH.
So what is the problem?
Could you please help me?
Many thanks and HAPPY NEW YEAR !!!!
Regars,
Andrea
|
|
|
|
|
In short : The interface pointer used by your worker thread to fire the events is not valid for the worker thread.
In length (there are numerous resources on the web that discusses this problem):
http://www.mvps.org/vcfaq/com/1.htm[^]
It's doesn't matter that the object is martked 'Both'. VB instansiates it in an STA.
In detail: When you fire the event in your worker thread that thread executes native VB code. VB assumues that the thread that calls it is always the same thread (the same requirement as for the STA). VB tries to get data in the TLS but since it is the wrong thread that calls VB, VB will sometimes throw access violation (if you're lucky).
If the object would've been marked 'Free' (an MTA object) then VB (or rather the COM-runtime) is forced to instansiate the COM object in the MTA. If the worker thread then also enters the MTA (by calling CoInitializeEx with argument COINIT_MULTITHREADED) then it's legal for the worker thread to fire the events in the way the VC 6 wizard generates the event-firing code. In this case COM will automatically put up proxy/stub pairs between the VB and your object ensuring that it's the correct thread that calls the VB code.
The drawbacks are:
1. Performance (every call is marshalled and will force a thread switch, few calls = no problem, many calls = large performance hit)
2. You must secure your object for concurrent access (but since it was marked 'Both' it should've been secure already
3. An MTA object _can not_ be an ActiveX object (that is a COM object with UI)
A peculiar detail is:
1. When the VB code calls your object the COM runtime will pump the message loop.
|
|
|
|
|
1. If I load a web page that contains frames then the OnDocumentComplete() is hit for each frame. How can I recognize that the page is completely loaded (no more frames missing)?
2. How to recognize that web page is redirecting?
|
|
|
|
|
|
|
|
I tried this in my application but it doesn't seem to work. Did get it to work though by checking the iDispath parameter of the webbrowser with the one fired. But the problem came in certain pages when the top level frame does not fire a documentcomplete. does anyone know how to get over this??
Thanks,
Arun
|
|
|
|
|
if you have created a Button on Outlook express Menubar ,you must have craeted a Window(hidden window) to do that,check for Button message in that Hidden window Simple
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
First Make me clear that you have added the button on Menu bar or not
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
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
|
|
|
|