|
hi
i want to read a binary file and store it into one of my activeX Control's
property. i used unsigned char * as the type of the property that will hold
the data read from file. but when it calls the
IPersistStreamInitImpl::Save(....) method. the data stored in the property
of type unsigned char * is not read, displaying in output window that
ATL: Invoked failed on DISPID 3
where DISPID 3 is id of that property. plz let me know which data type to
use? or where the actual problem lies.
Thanks in advance.
Ahmad Jalil Qarshi
|
|
|
|
|
hi,
I have a wee problem, Im using TypeLibInfo in VB .NET to expose
members of COM+/COM objects. So far so good as I have been able to do many things with it, The problem comes when trying to determine the member type
i.e if it is a function or property etc. as the TLI.MemberInfo.InvokeKind
is always comming back as unknown.
thoughts?
regards
charlie
|
|
|
|
|
hi dears,
i want to write a program which can add a button in the toolbar of ms outlook. can someone help me to accomplish this task. can i do this in vb6. i shall be very thankful.
|
|
|
|
|
Hi,
There are a lot of articles on how to accomplish this. I have even managed to do it with Delphi. As long as you can create a dll you should be fine, so if you can do some code translation you should really check out this article:
http://www.codeproject.com/com/outlookaddin.asp[^]
This one is for VC++, but the principle is the same. On MSDN you will also find a lot of information, but the articles there usually refer to VS.NET and tools that come with it. If you want to right an add-in from scratch the article above will be a good place to start.
Johannes Ackermann
|
|
|
|
|
Is it possible to do exactly a client does when it releases a COM object, but from the server?
|
|
|
|
|
hi!
I want to insert an object into MS Word using function AddOleObject. i did it using visual basic 6 using the following function.
InlineShape.AddOleObject(insRange,"{7A4960FC-645E-4971-B2C4-E4C3DB896D10}","",False,False);
where insRange is of Range type. it worked fine. but the problem is that i want to do it in Visual C++6. Now the function prototype in VC++6 is hereunder
MSWord::InlineShapes::AddOLEObject ( VARIANT * ClassType, VARIANT * FileName, VARIANT * LinkToFile, VARIANT * DisplayAsIcon, VARIANT * IconFileName, VARIANT * IconIndex, VARIANT * IconLabel, VARIANT * Range )
i am a bit confused about how to use this function in VC. I tried it using following code.
VARIANT varClassType; VariantInit(&varClassType);
VARIANT varLinkToFile; VariantInit(&varLinkToFile);
VARIANT varDisplayAsIcon; VariantInit(&varDisplayAsIcon);
VARIANT varEmpty; VariantInit(&varEmpty);
VARIANT range; VariantInit(&range);
varClassType.vt = VT_BSTR;
varLinkToFile.vt = VT_BOOL;
varDisplayAsIcon.vt = VT_BOOL;
range.vt = VT_I4;
_bstr_t clsID = "{7A4960FC-645E-4971-B2C4-E4C3DB896D10}";
varClassType.bstrVal = clsID.copy();
varLinkToFile.boolVal = FALSE;
varDisplayAsIcon.boolVal = FALSE;
varEmpty.vt = VT_EMPTY;
range.lVal = 0;
MSWord::InlineShapePtr SigObj = m_pWordApp->ActiveDocument->InlineShapes->AddOLEObject(&varClassType, &varEmpty, &varLinkToFile,&varDisplayAsIcon,&varEmpty, &varEmpty,&varEmpty,&range);
but unfortunately when last line of above code executes my program crashes. i think that the problem is with my first and last parameter in the AddOleObject function. I dont know how to resolve it.
Please help me.
Thanks
|
|
|
|
|
Months ago I was doing a similar type of program, except that it was coded in C++ .NET and used COM Interop.
As I recall, the difficulty was with the VARIANT type, which can be just about anything in COM, but, has no counterpart in the CLR.
Your problem is similar; you have to use the VARIANT type in C++ (there is no natural type in C++ that would be equivalent).
I couldn't figure it out either, but, I'm fairly sure it would involve writing some kind of elaborate series of marshaling functions to structure the data correctly in memory so that COM can understand it.
|
|
|
|
|
Thanks Ursus Zeta!
the thing is that i have also tried to use this function in VC7.1 using COM. but it didn't work out. you can see from my previous post that i have used the VARIANT datatype. but don't know wht's happening. The Error indicates that there is a type mismatch. I am very upset about it. coz i have tried all the datatypes in the VARIANT type.
|
|
|
|
|
i have solved the problem using CComVariant in place of VARIANT.
i replaced the code in my first post with following 2 lines and it worked fine.
CComVariant varClsType("Ascertia.AscertiaObj.1");
MSWord::InlineShapePtr SigObj = m_pWordApp->Selection->InlineShapes->AddOLEObject(&varClsType);
|
|
|
|
|
hi all
can anybody tell me whr i can get the file formats of audio media file like
M4A
MP4
M4B
M4P
LA1
LQT
AAC
MND
MMZ
PCA
RM
RAM
RMX
RAX
so as to identify them.
and also the source code in MFC/SDK to convert them to WMA.
thanx in Advance
SUMIT
sumit kedia
sumitpkedia@yahoo.co.in
|
|
|
|
|
hi,
I read about events and implementation of connection points. I did it and it works fine in vb and c++, but not in vb/javascript!
So now my question is: does it work in IE 6.0 and vbscript/javascript too?
Please help and explain how it works
1000 thx
|
|
|
|
|
The simplest way to sink events from an external COM object in a browser page is to embed an ActiveX control in the page to subscribe to and sink the events. The main problem with this is that users have to download and install the AcvtiveX control. IE will handle this for you automatically when the page loads, but you have to get a security certificate from someone like Versign etc.or many people will not accept the download.
If you atre distributing some sort of application that users have to install anyway, you can include the ActiveX control in your setup package, and add registry keys to mark it safe for scripting and initialiuzation. In this scenario, IE never has to download the control because it is already installed, so you don't need to sign it with Versign, etc.
However, some people have their browser security set to never allow ActiveX controls to load, in which case you cannot use the control to trap the events period.
Robert
|
|
|
|
|
first of all thx very much. B U T;) isn't a 'usual' com object like one created with ATL the same as an ActiveX?
I created a com object, used ATL, connection point Notify and I get the event 'Notify' in vb, c++ but not in IE with javascript or vbscript. the com object is locally installed and registered.
I try to catch event like this:
<script language="vbscript" for="MyComInstance" event="Notify">
alert( "ev " )
</script>
but nothing happens
thx
|
|
|
|
|
The syntax you are using is for HTML page events, not sinking COM events.
You have to create the COM object instance from the web page in order for the web page to receive it's events. Then you can write event handlers.
For example,
If the COM object is already registered locally then you can use code like this (substitute the CLSID for your actual class):
-------------------------------------------------------------------------------------------
<head>
<OBJECT ID=MyCOMObject CLASSID="CLSID:BC89547C-9CC5-445D-A960-567B9B9AB93A"></OBJECT>
<SCRIPT LANGUAGE = "VBScript">
Sub MyCOMObject_Notify()
'Add code here to process your notification event
Msgbox "Trapped Notification"
End Sub
</SCRIPT>
</head>
-------------------------------------------------------------------------------------------
The COM object in this case is always loaded by the OBJECT tag when the web page loads, and unloaded when the web page unloads.
This may not be what you want. If the COM object already exists, what you have to do is write a second object that the web page can load. This second object must contain code that gets a reference to the running COM object, as well as code that allows it to act as a proxy in the web page for relaying the events from the original COM object.
Robert
|
|
|
|
|
hi and thx again,
I tried it again and again, but it don't work!!! I added a messagebox inside the Fire_Notify() method inside the com object and it seems that the IE sink is not registered in my object. the code will not jump in the "for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)"
loop where pDispatch->Invoke is called.
So I think IE simply doesn't register for events (no call for the advise stuff)! I DON'T KNOW WHY!!! anyone who knows how to force IE to do it?
thx
|
|
|
|
|
I would be grateful for help on this problem.
I have a DCOM application running on a client computer, which is started by a process on a server computer. It is important that this application only runs on the clients. The DCOM application is started by calling CoCreateInstanceEx() and an event sink is started using DispEventAdvise(). This works 100% once DCOMCNFG is used to set the launch and access permissions.
On a terminal services setup, the clients run all the processes on a server computer, except for this one DCOM app. When starting the process, the DCOM app starts as expected on the client computer, but when starting the sink, DispEventAdvise() returns 0x80070005 or E_ACCESSDENIED. I cannot find what security setting that I might need to drop in order to remove this problem and I have been pulling my hair out on this matter for some time.
Any assistance would be warmly received.
|
|
|
|
|
Has anyone been successful in executing the
Win32_OperatingSystem class method "Reboot" or "Shutdown" from a call to the ExecMethod routine in C++. This method works fine using VBScript. But in C++, the method returns an error in ExecMethod - WBEM_E_INVALID_METHOD_PARAMETERS.
Why ?
Here is my code :
...
HRESULT hr;
CComPtr<IWbemLocator> pLocator;
CComPtr<IWbemServices> pServices;
CComBSTR bstrPath = L"//";
bstrPath.AppendBSTR(bstrComputer);
bstrPath.Append(L"/root/cimv2");
CComBSTR bstrObject = L"Win32_OperatingSystem";
CComBSTR bstrMethod = L"Win32Shutdown";
CComBSTR bstrLanguage = SysAllocString(L"WQL");
CComBSTR bstrQuery = SysAllocString(L"select * from Win32_OperatingSystem where Primary=true");
CComBSTR bstrFlags = L"Flags";
CComBSTR bstrReserved = L"Reserved";
hr = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hr))
{
cout << "Failed in CoInitializeEx" << endl;
return hr;
}
hr = CoInitializeSecurity(
NULL,
-1, // COM negotiates service
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
if (FAILED(hr))
{
cout << "Failed in CoInitializeSecurity" << endl;
CoUninitialize();
return hr;
}
//get the initial namespace of the CIM Object Manager
hr = pLocator.CoCreateInstance(__uuidof(WbemLocator), 0, CLSCTX_INPROC_SERVER);
if (FAILED(hr)){
cout << "Failed in CoCreateInstance" << endl;
return hr;
}
//create an instance for the interface that connects WBEM services
hr = pLocator->ConnectServer(bstrPath, NULL, NULL, NULL, 0, NULL, NULL, &pServices);
if (FAILED(hr)){
cout << "Failed in ConnectServer" << endl;
return hr;
}
//authenticate to the service, using current credentials
hr = CoSetProxyBlanket(pServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
if (FAILED(hr)){
cout << "Failed in CoSetProxyBlanket" << endl;
return hr;
}
//query WMI for objects: get the Win32_OperatingSystem class using WQL
CComPtr<IEnumWbemClassObject> pEnumWbem;
hr = pServices->ExecQuery(bstrLanguage, bstrQuery, WBEM_FLAG_FORWARD_ONLY, NULL, &pEnumWbem);
if (FAILED(hr)){
cout << "Failed in ExecQuery" << endl;
return hr;
}
//for each returned object call Win32Shutdown
IWbemClassObject* pWbemObject;
DWORD nRetObjects;
pEnumWbem->Reset();
while (pEnumWbem->Next(WBEM_INFINITE, 1, &pWbemObject, &nRetObjects) == S_OK)
{
CComPtr<IWbemClassObject> pClass;
CComPtr<IWbemClassObject> pMethod;
CComPtr<IWbemClassObject> pInParams;
CComPtr<IWbemClassObject> pOutParams;
//get the class definition of Win32_OperatingSystem
hr = pServices->GetObject(bstrObject, 0, NULL, &pClass, NULL);
if (FAILED(hr))
{
cout << "Failed in GetObject" << endl;
pWbemObject->Release();
return hr;
}
//get our method
hr = pClass->GetMethod(bstrMethod, 0, &pMethod, NULL);
if (FAILED(hr))
{
cout << "Failed in GetMethod" << endl;
pWbemObject->Release();
return hr;
}
//create a new object for in parameters
hr = pMethod->SpawnInstance(0, &pInParams);
if (FAILED(hr))
{
cout << "Failed in SpawnInstance" << endl;
pWbemObject->Release();
return hr;
}
//add parameters
CComVariant var;
V_VT(&var) = VT_I4;
V_I4(&var) = (short)nAction;
hr = pInParams->Put(bstrFlags, 0, &var, CIM_SINT32);
if (FAILED(hr))
{
cout << "Failed in Put" << endl;
pWbemObject->Release();
return hr;
}
//call Win32Shutdown with our action
hr = pServices->ExecMethod(bstrObject, bstrMethod, 0L, NULL, pInParams, &pOutParams, NULL);
if(hr == WBEM_E_INVALID_METHOD_PARAMETERS){
cout << "That's it" << endl;
}
if (FAILED(hr)){
cout << "Failed in ExecMethod" << endl;
pWbemObject->Release();
return hr;
}
pWbemObject->Release();
}
Code Red
|
|
|
|
|
We have some in-house Mfc ActiveX controls that need to have transparency (fully opaque to fully transparent) applied to them. We need to be able to see the background (container)
underneath them. I got some code working .... sort of. The problems looks
to be that the container was not drawing the background under the activex
controls. So my control that had some transparency code in it (using
AlphaBlend() of the GDI extended library) would combine its own color or
bitmap with white, the containers color under the control. That's what it
looks like to me.
Another thing is that my code works if the control is run in the ActiveX
control test container of VS6 or VS7 if I resize the control. I placed a
non-related control also on the test container just to be able to "see"
something underneath my control. If I resize mine and have some alpha value
like 50% then I can see the other control.
-SJ
|
|
|
|
|
SJ,
I worked on controls like this a while ago. You need to make your control 'windowless' and get access to the control's parent member "m_pClientSite" via the following code:
LPOLECLIENTSITE YourCOntrol::GetClientSiteMember()
{
return COleControl::m_pClientSite;
}
once you do that, you need to tell the parent to 'refresh' the drawing area when your controls needs it. That is done by using the following code:
IOleInPlaceSiteWindowless* pSiteWindowless = NULL;
GetClientSiteMember()->QueryInterface(IID_IOleInPlaceSiteWindowless,(void **)&pSiteWindowless);
if(pSiteWindowless)
{
pSiteWindowless->InvalidateRgn(NULL, true);
}
else
{
InvalidateControl();
}
That is the starting poing, there are other items you may need to be aware of, such as when your control is 'm_bInPlaceActive' or not and maybe more details need to be addressed depending on the functionality(rendering) of your control.
I would really like to hear how, or if that works, and any other info you came accross while implementing that.
-JL
|
|
|
|
|
I was wondering about the windowless aspect. Does layered windows play a part with this? Thanks for the feedback I will try what you suggested.
-SJ
Manufacturing Software Developer
Hewlett-Packard Company
|
|
|
|
|
Its been a while since I have been able to get back to this code but here I am.
Ok, to keep things simple I created a basic Windowless control that subclasses nothing. To cause the control to update I added a left mouse click handler in the control. I understand that IOleInPlaceObjectWindowless interface will redirect this mouse click from the container back to the control because since the control now has no window of its own it cannot handle the mouse message by itself. Because of the interface now it can. I added it so that I can manually cause the control to be updated therefore causing its OnDraw() method to be called.
So far so good. Then I put your code which calls the method MyControl::GetClientSiteMember() in the left mouse click handler. That works too.
How did you make sure the container had a valid window before calling any functions that report back stuff related to it's window handle? For example, calling GetClientRect() should get the rect for the control but I believe it uses the containers window handle or something like that. If I put GetClientRect in the control's OnDraw() is get an unhandled exception, basically the m_hWnd == NULL.
The whole thing im trying to do is draw a border around the control, draw a few shapes inside the control area rect and allow the container's background underneath the control to show through.
MSDN's Providing Windowless Activation talks about common examples of using windowless controls as having transparent controls. Text is painted but not the control background. They give no further direction as far as I could find.
Your help is appreciated but I think I need a little more direction.
BTW, in case you were wondering, I have successfully created a few MFC and one ATL ActiveX controls (windowed) and they work fine. But they are not transparent nor transluscent.
-SJ
Manufacturing Software Developer
Hewlett-Packard Company
|
|
|
|
|
Two Items:
1) Yes, the windowless control's 'window' is the parents window. GetClientRect should return the contorls size, not its location. When drawing the control, you could get the position/location of your control by using the passed in paramater "rcBounds".
[OnDraw(CDC* pDC, const CRect& rcBounds, const CRect& rcInvalid)]
It may not be necessary, for your control to be windowless. Depending on your needs, you may want to process OnEraseBkgnd function and return 1. This will tell the framework that you have taken care of the drawing/erasing of the background.
2) Second idea, again depending on your needs this may or may not work. Its an ALT 3.0 component and will demonstrate a transparency effect.
Do the following:
a) create an ALT COM component via "Alt COM Wizard" in Visual Studio MFC (I used VC++ 6.0 with MFC)
b) when specifying the control atrributes, unselect the 'Opaque' option (see figure: http://www.microsoft.com/msj/0299/atl3Activex/atlfig12.gif[^])
c) Add a ALT control to your project "Full Control"
d) Process the following messages WM_ERASEBKGND and WM_MOUSEMOVE (OnEraseBkgnd & OnMouseMove)
e) Declare a CPoint member variable name it "m_Point"
f) Drop in the following code for the OnDraw, OnEraseBkgnd and OnMouseMove funstions:
HRESULT OnDraw(ATL_DRAWINFO& di)
{
CString strTemp;
RECT& rc = *(RECT*)di.prcBounds;
//Set Background for text the be transparent
SetBkMode(di.hdcDraw, TRANSPARENT);
//Format Mouse Position Text
strTemp.Format("X: %d Y: %d ",m_Point.x,m_Point.y);
SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
LPCTSTR pszText = strTemp;
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2, pszText, lstrlen(pszText));
return S_OK;
}
LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return 1;
}
LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
m_Point.x = (short)LOWORD(lParam);
m_Point.y = (short)HIWORD(lParam);
HWND hParent = GetParent();
/*For better results, Determine the controls RECT and pass it in the InvalidateRect() fucntion below,
doing this this will result in only your control being redrawn, rather than having your parents entire rect be redrawn and result in flashing/blinking */
::InvalidateRect(hParent, NULL, true);
return 0;
}
Hope that helps you out a bit.
|
|
|
|
|
Hi,
Is it possible to create a com-addin , which can sync contacts,calender and tasks with the remote database using webservices.
The client side addin should be capable of interacting with the server component(typically webservice) which talks to the database.
the addin which sits on the client machine(outlook) should do the following.
1) provide automatic and manual sync ( Configurable)
2) provide UI for configuration
3) scheduling (incase of automatic sync)
4) perform conflict resolution ( data between the database and the outlook items)
last but not least!
is com-addin is the solution , or i have another best option?
Thanks in advance.
|
|
|
|
|
am having 2 problems. First problem has the highest priority. I mean I want to solve my first problem first ASAP.
1.) I am working with powerpoint Automation. Using VB Macro I have to call a function from a dll. This called function in turn has to call another function from another dll. I have been able to call the function from the first dll (using vb macro). Whats my problem is that I m not able to call the function(in second dll) from the first dll. I am using __declspec(dllexport) in the second dll and __declspec(dllimport) in the first dll. I think what I m missing here is that I don't know how to tell the first dll that which dll it shud consider for the called function.
My first dll is for keyboard hooking and second for displaying MS Agent. Can neone help me.
2.) Also, further if anyone can guide me about how to do mouse hooking???
|
|
|
|
|
well for mouse hooking you can use CBT hooks if I remember , see in MSDN for that.
I am still studying your first problem,
May be i will reply in another 10 minutes..
Regards
Tarundeep Singh Kalra
************************
www.tarunsadhana.com
************************
All men die. Not all men really live”. - “Braveheart”, 1995
|
|
|
|
|