|
Hi in my project there is a window where I have to embed a word application using OLE. It is fine for Internet explorer, but for Word rather embedding it is opening as a separate application. One thing if I use IWebBrowser2 to achieve it is fine, but there is a problem relating to history so I am trying to do it in this way.
The flow is as follows: The syntax is based on plain C.
CLSID idMsWord;
HRESULT hr;
IStorage *pStorage;
IOleObject *browserObject;
_IOleClientSiteEx *_iOleClientSiteEx;
hr = CLSIDFromProgID(L"word.document", &idMsWord);
hr = StgCreateStorageEx(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DIRECT | STGM_CREATE, STGFMT_DOCFILE, 0, NULL, 0, &IID_IStorage, (LPVOID*) &pStorage);
if (!OleCreate(&idMsWord, &IID_IOleObject, OLERENDER_DRAW, 0, (IOleClientSite *)_iOleClientSiteEx, (void**)pStorage, (void**)&browserObject))
{
GetClientRect(hwnd, &rect);
rect = *R;
// Let word object know that it is embedded in an OLE container.
if (!OleSetContainedObject((struct IUnknown *)browserObject, TRUE))
{
browserObject->lpVtbl->DoVerb(browserObject, OLEIVERB_INPLACEACTIVATE, NULL, (IOleClientSite *)_iOleClientSiteEx, -1, hwnd, &rect);
browserObject->lpVtbl->Release(browserObject);
}
}
_IOleClientSiteEx is the structure which holds IOleClientsite.
Now when DoVerb is beieng executed a new word application is being opened as a separate application rather as an embedded one.
Please help to resolve this issue as it is related to my project.
|
|
|
|
|
Here is an example, if that might help:
Using MS Office in an MFC application[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thanks
As you look at my code there is no use of MFC class. So I have to achieve this without MFC class.
|
|
|
|
|
Yajnesh Naraya Behera wrote: So I have to achieve this without MFC class.
That must be a real pain. Good luck.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Yap it is really. Now I got some concept, I have to implement an OLECONTAINER to host MS Word, again from where I will get the interfaces for Word. In other way I can use all the proeprties & methods of MS Word using IDispatch, but what about other interfaces
IOleClientSite, IOleInPlaceFrame. All your sugestions valuable in this regard.
|
|
|
|
|
This thread is pretty much buried now. You may want to start a new thread, explaining your problem.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi all,
I m working on VC++ 2005,SDI type application.
in a Dialog Box i want to set the value of ReadOnly type Edit box.
i want to set the value of that Editbox when using Tab key for move diffrent controls or when i click on Edit box the value is automatically set on that Edit box. Without click on OK or any other button or before closing of that dialog box.
i m waiting for ur helpful reply.
Thank in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You can use
<br />
CEdit m_edit;
....<br />
m_Edit.SetWindowText(); function to set the function<br />
<br />
or<br />
<br />
SetDlgItemText( RESOURCE_ID_OF_EDIT_CONTROL, TEXT_TO_SET);
You can map ON_EN_KILLFOCUS notification to track when cursor leaves the window - Check MSDN for more info[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
modified on Monday, May 12, 2008 4:44 AM
|
|
|
|
|
I m already using this but it is not working.
Thanks
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
What do you mean by "it is not working"? Can you explain?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I mean i using this but the value is not show in edit box.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
How are you using it? What are you doing exactly? Can you show the code? Please read the sticky post, "How to get an answer to your question" at the top of this board. Please.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
<code>
COleDateTime=m_ole_date1,m_ole_date2;
COleDateTimeSpan daydiff=(m_ole_date1-m_ole_date2);
int noofday=(int)daydiff.GetTotalDays();
CString m_no_ofday,nday;
noofday++;
nday.Format("%d",noofday);
m_no_ofday.SetString(nday);
SetDlgItemTextA(IDC_EDIT1,nday);
</code>
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
If it doesn't work with your variable, verify with a hard coded string. That's because you might be screwing up the value in your variable somewhere.
Create a control variable (say c_edit ) for the edit control and call c_edit.SetWindowText("Your text here"); .
Or
Call SetDlgItemText(IDC_EDIT1, "Hello world");
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Sorry to say that but Its not working,
actully i m calling this dialog box in another class which is Form view type.
i want before closing of dialog box the value is show in EditBox.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You're going wrong somewhere. Did you try debugging?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I can be the reason you are not properly pumping the message, how you create the dialog, where is the code to set the text in the dialog resides.
|
|
|
|
|
ThatsMe. wrote: SetDlgItemTextA(IDC_EDIT1,nday);
What is the value of nDay at this point? What does SetDlgItemTextA() return?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
nday gives the total calculated no of days.
and there is no value show in EditBox after using of SetDlgItemTextA();
Thanks & Regards
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Can you insert simple text to editbox?
|
|
|
|
|
ThatsMe. wrote: nday gives the total calculated no of days.
and there is no value show in EditBox after using of SetDlgItemTextA();
This answers neither of my questions.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
You can achieve this by sub classing your edit box. For this you have to use the API SetWindowLong where you will set a new window proc so that the entire message will be redirected to this new window proc. Here you can achieve the functionality by handling the appropriate message.
|
|
|
|
|
Can u please tell me this with example.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
I am not getting what is your exact requirement any how I am giving you the skeleton to do sub clssing.Suppose handle of edit box is
hWndEdt
then
WNDPROC oldEditProcedure ;
WINAPI SubClassFunc(HWND hWnd,WORD Message,WORD wParam, LONG lParam);
oldEditProcedure = (WNDPROC) GetWindowLong(hWndEdt, GWL_WNDPROC);
SetWindowLong(hWndEdt, GWL_WNDPROC, (LONG)SubClassFunc);
do not forget to call in your destructor or at the appropriate place
SetWindowLong(hWndEdt, GWL_WNDPROC, (LONG)oldEditProcedure );
WINAPI SubClassFunc(HWND hWnd,
WORD Message,
WPARAM wParam,
LPARAM lParam)
{
if(Message == WM_PAINT)
{
SetWindowText(hWnd, "Hello SubClassFunc");
}
return CallWindowProc(oldEditProcedure, hWnd, Message, wParam, lParam);
}
|
|
|
|