|
I have to agree with Michael. Attributed COM/ATL is one of the most stupid idea ever conceived by the VC++ team... It's inefficient at compile time (Zzzzzz), and it causes general headaches in cases such as these.
MIDL for the win!
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
hmmm, yeah i'm not enjoying using Attributed ATL. I only used it because I started a new project in VS 2003 and it must have been the default setting back then and so i thought "It must be better and the thing todo" so it has stuck with this particular project since then...
I'm not looking forward to rewriting it though, i figured that forward declaration was such a common thing that there would be a well known solution.
Jared Allen.
www.chironexsoftware.com
|
|
|
|
|
The idea is to create some add-on in a program using COM functions interface exist in his own API.
The particular type which I try to implement is a generic one , let say MyClass, and is declared like below:
//MyClassPtr declaration;
_COM_SMARTPTR_TYPEDEF(MyClass, __uuidof(IDispatch));
//The class itself
struct __declspec(uuid("5e772660-389b-11ce-ba48-080036250302"))
MyClass : IDispatch
{
...
// other functions...
...
IDispatchPtr Function1;
__declspec(property(get=GetArea,put=PutArea))
IDispatchPtr Function2;
__declspec(property(get=GetSize))
...
}
I create an instance of MyClass using:
MyClassPtr pMyInstance;
This pMyInsatance have to be provided to another API function but in form of a SAFEARRAY!This function can look like below:
FinalFunction(SAFEARRAY * * pMyClassInstances, .. , ..)
So I have to convert my variable MyClass (can be more than one in my code of course, but I want to limit only to one instance for now) to this SAFEARRAY .. How can I do this?
I try:
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 1;
long a=0;
SAFEARRAY * vMyClassArray;
vMyClassArray.vt = VT_VARIANT|VT_ARRAY;
vMyClassArray= SafeArrayCreate(VT_VARIANT, 1, rgsabound);
SafeArrayPutElement(vMyClassArray .parray, &a, &(pMyInstance));
Finally I put my class instance as an argument for:
FinalFunction(pMyInstance, .. , ..)
It doesn't seem to work, probably because argument pMyInstance can not be express as a VARIANT declarated type.
The class I want to work with - MyClass- which exist in a .tlh file, is part of the API interface, so it is not exactly a user define type, but more an interface define type. I mention this becose I try to work with VT_RECORD type in SafeArrayCreate(...) instead of VT_VARIANT type, but this imply an idl function declaration for my type, and other additional stuff
Any ideea ??
|
|
|
|
|
I use a third part COM API lib. I need to pass an array of double to a method which accept VARIANT*, Is there any simple way to cast from double* to VARIANT*, I don't want to create a VARIANT array and copy each double value into it.
|
|
|
|
|
songll wrote: I don't want to create a VARIANT array and copy each double value into it.
Hmmmm - no can do. You'll need to pass a VARIANT that contains a SAFEARRAY of doubles. Something like:
SAFEARRAY* sa = SafeArrayCreateVector(VT_R8, 0, count);
double* pSAData;
if (SUCCEEDED(SafeArrayAccessData(sa, (void HUGEP**)&pSAData)))
{
std::copy(start, start+count, pSAData);
SafeArrayUnaccessData(sa);
VARIANT v;
V_VT(&v) = VT_ARRAY|VT_R8;
V_ARRAY(&v) = sa;
} should set the VARIANT , then you can pass a pointer to it.
|
|
|
|
|
Stuart Dootson wrote: HUGEP
Dude.. it's 2007!
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
Joergen Sigvardsson wrote: Dude.. it's 2007!
Tell that to Microsoft - it's copy'n'pasted from their documentation...
|
|
|
|
|
Just pullin' your leg..
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
Hi,
I am trying to fire an event from the worker thread and it worked fine as long as I worked with a VB client inside VB development environment. As I created an exe and ran, it was crashing and found that there is a KB article in Microsoft on that talking about marshalling the sink interface (http://support.microsoft.com/kb/q280512/ ). But, when I use that, I am getting a 0x80004002 error in the pDispatch->Invoke. Appreciate your help in sorting out this issue,
Thanks & Regards,
Satish
|
|
|
|
|
What have you done so far?
Have you initialized the new apartment with a call to ::CoInitialize() ?
You cannot fire events from a secondary thread without marshalling since the call crosses apartment boundaries.
You could also post a message to the main thread and fire the event from there.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hello Satishkumar,
Not sure why you are getting your error. I've tried to use ATLCPImplMT.h entirely as advised by the MSDN article in http://support.microsoft.com/kb/q280512/[^]
and faced no problem.
If you would like to have a look at my sample codes, pls email me :
bio_lim_2004@yahoo.com
Regards,
Bio.
|
|
|
|
|
//Belows are from MSDN2003, an example about hash_set::find
// hash_map_find.cpp
// compile with: /EHsc
#define _DEFINE_DEPRECATED_HASH_CLASSES 0
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_map <int, int=""> hm1;
hash_map <int, int=""> :: const_iterator hm1_AcIter, hm1_RcIter;
typedef pair <int, int=""> Int_Pair;
hm1.insert ( Int_Pair ( 1, 10 ) );
hm1.insert ( Int_Pair ( 2, 20 ) );
hm1.insert ( Int_Pair ( 3, 30 ) );
hm1_RcIter = hm1.find( 2 );
cout << "The element of hash_map hm1 with a key of 2 is: "
<< hm1_RcIter -> second << "." << endl;
// If no match is found for the key, end( ) is returned
hm1_RcIter = hm1.find( 4 );
if ( hm1_RcIter == hm1.end( ) )
cout << "The hash_map hm1 doesn't have an element "
<< "with a key of 4." << endl;
else
cout << "The element of hash_map hm1 with a key of 4 is: "
<< hm1_RcIter -> second << "." << endl;
// The element at a specific location in the hash_map can be found
// using a dereferenced iterator addressing the location
hm1_AcIter = hm1.end( );
hm1_AcIter--;
hm1_RcIter = hm1.find( hm1_AcIter -> first );
cout << "The element of hm1 with a key matching "
<< "that of the last element is: "
<< hm1_RcIter -> second << "." << endl;
}
Output
The element of hash_map hm1 with a key of 2 is: 20.
The hash_map hm1 doesn't have an element with a key of 4.
The element of hm1 with a key matching that of the last element is: 30
My question is: hm1_RcIter is definded as a iterator, how can it use the member function of Pair: "hm1_RcIter -> second "? what is wrong?
|
|
|
|
|
An iterator just has 2 pointers. First pointer points to the key value. Second pointer points to the value itself for that key. The member variable/function second is not a member of the pair class. It is a specific part of the iterator itself.
From what I can see, nothing is wrong with your code. What's the problem? Nothing.
|
|
|
|
|
I build my project with "Win32 Unicode Release MinSize" setting. It defines "_UNICODE", "_ATL_DLL", "_ATL_MIN_CRT". And I don't want my dll to use MFC and CRT.
now I need to format strings. I think I should prevent calling functions like "_stprintf" from using CRT. But I don't know other way to fromat strings. Can you tell me some helpful Win32 functions. Or, maybe my idea is wrong!
|
|
|
|
|
|
I have a dll written in C++ running in a Linux machine. Now i want to move that dll to a Windows system and use it with a Windows application.
How can i do that?
Can you please tell what all are the performance issues i face?
What all are the dependencies?
Thanks in advance
|
|
|
|
|
Do you want to use this dll on the C++?
|
|
|
|
|
Hi All,
I am working on an ActiveX based project.
I am using AtlAxCreateDialog method to create a dialog whose resources have been specified in a RC file. The dialogue gets created perfectly fine but i have not been able to handle its events like OnSize, OnClose etc
It has taken me a while to solve this problem but didn't succeed. Kindly, help me.
AZ
Aamir Zia
|
|
|
|
|
Calling AtlAxCreateDialog directly is unusual: normally it’s called for you in the implementation of the CAxDialogImpl::Create method.
Steve
|
|
|
|
|
I have created a toolbar for IE and added a an edit control to it, but I couldn't add a menu control beside to the edit control. Can anybody help me, please. Thanks a lot.
love U much...
|
|
|
|
|
first, create a menu in your resource file.
second, put a button to the toolbar that will open the menu up with a style BTNS_WHOLEDROPDOWN
third, get a command handler handle the button's command ( WM_COMMAND message )
and lastly, write a method that creates the menu and tracks it. something like:
HMENU hM = ::LoadMenu(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(ID_MENU);
HMENU hMPopUp = ::GetSubMenu(hM,0);
::TrackPopupMenu(hMPopUp,TPM_TOPALIGN,pointX,pointY,0,m_hWnd,NULL);
that's the way i did it, i think you can handle the rest with the holy MSDN
|
|
|
|
|
There's this file that I wanna open from my web application, but I want it to open by Google Earth, the file is not located on the server it's on the user's computer but the application knows its name and path: "C:\\Places.kml"
How can I do that? I'm using ASP.NET web application in C#
|
|
|
|
|
Hello All,
I am opening a word document and save it usually and now i am changing some text in this file then
i have to save this file programmatically so what i have to for that.
If any one have idea about that please share with me.
Thanks & Regards
Bankey
|
|
|
|
|
What does this have to do with ATL/WTL? You are in the wrong forum...
|
|
|
|
|
Can you more explain and with which language?
|
|
|
|