|
Hi,
I've been trying to create an ActiveX control to put a directX game in it .
But I can't manage to create a DirectGraphics8 Device for such a control.
IDirect3D8::CreateDevice(...) returns D3DERR_INVALIDCALL
(while the exact same call on a "standard" hWnd, doesn't fail (with all parameters set the same).
I think my problem is to get a handle I can use to create my device...
Can anybody help me doing it or can give me pointers to article that can help ?
thanks.
|
|
|
|
|
Hi All,
I have 2 executables, say A and B.
A uses some activex controls and COM components which I want to use from exe B.
I plan to use the SharedPropertyGroupManager for this, say common.dll
I plan to host this dll in MTS and set the object pooling property for Min and Max as 1 and 1. This dll will take in pointers to the activex components used by app A to store in the SPGM.
I plan to instantiate this dll, common.dll in App 'A' and pass the instantiated activex objects to store in SPGM.
I shall instantiate the common.dll from App B and try getting the objects stored by the SPGM.
Will this work??
Can someone help me with this? If this will not work, what is the work around?
Thanks in advance,
Cheers
Raja
|
|
|
|
|
I wrote an activex control that works well in W98.
It had some problems with extended chars in WinwowsXP, so I recompiled it using unicode support.
And now it works well in WinXP. But I can't register it win w98 nor in wme.
Have I got to distribuite 2 versions (98/me and 2000/xp) or there is some way to have only one activeX working on both systems?
Thanks
Paolo
|
|
|
|
|
Not being able to register sounds like it cannot be loaded. Chances are that you're using API calls which have UNICODE/ANSI versions, eg OpenFileA and OpenFileW. In the UNICODE build, it will be trying to pull in references from the DLLs like KERNEL32, USER32 etc. The XP versions have both ANSI and UNICODE entry points, but the Win9x versions don't, they only have ANSI.
This gives an error when loading the DLL.
To resolve it, you can
(a) have two builds (as you ask)
(b) Build only an ANSI version, but convert all string parameters (in and out) and properties to be BSTR, which are UNICODE strings.
This will require a little extra effort, as you may well need to convert from UNICODE to ANSI for use internally, but it's probably worth it.
Steve S
Developer for hire
|
|
|
|
|
[quote]Not being able to register sounds like it cannot be loaded.[/quote]
It crashes and then reports the error "LoadLibrary failed".
Yes, I'm using socket API with different unicode/ansi version.
At first I had only the ansi version, but it gave me some problems with ext chars; also I don't know where to convert from unicode to ANSI, because the VC++ Wizard declares the called function using "LPCTSTR"...
|
|
|
|
|
|
By using with interface, can i set this filter's special property that we can manully change in Directshow GraphEdit?
thx.
|
|
|
|
|
HI all,
I have a doubt..I have an simple MDI application whose View class is derived from IDispatch so i had implemented all the functions specific to IDispatch and also i have some functions specific to the view class.I have another DLL application in which i have to access that MDI view class fucntion.How can i do it?
|
|
|
|
|
I'm pretty new to COM programming so here goes my question. I've written a component that has some properties. One is written like
STDMETHODIMP CPopClient::get_Response(BSTR *pVal)
{
*pVal = (BSTR) m_bsResponse;
return S_OK;
} Would this be the correct way to use it
IPop->get_Response (&message.AllocSysString ()); Thinking about this I see a problem in that if the CString is null then I'm not allocating anything. So I guess I'm needing to know how I would call the above property from MFC. Thanks.
- Aaron
|
|
|
|
|
No, you need to use a BSTR implicitly.
BSTR bstrVal;
IPop->get_Response (bstrVal);
Your get_Response() implementation should be responsible for allocating storage. Your "client" must therefore free the BSTR when its finished with it. So, remember to call something like:
::SysFreeString(bstrVal);
Hope that helps!
|
|
|
|
|
Thank you for the information.
- Aaron
|
|
|
|
|
Aaron,
If you're using #import for your COM object, then why not use the nice wrappers implemented for you.
e.g.
_bstr_t bstrValue = IPop->GetResponse();
The wrapper tests for failed HRESULTS and also uses _bstr_t which handles Allocs and Deallocs for you.
Hope this helps,
Andy
|
|
|
|
|
AndyQ wrote:
_bstr_t bstrValue = IPop->GetResponse();
Can I use that even though the get_Response is implemeted with the return being a pointer parameter passed in, and the return is an HRESULT?
Thanks for the information on the _bstr_t class.
- Aaron
|
|
|
|
|
Aaron,
If you are using #import you should get two files in the project directory, e.g.
Pop.tli
Pop.thi
These are implementation and header files from the import process. Now you should get different versions of the same method calls. You'll have the 'raw' call that returns the HRESULT as you describe, but there should be another version that simplifies things, an example may look like:
inline _bstr_t IPop::GetResponse( ) {
BSTR _result;
HRESULT _hr = get_Response(&_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _bstr_t(_result, false);
}
Look for the files in your project directory (or debug/release directory) and look through them.
Hope this helps,
Andy
|
|
|
|
|
Ah, that makes a lot of sense now. I wasn't using #import, but that seems like a much better way to do it. I'll give that a go. Thanks very much for the help Andy.
- Aaron
|
|
|
|
|
Hi Aaron,
There is an error in the way you are returning the string, what you are doing is passing the address of the string contained on m_bsResponse to the caller, the problem there is if the instance of CPopClient is destroyed the client will end having an address to a string that is not longer valid. So, what you should do is create a copy of the string and return the address of the copy. Remember BSTR is a pointer to a wide character string, so BSTR * is a pointer to a pointer!!!
STDMETHODIMP CPopClient::get_Response(BSTR *pVal)
{
*pVal = m_bsResponse.Copy();
return S_OK;
}
And the client should do something like this to call it
BSTR sResponse;
IPop->get_Response(&sResponse);<br>
... do something with the string<br>
SysFreeString(sResponse);
Fabian
|
|
|
|
|
Hi,
I’m developing an ActiveX-control in VS C++ 6.0 (winXP): works fine.
For deplyment, I’m using VS.NET for making the Cab-file (New project: Cab
Project). Adds ocx and builds Cab: works fine.
Problem: ocx is depending on 2 other dlls, as it is now they are downloaded and registered manually: this works some times, some times it is "Dll Hell".... "Dll hell" occurs when updating ocx and dlls.... is there any way to force registration and so on? My belive is that it will work fine if I just adds the dll to the Cab File-project, could that be rigth? If so, how do I do it in VS.NET (I know how to add the files, but it’s not working when adding the depending dlls)?
I’m also a bit confused of the making of the Cab File, with VS.NET (Cab Project, OSD-file) it’s easy, but I dont know what I’m doing... old tech, with INF-file, it was harder, but more open I guess?
Which is the best solution in my case?
...and justice for all
APe
|
|
|
|
|
Hi all,
I'm having a strange problem whith an application I'm developing using COM Components. This is the situation:
COM+ Application 1 with components:
COM1A (Transaction: Supported)
COM1B (Transaction: Required) -> I've set transaction timeout to no expire
COM1C (Compensator resource manager)
COM+ Application 2 with components:
COM2A (Transaction: supported)
My front end application calls COM+ Application 2 (COM2A component) which in turn calls COM1A component and this calls COM1B component. This last component starts a transaction against a SAP using the custom CRM COM1C. When this happens, everything hangs. At this point in Component Services window I see COM2A a COM1A active and instantiated and waiting forever (execution time keeps growing) COM1B says 1 1 on object and activated columns but 0 in all other columns, If I see current transactions, there's the transaction started by COM1B active (preparing state) but never resolves (it's not in doubt so I can't manually resolve it).
I've also noticed a couple of things trying to figure what might be happening:
If I disable transactions (setting transaction:supported on component COM1B) everything works fine and the application doesn't hang, components execute and finish
If I keep transactions enabled but I mix both applications in another application with all the components together everything works fine !!! I can't understand this point... What difference might be from having components separated in different applications that can cause this behaviour ?
This is the problem, If somebody has any advice on solving this problem I'll apreciate it !! Is there anything I should be aware when designing transactions or CRMs that could cause this behaviour ?
Thx in advance.
ori
|
|
|
|
|
Dear C++ Experts,
Does anyone have sample code to use GoToDate method in the Outlook View Control activex using C++ code?
Thanks,
-Henry
|
|
|
|
|
Hai to all,
here i am developing one COM server it has one method, and three parameter. i want to exachange the data. please can you check the this program. it has no errors but it is not working.
i think method impementation is not correct?
TestCOMServer.idl:
[id(1), helpstring("method GetFunctionState")] HRESULT GetFunctionState([in, out] short* pflEnd, [in, out] BSTR* pstrStrParam1, [in, out] BSTR* pstrStrParam2);
Here,i insert the one ATL Control(full control)
TestCOM.cpp
STDMETHODIMP CTestCOM::GetFunctionState(short* pflEnd, BSTR* pstrStrParam1, BSTR* pstrStrParam2)
{
HRESULT hResult = S_OK;
*pflEnd = bFinished;
*pstrStrParam1 = strStrVariable1;
*pstrStrParam2 = strStrVariable2;
if (*pflEnd = 1)
bFinished = 0;
...........................
..............
//here please fill with stuff
return hResult;
}
thanks to all
sudheer
|
|
|
|
|
I've written an OLE control using MFC. My control derives from COleControl. When I place the control into a VB container I am receiving only one WM_MOVE notification at the beginning. After that when ever I move the VB app around my control doesn't receive any notification.
Does anyone know what I am missing? Is there some interface I should call or support?
|
|
|
|
|
Dear all,
I have been trying to create COM object using ATL and VStudio 6.00 that will implement a TCP/IP client. The idea is as follows:
A COM object that Implements connectable interface is creating a thread that monitors the TCP/IP port. The thread has a pointer to the COM object so when it receives something from the TCP/IP port it "calls back" the Notify(BSTR msg) method of the COM object. The Notify method of the COM object performs a Fire_MessageReceived call to the event proxy class. Eventually the registered for events clients receive the message.
This mechanism works perfect till the point that the proxy class calls the Invoke method for each client. I get an Access violation on the Client.exe error 0xC0000005 ( I may have missed a 0 ). Stepping in the proxy class I can see that the connection counter is correct and that also the messages have been correctly assigned to VARIANTS. No out-of scope case... The funny thing is that this problem happens ALWAYS when the Clinet application is a VB programm and seldom when the client application is a C++ application.
Any help will be really appreciated
Kind regards
Giannis
|
|
|
|
|
In your worker thread you have to initialize the COM library for that thread, i.e. create an apartment, by matching calls to ::CoInitialize() and ::CoUninitialize(). I suspect that you haven't done so and that could explain why it works when the client is implemented in C++.
Given the above you are firing events from another apartment and you have to marshal the the sink interface since you are crossing apartment boundaries. Have a look at Michael Lindig's solution for one way of doing this through the GIT at
http://www.codeguru.com/Cpp/COM-Tech/atl/atl/article.php/c75/
I have used this solution and I've found it very useful.
If this doesn't help and if you are not using typelib-marshaling, try doing so by adding the keyword 'oleautomation' in the interface definition in the IDL file. If this helps you have a problem with your proxy-stub.
--
Roger
|
|
|
|
|
Roger,
I can only say that I am really thankfull for this answer of yours. Great info and just when I had started to get dissapointed.
I actually followed the solution proposed by the article in CodeGuru you pointed to and it worked perfectly. If I am not mistaken the first paragraph of your replay, to use CoInitialise() in my worker thread, could be a reason for my problems. But although I did so, it didn't short out anything. So only Michael Lindig's solution worked staigh out of the box!
I final note, it seems that VisulaStudio.NET is not very happy though with this solution (don't know why). Can't explain why the same code in VC6 is working while when compiled on VS.NEt C++ it behaves like I before (carsh the client regarless Michael Lindig's solution).
So thank you very much for one more time
Giannis
|
|
|
|
|
Giannis,
Thanks for your thanks!
I'm glad I was able to help you.
However, I didn't expect ::CoInitialize() in the worker thread to solve your problem. I just wanted to make sure you were initializing COM correctly in your thread since the rest of the steps won't work unless the apartment is properly set up.
Regarding VC7 and the .NET environment I cannot help you since I'm still running VC6. But I would expect it to work with VC7 as well.
Anyone else who has problems with GIT marshaling using VC7 / .NET?
--
Roger
|
|
|
|