|
My ActiveX project has some problem, It's Can't Add Method and Property. It's hint Error adding a(n) method to the associated class.I'm use vc6+sp6.
tell me why ,thank you.
msn:Flashcutreg@hotmail.com
|
|
|
|
|
* Make sure all relevant files are not read-only
* close VC6, delete the .ncb and .clw (if any), then try again
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
Hi,
I want to add content to a view derived from MFC's CHtmlView from a thread.
The following code is a stripped back version of the code executed by the
thread.
CMyHTMLView::AddHTML()
{
HRESULT hr = CoInitialize( NULL );
ASSERT( SUCCEEDED( hr ) );
string shtml( "Hello World" );
try
{
CComQIPtr< IHTMLDocument2 > pHtmlDoc( GetHtmlDocument() );
if ( pHtmlDoc )
{
CComQIPtr< IHTMLElement > pBodyElement;
HRESULT hr = pHtmlDoc->get_body( &pBodyElement );
if ( SUCCEEDED( hr ) )
hr = pBodyElement->insertAdjacentHTML( _bstr_t(L"beforeEnd"), _bstr_t( shtml.c_str() ) );
ASSERT( SUCCEEDED( hr ) );
}
}
catch( _com_error e )
{
REPORT_COM_ERROR(e);
}
catch(...)
{
}
CoUninitialize();
}
If the contents of shtml is small as shown above it works fine. However when
shtml is a few K of HTML the call to insertAdjacentHTML() throws an
exception which is caught in catch(...). The HTML is valid and the same code
works fine when it isn't in a thread. In the real code, shtml is on the
heap or maybe the stack?
Any clues about what I'm doing wrong?
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
It could be something to do with thread-local data, a lot of MFC uses it. I've had problems trying to manipulate objects from threads - usually you have to do the work in the thread that created the object, but presumably this takes away the point of what you're trying to do.
It won't matter if shtml is on the stack or heap, but you should check if insertAdjacentHTML completes when the function returns or maybe it takes the data, returns and then some other thread processes it. Some of the html stuff has other threads to do work. Have you tried putting a sleep in after the insert to give it time to complete?
|
|
|
|
|
Hi Keith,
Thanks for the reply. I got the following reply on an MS Newgroup, which explains things.
You cannot simply pass COM interface pointers to a worker thread - you
need to marshal them. See
http://support.microsoft.com/?kbid=150777
MSHTML is a single-threaded component. If you don't marshal the
pointers - in violation of COM rules - you'll likely get random crashes.
If you do marshal, then any call you make in the worker thread though
such a pointer gets marshalled back to the main thread, executed there,
and any results marshalled back to the worker. Essentially, the worker
thread isn't doing any work, it spends all its time waiting for the main
thread to serve its calls.
Bottom line: it's pointless to perform DHTML manipulations from a worker
thread. You add pure overhead, without gaining anything at all.
I was already working on implementation that built the HTML in a thead and
added it to a queue for the app thread to display. My main problem was
getting the main thread to be a bit more responsive when large chunks of
HTML are in play. After a few different implementations, I've now got
something I'm quite happy with.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
If you are using the use the interfaces in a different thread than the one creating the control, you need to marshal it to this thread (CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream, which probably were made to win the WIN 32 API lyrics award)
chopping strings usually isn't a symptom of violating apartment boundaries, but MSHTML ctrl has a few message loop interacitons that make that possible.
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
I'm trying to register a dll on a Win2003 server, but an getting the message "DllRegisterServer in ...filename... failed. Return code was 0x8007007e". This error supposedly means a module is missing. I think all the DLLs are there - it's a standard atl dll.
I can register the dll fine on my development pc and on another Win2003 server, just this one I can't. I tried loading up the registry entries manual, but I just get an error when I try to use createobject.
Any ideas why I can do it on one server and not another?
Thanks
|
|
|
|
|
Use a dependency viewer, like "Depends" which comes with MSVC6), to view the dependencies of the COM DLL. It will highlight missing DLLs.
Steve
|
|
|
|
|
Done that, there aren't any missing. I'd get a LoadModule failure if a dll was missing.
|
|
|
|
|
Have found the problem now - atl.dll was not registered!
|
|
|
|
|
Hi,
I'm trying to paste clipboard content in an outlook message window (new mail/reply) from an outlook addin (when a button is pushed)
I'm using VC++ 6, and the addin is based on several good articles from codeproject.
I was able to create a button in the message window, but I didn't found a way to paste content in this window through the Office API.
So I used SPY++ to get the structure of an Outlook message window and sent a WM_PASTE event to the body control handle. (Using Active window, FindWindowEx and SendMessage)
This works fine for text and rich text emails ('RichText20' window class), but I can't make it work for HTML mails (Window class is 'Internet Explorer_Server').
Since WM_PASTE event was not working, I managed to get an IHTMLDocument2 pointer on this control and tried to use execCommand( _T( "Paste" ) , ...) but nothing happens. On the contrary, when I use execCommand( _T( "SelectAll"), ... ), it works.
I'm running out of ideas on this, so i'm looking for hints.
Basically , I only want to insert text/links at the cursor position.
I think that if I can get an IWebBrowser2 pointer for this control, I should by able to send the event using execWB (I already did it in IE)
How Internet Server_Explorer handles Ctrl-C events ? Is it using another control ?
Do you know a better way to do this ?
Thanks
--
Nicolas
|
|
|
|
|
Hi again,
I found the solution.
I use Outlook::_Application to get the active inspector
I'm then able to get the editor type and the HTML editor in a clean way.
An interface query on the html editor gives an IHTMLDocument.
Insertion is done using get Selection and IHtmlTxtRange. (see http://starkravingfinkle.org/blog/2005/01/)
--
Nicolas
|
|
|
|
|
I heard Mac OS suports COM. Is that true? Do unix ,linux or QNX support COM or COM is just a binary standard on windows?
|
|
|
|
|
Hi,
I have developed a MFC ActiveX control and embeded it in IE. The control is working fine but when another instance of IE is opened using Ctrl+N, I am getting ASSERT exception in debug mode and in Release mode IE crashes.
Note that if the second instance is opened without using Ctrl+N (i.e by using explorer icon) no exception arrises.
what could be wrong. your support is highly appreciated.
Thanks
Muhammad Azam
|
|
|
|
|
You've obviously got a problem with your control when more than one instance of it is created. This is probably a threading issue since IIRC Internet Explorer creates a new thread for each browser window. If your control is marked apartment-threaded (which it is, by default), then the second instance of your control will be running on a different thread from the first.
When a second instance is opened by using the icon, a new IEXPLORE.EXE process is created. This gives a whole new address space, so the problem does not occur.
It might help diagnose the problem if you post the file and line number on which the ASSERT occurs.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks a Lot Mike, your answer has given me a new dimension to think. first of all i need to know 2 things
1. what is
Mike Dimmick wrote: IIRC Internet Explorer
and what it does?
2. how co i know whether my control is
Mike Dimmick wrote: marked apartment-threaded
and is the problem due to the fact that you wrote:
Mike Dimmick wrote: your control is marked apartment-threaded (which it is, by default), then the second instance of your control will be running on a different thread from the first.
yes the line where i am getting the Assert is, when i try to access Frame window ( that i have created in my control) using AfxGetApp()->m_pMainFrame or AfxGetMainWnd() .
thanks once again for your response
Muhammad Azam
|
|
|
|
|
This is the first time I've worked with an OCX in C and I'm having trouble getting it to run. I'm trying to use a barcode control[^]. This is not a visual application, there's no gui, I'm using it to print barcodes.
I used the class wizard to import it, it created an ezbarx32.h/cpp. I seem to be able to successfully create it using
COleException tvExerror;
_DBarcode Barcode;
if (!(Barcode.CreateDispatch("EZBARX32.BarcodeCtrl.2", &tvExerror)))
{
char tvBuf[10];
itoa(tvExerror.m_sc, tvBuf, 10);
throw CEMException(CString("CreateDispatch() failed! - ") + tvBuf);
}
but as soon as I try to call a method
Barcode.SetBarcodeType(22);
I get an un-handled exception. Debuging into it I find that this call in the libraries
SCODE sc = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags,
&dispparams, pvarResult, &excepInfo, &nArgErr);
returns 0x8000ffff in sc which causes the error checking code after it to report an exception.
Anyone know what I might be missing? I know the control works, it's used in some programs in other languages without any problems.
|
|
|
|
|
can somebody pls explain what this piece of code means??
"Data" is used as a datatype throughout the idl file but isnt it an object...?? and why typedef the uuid? im a novice programmer pls help
<br />
typedef [uuid(----- ----- ------------ ---------), version(1.0)]<br />
enum {<br />
None_o = 0,<br />
Endpoint_o = 1,<br />
Midpoint_o = 2,<br />
Nearest_o = 3,<br />
Perpendicular_o = 4,<br />
Intersection_o = 5,<br />
Tangent_o = 6,<br />
Quadrant_o = 7,<br />
Node_o = 8,<br />
User_o = 9<br />
} Data;<br />
im inserting activex controls in a com. this a part of the idl generated from the ocx.
-- modified at 6:32 Wednesday 28th June, 2006
|
|
|
|
|
Spot the keyword enum . This is an enumerated type. IDL follows the C syntax - enum s live in a separate namespace from the standard types, so you must use enum foo rather than just foo when using them. To work around this, virtually every enum you'll ever see is put in a typedef declaration to create a type name in the global type namespace. A Microsoft extension to C allows the name of the enum itself to be omitted if you do the typedef in the same declaration as the enum itself, and again this has carried over to IDL.
The [uuid] and [version] attributes are attached to the enum declaration, not the typedef itself. Enumerated types must have GUIDs the same as everything else. You can modify an enumeration without changing the GUID as long as you only add new values; you cannot delete existing ones or renumber them.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi mike,
i got it... i guess this is what i understood of this before i put up a post... but then why does the compiler give me an error saying that i need to add a type specifier before the datatype? can you suggest any changes in the idl file...
thanks
nikhil
|
|
|
|
|
|
Hi,
I am developing the COM addin for outlook 2000 with Windows XP OS.
I am facing the problems while adding the picture on the button of the toolbar. as I have added the picture on outlook 2003 sucessfully but the API put_Picture i have used in OL2003 is not working with OL2000..
Is there any way to do same??
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Try using
tempButton->Style=Office::msoButtonIconAndCaption;
tempButton->Caption="Hello";
tempButton->FaceId=67;
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks man,
I have the idea about it... but this work only for the faceid's provided by Outlook itself..
I want to add custom face to the button using the picture and mask i created.
Thanks for instant reply.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi use this one:
void SetBitmap(CComQIPtr<office::_commandbarbutton>tempButton,const int& imageId)
{
CComQIPtr < Office::_CommandBarButton> spButton(tempButton);
ATLASSERT(spButton);
bool transparence;
HBITMAP hBmp =(HBITMAP)::LoadImage(_Module.GetResourceInstance(),
MAKEINTRESOURCE(imageId),IMAGE_BITMAP,0,0,NULL);
// put bitmap into Clipboard
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, (HANDLE)hBmp);
::CloseClipboard();
::DeleteObject(hBmp);
// set style before setting bitmap
spButton->PutStyle(Office::msoButtonIconAndCaption);
HRESULT hr = spButton->PasteFace();
spButton->PutVisible(VARIANT_TRUE);
}
jhala ki sang aplyakade sagle ahe
Cheers
"Peace of mind through Technology"
|
|
|
|