|
Hello,
first of all thank you for your interest.
I have tried it... but the compiler has told me:
C:\sdsgfasjk.cpp(977) : error C2664: 'Attach' : cannot convert parameter 1 from 'struct IDispatch *' to 'class _com_ptr_t<class _com_IIID<struct IDispatch,&struc
t __s_GUID _GUID_00020400_0000_0000_c000_000000000046> > *'
after writting this:
spIDispatchPtr.Attach(this->m_HTMLCtrl.GetHtmlDocument());
Could you explain me what's happening (I'm getting lost...) and I should get it finished in 4 hours!
Thank you in advance...
NOTE:
seems that I'll be continue needing the CComPtr<idispatchptr> spIDispatchPtr;, how will I pass to the CComPtr<ihtmldocument2ptr> spHTMLDocPtr; (I mean how I will use them altogheter?
|
|
|
|
|
Well, the second part is easier, just change the CComPtr<IHTMLDocument> to CComQIPtr<IHTMLDocument> . Then when you do an assignment from spDispPtr, the spHtmlDoc will do the things necessary for it automatically (QI stays for QueryInterface).
Hmm, the first part, it is so, that the GetHtmlDocument doesn't add the reference (if my thinking was correct and it is GetHtmlDocument from MFC's CHTMLView). Then you have to do it as it was before spDispPointer = GetHtmlDocument() and you will be on the safe side (sorry that I didn't check the MFC sources for this, but somehow this is not correct behavior in COM, you have allways add reference to pointer you are returning). So try it and write me, what is the result then.
And please for < and > characters, use the buttons under the edit area, it might be important to see the template parameters
|
|
|
|
|
First of all thank you very much...
I've done what you've told me (at least what I've understood ):
CComQIPtr<IHTMLDocument2Ptr> spHTMLDocPtr;
CComPtr<IDispatchPtr> spIDispatchPtr;
Now seems that I won't need spIDispatchPt, but I'm getting lost again...
when I use this:
spHTMLDocPtr = this->m_HTMLCtrl.GetHtmlDocument();
spHTMLDocPtr gets an adress, but when I leave the function (just after calling the previous line) it gives me an error:
First-chance exception in TCC.exe: 0xC0000005: Access Violation.
and moreover...
it seems that in order to get acces to the HTML body I'll need again to use this:
spHTMLDocPtr->GetInterfacePtr()->get_body() and I'll be again at the beggining: having a pointer that is not being freed...
NOTE:
How will I get access to the HTML body using smart pointers?
Is there somewhere a list of those smartpointers?
Thank you very much again...
|
|
|
|
|
Hi,
one very quick issue - you should not use CComPtr<IDispatchPtr> spIDispatchPtr but
CComPtr<IDispatch> spIDispatchPtr !
Normally the workflow is something like that:
<br />
CComPtr<IHTMLDocument2> spPointer1 = GetHtmlDocument();<br />
if( spPointer1 )<br />
{<br />
CComPtr<IHtmlBody> spBody = spPointer1->get_body();<br />
...etc...<br />
}<br />
then every pointer you received have correct addref/release handling - when spBody goes out of scope, the reference is released, the same for spDispatchPtr
|
|
|
|
|
OK... understood, but I'm getting a lot of errors:
using this code:
CComPtr<IHTMLDocument2> spPointer1 = this->m_HTMLCtrl.GetHtmlDocument();
if( spPointer1 )
{
CComPtr<IHtmlBody> spBody = spPointer1->get_body();
if (spBody)
{
spBody->put_innerHTML("");
}
}
I get those error messages:
Compiling...
error C2440: 'initializing' : cannot convert from 'struct IDispatch *' to 'class ATL::CComPtr<struct ihtmldocument2="">'
No constructor could take the source type, or constructor overload resolution was ambiguous
error C2065: 'IHtmlBody' : undeclared identifier
error C2955: 'CComPtr' : use of class template requires template argument list
c:\archivos de programa\microsoft visual studio\vc98\atl\include\atlbase.h(563) : see declaration of 'CComPtr'
error C2660: 'get_body' : function does not take 0 parameters
error C2512: 'CComPtr' : no appropriate default constructor available
error C2262: 'spBody' : cannot be destroyed
error C2451: conditional expression of type 'class ATL::CComPtr' is illegal
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
error C2678: binary '->' : no operator defined which takes a left-hand operand of type 'class ATL::CComPtr' (or there is no acceptab
le conversion)
error C2039: 'put_innerHTML' : is not a member of 'CComPtr'
c:\archivos de programa\microsoft visual studio\vc98\atl\include\atlbase.h(563) : see declaration of 'CComPtr'
Error executing cl.exe.
|
|
|
|
|
I see. These errors are cased by the fact, that the IHtmlBody interface doesn't exists. I just wrote something in a sample. sorry for that I suppose it to be a sample of generic usage of smart pointers, not exact webbrowser reference
I'll have look what it is exactly... So the IHtmlBody is in fact IHTMLElement.
|
|
|
|
|
OK!
Now it works and the memory is getting freed and so on!
Thank you very much for your help!!!
More or less I've finished in the established time... (more or less)
Only one more question:
Qhere could I find a list of com smart pointers? I don't know where to get it and without you I wouldn't be able to do it because I wouldn't know where to find them...
Thank you again!
|
|
|
|
|
congratulation
well, there is nothing like list of smart pointers. CComPtr is a template - this means the actual code is 'created' during the compilation. Therefore you can create CComPtr or CComQIPtr with any interface (for being precise, must be derived from IUnknown, but for your usage it is vith every interface you can get from any of microsoft libraries), so for IHTMLElement it is CComPtr<IHTMLElement> for IDispatch it is CComPtr<IDispatch> for IHTMLForm it is CComPtr<IHTMLForm> for IAnyInterface it is CComPtr<IAnyInterface> etc. (the same is valid for CComQIPtr). Compiler then takes the parameter (what is written between <> ) and makes some specific CComPtr pointer pointing to some specific interface.
Hope it is clean for you now
|
|
|
|
|
Yes!
great...
Thank you again!
can I ask you the last question? (I promise this is the last )
If not don't continue reading!
I'll try it:
The first time I try to get the document it's an empty pointer and I cannot get access to it, but the second and the other times I can do it...
Is there any way to create a document for an HTMLView?
Let me promise that I will not bother you again...
Thank you in advance!
|
|
|
|
|
Hmm this is probably some IE specific issue I never heard about, so I am afraid I can't help you in this topic
|
|
|
|
|
Hello again...
I'll post that last question to the general forum... (I don't want to abuse...)
Thank you again! You've helped me a lot
|
|
|
|
|
btw if you look directly to mfc code, that guys does it exactly as we supposed to you:
CComPtr<IDispatch> spDisp = GetHtmlDocument();
mfc, viewhtml.cpp, line 108
|
|
|
|
|
Does anybody has experience in using CRichEditView in a Splitter window?
The scroller of the rich edit view and the scroller of the splitter window are both visible. I can hide the scroller of the rich edit view (only the scroller of the splitter window is visible).
If the rich edit view scrolls (by key up/down) I do not get the scrolling message from the rich edit to update the scroller of the splitter.
Who has ever implemented a rich edit view in a dynamic splitter window?
Does anybody know a sample application?
Berlenz
|
|
|
|
|
But why to not make it vice versa? Hide the scroll bar of slitter window, align your richedit control in all client area of splitter window and all will be pleased.
|
|
|
|
|
I use a "dynamic splitter" window. For that reason I have to show the scroller of the splitter window because it shows the splitter boxes.
Splitter Box:
A small control at the top of the vertical scroll bars or to the left of the horizontal scroll bars in a dynamic CSplitterWnd. Used to create new rows or columns of panes.
Berlenz
|
|
|
|
|
OK.
Then you can use a notify message EN_SELCHANGE, which inform you about cursor position changing. You can find out current line by means of
EM_GETSEL, EM_LINEFROMCHAR, EM_LINEINDEX messages. Then, knowing total count of lines in the edit and current line you can calculate vert. scrollbar's thumb position.
Something similar is possible for horz. scrollbar too
Is it convenient solving for you?
|
|
|
|
|
Hello,
How can i make right aligned Tree control ?
I want to show the icons in right of tree ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
In standard way - nowise. There is only sole method to do it - to write own tree. It might be possible to use ownerdraw style, but as I understood you need to mirror whole tree, with buttons, lines and etc, didn't I? In this case ownerdraw style won't help.
|
|
|
|
|
We are using one ocx control to play our custom files from internet explorer. This main ocx will load more than 10-15 ocx/dlls. At this point it will cause a crash in Windows 95 systems. We are using internet explorer v5.5. McAfee antivirus protection is enabled in the client system. We should have to load one simle ocx control or simple applet, before loading the main ocx(or plugin dll) to get the crash. We are building all the components in this project in release (minimum dependency ) - MFC statically linked.
We can also simulate this problem when loading these components from the creation time of the main ocx(plugin dll)using loadlibray(API).
It is a very critical client side problem and should have to be solved as early as possible. So we want an urgent solution for the same. Looking for a positive support from you.
|
|
|
|
|
I haven't done any GUI stuff in quite a while, so I wonder what I am missing here. MY forte has been mostly backend code and implementing algos. I know I sound like a VB guy (I clicked everywhere but nothing seems to happen!), but I really am so desperate that I really did click everywhere, but nothing seems to happen. Please help me out someone. It's something very obvious, I know, but when I don't get it, I don't get it. I need someone else to tell it to me. All of us have these moments, I am sure.
I have a combo box in a dialog box which shows up as a tab window. I have filled all the data that must initially show up in the combo and specified these styles for it:
visible
tab stop
type: drop list
owner draw: no
vertical scroll
The problem is that when I click on the combo box, it doesn't uh, drop down. Though if I use the up down arrow key, I can navigate through the options. I haven't yet attached any code to it to see if I can get the selected item back, but I am sure I would. What could be the problem? This combo box is inside a tab control which is inside a form view in an SDI app. The dialog box which contains this combo box has the following styles defined:
Style: Child
Border: none
All other check boxes are unchecked.
I tried to do the same thing in another project, a dialog based one, just to test things, and here things are absolutely fine. All the styles are the same, except for the dialog box, but I don't see how that should make any difference.
Someone please help me, I would be very grateful.
Thanks in advance,
Muralia
|
|
|
|
|
Don't feel bad, a friend spent two days trying to figure this out, and I looked at it at least four times before I got it. Go to the dialog editor, click on the arrow in the combo box, and then grab the little box in the middle of the bottom line and drag it down. You're setting how far it will drop, and for some moronic reason, the default is zero, so it won't drop at all.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Wow, that did it! Thanks a lot. You are my saviour!
|
|
|
|
|
Hi,
Is there any way to Invalidate the window without using
Invalidate() or RedrawWindow(..RDW_INVALIDATE )?
|
|
|
|
|
Why do you need another way ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I want to send WM_ERASEBKGND message to the control.
|
|
|
|