|
Hi lokesh,
Right I found the project you are on about. Just to clarify - it was the CEdit project was it not?
Anyway I've had a look and have got it to insert the BGSOUND element.
This project must have been written way way back and is a very verbose way of doing things. Anyway I digress.
This is what I did:
Firstly, we what to inject the element on the Document Complete event but because this is an old application we have to do it the old way. Events from the HTMLDOMDocument are handled by the CImpIDispatch class in DOCEVENT.cpp, we can tell this because in the crtview.cpp you see the following line:
hr = m_pConnectionPoint->Advise( m_pDocEvents, &m_dwConnectCookie );
So we are setting the object for the DOMDocument to call us back on.
Then in the CImpIDispatch class, we need to look for the ::Invoke method, this is what will get called whenever any events take place - dispIdMember parameter will hold what event it actually is (see MSDN for all the events)
The event we are interested in is: DISPID_HTMLDOCUMENTEVENTS_ONREADYSTATECHANGE
readyState is a property of the document that tells you what the state of it is - we want to wait for it to be "complete"
So here is the code I used in the ::Invoke method:
USES_CONVERSION;
if ( dispIdMember == DISPID_HTMLDOCUMENTEVENTS_ONREADYSTATECHANGE )
{
MSHTML::IHTMLDocument2Ptr spDoc(m_pView->m_pSite->GetObjectUnknown());
if (spDoc)
{
CString strState = OLE2T(spDoc->readyState);
if (strState == _T("complete"))
{
MSHTML::IHTMLElementPtr spElem = spDoc->createElement(_T("BGSOUND"));
if (spElem)
{
MSHTML::IHTMLBGsoundPtr spBG = spElem;
if (spBG)
{
CString strURL = _T("http://www.htmlcodetutorial.com/sounds/hazy_shade_of_winter.mid");
spBG->put_src(T2OLE(strURL));
MSHTML::IHTMLDOMNodePtr spBody = spDoc->body;
MSHTML::IHTMLDOMNodePtr spNode2Add = spBG;
spBody->appendChild(spNode2Add);
}
}
}
}
}
Now you may notice that above I'm using the smart pointer implementation for COM calling - I did start doing in the traditional way but I got so bored with doing QueryInterface all the time. So add the following to the top of the cpp file:
#import "C:\Windows\system32\mshtml.tlb" no_auto_exclude
Actually there is another reason - the mshtml.h file that is already included in the file points to a version in your VC install directory - and this is woefully out of date (i.e. doesn't include the IHTMLDOMNode interface that we require)
Ok, no also don't forget to include:
#include <AFXPRIV.H>
In your stdafx.h as we are using the USES_CONVERSION macro to help us with string conversion.
I'm going to end it now, rather than babble on and on. I hope I've got the right end of the stick of what you wanted to achieve ?? Any questions just ask
Andy
|
|
|
|
|
Super!Super! U GOT IT RIGHT MAN...
ITS WORKING....
THANKYOU VERY MUCH.
Iam just new to vc++ especially to com. I would be pleased if u guide me or teach me this thing from basics( Even some material would do).My email id is
itslokeshk@yahoo.co.in and would be pleased to yours too. Thank you very much...once again.
bye..
lokesh
|
|
|
|
|
Hi world!
I'm looking for methods to share an object (C++) between several applications?
I use VC6...
Example:
Application 1 write in my_sharing_object object.
Application 2 read any attributs from my_sharing_object object (writed by the first application).
Any idea?
Thans in advance for your help.
Hello World!!!
from Raphaël
|
|
|
|
|
Hi,
I personally would implement a SINGLETON COM server.
Maybe overkill for what you want, but implement a compliant IDispatch interface, and now app 2, 3, or 4 can be VB or even Internet Explorer clients - much more sexy.
Hope this helps,
Andy
|
|
|
|
|
I have a toolbar button that I want to change dynamically to different solid blocks of colour. I can get a handle to the current image using
tbbi.dwMask = TBIF_IMAGE;
SendMessage(hTB,TB_GETBUTTONINFO,(WPARAM)TB_COLOUR,(LPARAM)&tbbi);
himl = (HIMAGELIST)SendMessage(hTB,TB_GETIMAGELIST,0,0L);
ImageList_GetImageInfo(himl,tbbi.iImage,&ii);
and I can replace the image and tell the toolbar to use the new one using
ImageList_Replace(himl,tbbi.iImage,hbm,NULL);
SendMessage(hTB,TB_CHANGEBITMAP,TB_COLOUR,MAKELPARAM(tbbi.iImage,0));
but in between how do I change the bitmap or create a new one? I've tried
hbm = (HBITMAP)CopyImage(ii.hbmImage,IMAGE_BITMAP,size.cx,size.cy,LR_COPYRETURNO);
selecting into a HDC, and using FillRectEx but it doesn't work. I'm using C and win32 (I don't know C++ or MFC).
Any help appreciated.
thanks
Dave Risley
|
|
|
|
|
I had include header file in stdafx.h and set precompiled headers is stdafx.h but when i compile my project it still error some variable not defined.
somebody can help me?
thanks
Nho'c Ti`
|
|
|
|
|
I think you need to supply more information. To start with: What compiler error occurred?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
-- in stdafx.h file
#include "mylib.h"
-- in myfile.h file I use some variable and some define in mylib.h
ex : #define A 1
but when i compile it still error in myfile.h with message : A isn't defined
Nho'c Ti`
|
|
|
|
|
because in myfile.h you dont include stdafx.h
try including stdafx.h before you include your myfile.h
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Unless mylib.h rarely changes, it should not be included in stdafx.h. Otherwise, the majority, if not all, of the project gets needlessly rebuilt. Include mylib.h only where it is needed.
That aside, you haven't shown what file actually uses A . In that file is where you'll need to include mylib.h.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i saw some project don't need include when mylib.h use include in stdafx.h and stdafx.h is set precompiled headerfiles for project setting.
Nho'c Ti`
|
|
|
|
|
Hi People,
I have seen a CCheckStatic control that is a mix between a check box and a group box.
Does any body can tell me where I can find the same type of control but with a RadioButton?
Can anybod show me how can I insert a RadioButton in the GroupBox title?
Best regards.
There is no spoon.
|
|
|
|
|
Two options that come into mind:
1. Make your own GroupBox and do whatever you want there
2. Just throw a radio-button OVER your GroupBox, write the logic to 'connect' them, and you get a radio-group-box-thingy.
|
|
|
|
|
Thanks.
I would add this third option:
3. simply take the source of CCheckStatic and replace BS_CHECKBOX by BS_RADIOBUTTON in the Init() method of the class
There is no spoon.
|
|
|
|
|
Hi all
I have started on a project which has already been goign for a while
and i noticed that the callstack says that the code is breakign in function X, which is called from function Y and so on
much when i try and double click on said line in the callstack i go to an incorrect location in that class's file...is there a method for getting VC.net to resynch properly so it'll take me to the right place?
bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
Seems your browsing the wrong source (a copy?) or you need to rebuild the project because the binary is not online with the code.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi all,
I need to pass large data( in the order of MBs ) to DLL for processing. When I pass a reference to such object that holds reference to this data from the application and then, trying to access the member variables from passed object causes crash my application.
Note that, it works fine if
1. I downsize data in object,
2. I make member variables public.
Is there any thing special I need to do when passing and processing large data to DLL?
Hope I am clear about the question.
Please feel free to ask any questions, that would help to understand problem more correctly.
Thanks and regards,
Shrinivas
|
|
|
|
|
1. how many MBs?
2. is this data local memory?
Don't try it, just do it!
|
|
|
|
|
How about using shared memory?
-Mel
|
|
|
|
|
If you have access to the dll sources, you can try changing the dll to export two functions - Func1 to load (and append) the data, and Func2 will process the loaded data. Then break your data into smaller blocks and call Func1 until all data is loaded, then call Func2 to handle them.
...Plug & Pray...
|
|
|
|
|
call Func1 until all data is loaded, then call Func2 to handle them ....
Does this mean that, I am trying to access the data before it is loaded? I am not sure what we mean "Data loaded" here. This may sound primitive question. But I will appreciate further explanation.
Thanks and regards,
Shrinivas
|
|
|
|
|
I think the problem is on passing large amounts of data as parameters. Since you say it works with smaller blocks, what I suggest is break the large data into smaller blocks and call Func1 to pass them to the dll one by one.
Finally when you have passed all the smaller blocks to the dll, call Func2 to process them all together as one.
|
|
|
|
|
Hello
I am intermediate level programmer and i am having trouble in using MsChart componant in VC++. In documentation its written that i can directly use database as datasource if by using grid and ADO. It works perfectly in VB as per net examples and experiences of ppl i talked to. But how to use that feature in VC++ ?
Well i have database like following
Name Value Time
a 10 12-00
a 20 12-05
a 30 12-10
b 40 12-10
b 70 12-06
b 90 01-00
Now what i want to plot is two line graphs of a and b in the same chart.
What i have with me is the query which gives me above data.
Is there any other simple method to do above thing ?
Thanking you in advance
Bhushan
|
|
|
|
|
For compression and encryption experts out there.
Is it wise to apply encrytption algorithm after the compression?
Or there is already some way of achieving both compression and encryption at the same time?
Any inputs are welcome.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
To encrypt:
Plain data -> compress -> encrypt -> final data
To decrypt:
Final data -> decrypt -> decompress -> original plain data
Never try to compress something encrypted. If the encryption algorithm is any good then the encrypted data shouldn't be compressible, not even by 1%. So always first compress then encrypt.
Best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|