|
Hi,
Yes, your solution is right.
Thank for the help.
Regards,
Mandar
|
|
|
|
|
any place to get detailed info on variant arrays..and how to use them??
|
|
|
|
|
MSDN.
A variant array is just that, an array of VARIANT types, use just like any other kind of SAFEARRAY, except of course, that your basic array type is VARIANT rather than BSTR or whatever.
It's worth remembering that SafeArrayGetElement and SafeArrayPutElement deal with COPYING the data they work with, so Get gives you a new, second, copy and Put will not care what you do with the original you pass it. This is true for other "managed" types (IUnknown, BSTR etc) not just VARIANTs.
Of course, your element type is determined by the .vt member of each element, not by the type of the array, but each element is the same size
Steve S
|
|
|
|
|
guys i have a variant..being returned by a method..how do i get its vt..and also how do i then extract the value from this variant..
thanks
-anand
|
|
|
|
|
|
hey thanks ian..
one more thing plz..how do i then get the value from this variant?
thanks
|
|
|
|
|
Depends what it is. There are various macros beginning V_ that you might find useful.
Say you have
VARIANT v;
HRESULT x = myobj.mycall(...,...,..., &v);
You can have code like this:
switch(V_VT(&v))
{
case VT_BSTR: // Returned a string
// V_BSTR(&v) is the BSTR being passed back...
break;
case VT_I4: // Returned a 'long'
// V_I4(&v) is the number
and so on.
Does that help?
Steve S
|
|
|
|
|
Dang! You beat me to it
|
|
|
|
|
Thanks a lot people...
|
|
|
|
|
Hi,
I've created a control with rounded corners by calling SetWindowRgn. If you place this control on a VB-form and keep on loading/unloading the form, a memory leak appears. If you remove the call to SetWindowRgn, there's no memory leak. MSDN says that you should delete a region after a call to SetWindowRgn because Windows will delete it when it is finished with it, but it seems to me this moment is not until the program exits.
Has anyone any noticed also noticed this ?
|
|
|
|
|
But did you delete the region that you had created?
P.R.A.K.A.S.H
|
|
|
|
|
No I didn't because that is what MSDN is saying in the Remarks section of SetWindowRgn :
After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not delete this region handle. The system deletes the region handle when it no longer needed.
|
|
|
|
|
yeah u are rite, it should not be deleted that means then its not a porblem, windows may be removing it form the memory when it feels ok to remove it,
may be internal Garbage collector
One more thing, how many times the setwindowrgn is called???
If you call it twice, then its going to leak the memory.
P.R.A.K.A.S.H
|
|
|
|
|
What you say illustrates the problem, Windows will delete the memory when it thinks it is done with the region, but it seems to me that is not until termination of the application. My control calls SetWindowRgn each time the dimensions of the control or some visual property like the backcolor change, so yes, that is considerabye more then twice.
This is a problem because now, applications which use my control are forced not use Load/Unload constructs for forms with my control on it.
|
|
|
|
|
WHat is the exact difference between Win32 DLL and ATL DLL,
u can paste the gooooogled ans..or whatsoever..I have been asked this question at two places..
|
|
|
|
|
Win32Dll or ATL dll, both are dlls and same w.r.t the windows OS, The only difference lies how they are used..
To be short.. ATL dlls or COM dlls export certain apis like
DllMain
DllRegister
DllUnregister
DllCanunloadnow
etc
This apis helps to create a COM object from the dll.
P.R.A.K.A.S.H
|
|
|
|
|
Hi all,
I'm trying to make an activeX control that can be embedded in an HTML page to upload (multiple) files. (similar to JUpload -www.jupload.biz-, but then not a Java applet, similar to XUpload -www.aspupload.com-, but then without an ASP server component).
The language of the COM object is not important.
I've been searching the web for some starters but found little.
Does anybody have some interesting links for me? Ideally, some sample open source code.
TIA,
Corno
|
|
|
|
|
Hi All,
I have a VB ocx which contains 3 objects/classes. I imported them into VC6 with no problems.
In the code I need to tell the objects about each other. It goes something like this...
CMyObject1 myOb1;
CMyObject2 myOb2;
CMyObject3 myOb3;
myOb1.SetRefOb2(myOb2.m_lpDispatch);
myOb1.SetRefOb3(myOb3.m_lpDispatch);
When I run this I get a VB message box saying the object is no longer set! Also I get an OLE error in my debug output saying there is a NULL lpDispatch.
I attempted this...
HRESULT hr = CoInitialize(NULL);
CLSID clsid;
hr = CLSIDFromProgID(L"clsid.myOb2", &clsid);
myOb2.CreateDispatch(clsid);
qb.SetRefDiagramPane(&myOb2.m_lpDispatch);
CoUninitialize();
This seems to work ok but my application seriously crashes when it quits if I do this.
Any ideas how I am supposed to call these SetRef(LPDISPATCH *) functions?
Thanks,
Chris
|
|
|
|
|
i am developing an activeX control which displays a print preview.The print preview style depends on user input.The styles are controlled by print preview template files which reside on the web server.
i am using the following code:
CComPtr<iolecontainer> spContainer;
CComPtr<iserviceprovider> spSP;
CComPtr<iwebbrowser2> spWB;
CComPtr<idispatch> spDisp;
CComPtr<ihtmldocument2> spDoc;
CComPtr<iolecommandtarget> spCT;
CComVariant vPTPath = "res://BrochureMachine.dll/PT.htm";
m_spClientSite->GetContainer(&spContainer);
spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP);
spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB);
spWB->get_Document(&spDisp);
spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc);
spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT);
spCT->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW, NULL, &vPTPath, NULL);
return S_OK;
this compiles fine but when i execute it i get a blank print teplate file.But when the file url is used everthing goes fine.
Waiting for your valuable help
regards
jithus
|
|
|
|
|
m_spClientSite cau u tell me how to define this"m_spClientSite"?
3ks,best regards!
|
|
|
|
|
I have a VC++ COM Component that has an interface with OUT Values as Safearray of long as well as safearray of double.
I need to pass these to the C# which interprets it as a Ssytem.Array. I am running into issues with the same.
Could I pls request for a sample application that has a VC++ returning arrays of long as well as double and the C# being able to access the details..
Thanx
Sheela
|
|
|
|
|
Hi!
I call CreateDispatch on COleDispatchDriver and it's very slow. I think that's because i call a .Net COM object. Is it true? Can i make it faster somehow?
dzsigit
|
|
|
|
|
When you load a .NET control, the CLR has to be loaded and the managed AppDomain created. There is some overhead that you can't avoid. Other than that - optimize your code in the .NET control's initialization methods.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know this is possible, but can't for the life of me figure it out... How the heck do you get a list of the events, properties and methods implimented in an object, especially you didn't design it and may not have any documentation on how it works?
I don't see any obvious way to do this, but I know some programs do, especially the compilers themselves, when dealing with a COM object not listed in its own list of known objects.
|
|
|
|
|
Since you are dealing with COM, and not .NET, you will only be able to discover a limited amount of information about your mystery COM object. Assuming that you have no source code, you will have to deal with some form of a type library. Chances are that the type library is stored as a resource in the same binary (i.e., dll) as the mystery object. Only OLE Automation compatible things can be be described in a type library, so if the interfaces use custom interfaces or user defined data types, you are left a little more in the dark.
Do you know the names of all of the objects and interfaces that this COM server serves up?
Have you registered it?
Whether you have VS6 or VS.NET, there exists a tool called OLEVIEW.EXE whcih can decipher the contents of the registry and type library information on a registered COM Server. Just Start OLE View, and expand the "All Objects" category. You ought to be able to find your object in there.
If you don't know the names of things that are served up by your mystery object, you can search the registry for the filename to discover CLSIDs and ProgIDs that you can use to search Ole View.
Good Luck, but you are likely to be disappointed by the limited amount of information that you will find.
|
|
|
|