|
What are the limitations of using an ATL? Can a regular program (of course w/o GUI) be implemented as an ATL including calling a function inside the same .cpp, using structs, CStrings, MFC functions, etc? Thanx
|
|
|
|
|
Hi,
I have MFC static library Led Lib which is editor library.
I want to implement the View class of this library as Control using ATL COM?
Tried but not getting the actual Picture?
How can I do it?
Thanks in advance
-Hemant
|
|
|
|
|
what are .tlh files?
could anyone give me the links for COM tutorials?
thanx in advance
|
|
|
|
|
nvamshi wrote:
could anyone give me the links for COM tutorials?
http://www.codeproject.com/com/[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
.tlh and .tli files are created automatically by the compiler when you #import typelibraries. The .tlh file contains the "header" part, and the .tli file contains the "implementation" part, should you generate dispatch wrappers and stuff like that. These files are injected automatically into the code by the compiler, so you don't have to worry about them.
--
Look straight into the light!
|
|
|
|
|
I know the composite control is implemented by CWindowImpl.I think i can get the HDC of the control and operate it.but always occur an error.
my code as follow(in control class):
HDC hdc = GetDC();
LPSTR lpText = "hello world";
::TextOut(hdc,0,0,lpText,lstrlen(lpText));
ReleaseDC(hdc);
I use this control in ie.the code can execute successfulLy.but an error report will gave when i close the ie.error message:Microsfot Internet Explorer met an question and need to be closed...
the same thing happened when i operate the contained control in the dialog.
HDC hdc = ::GetDC(GetDlgItem(IDC_xxx));
::TextOut(hdc,0,0,lpText,lstrlen(lpText);
ReleaseDC(hdc);
I don't know if i say it clearly.thanks all.
|
|
|
|
|
Hi,
My problem is the follow one:
who to know, everything that I will go to describe will be about OPOS(Ole Point-of-Service)
I have many Automation Controllers. There are many ocx.
These ocxs are the Control Objects to an specific device( like CashDrawer ). The Control Object make calls to methods that are implemented in a Service Object. Each device or device class has a Service Object. This Service Object can be ATL or MFC.
I need to know how do I have to create a projec in Visual c++ 6.0 to build a Automation Server(Service Object). What steps do i have to do? Like what kind of Server type( Dynamic Link Library, Executable or Service), which check box do I have to check( allow merging of proxy, support MFC and/or support MTS) or
which ATL Object do I have to insert in project?
To show an example, the CrashDrawer's Control object defines the fallow method:
long COPOSCashDrawer::GetOpenResult()
{
long result;
InvokeHelper(0x31, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
How do I have define the Service Object to answer that method? I really dont't know how to do that. Please i need your help!
Grateful!
Hélio
|
|
|
|
|
if we return a sigle value, its fine, but if u wanna send a structure?
for example, i want to send,
[code]
typedef struct
{
BSTR Name;
long num;
double d;
}st;
[code]
how to send this across?.. how to define in "Add method" dialog?
in VB i guess we can accept using "Type"
[vb code]
private Type TestType
Name as string
num as long
d as double
end type
[/vb code]
can we do like ,in add-method [int z,[out,retval]st xyz] ??
will this work?
V
|
|
|
|
|
First create the UDT in IDL. There are examples in the MSDN docs on how to do it. They're very similar to ordinary structs in C/C++. Make sure the UDTs are referred to in the library block of the IDL file, so that VB gets the needed type information.
Then you just type in "struct YourUdtName" in the type box in the add method dialog. If you want, you can make a typedef in the IDL code like typedef struct tagYourUdtName { ... } YourUdtName; . Then you can type "YourUdtName" in the type box in the add method dialog.
--
Keep talking! I'm the preacher, you're a fool.
|
|
|
|
|
|
Did it work out well for you? (I still feel a bit ashamed for the ATL wizard stuff )
--
Look straight into the light!
|
|
|
|
|
actually, it could be done using Type in VB itself, no need to create an UDT in the Component. the requirement was like that. eg:
[ATL]
Fire_Event(BSTR Num,long Num)
[/ATL]
[VB]
Public Type MyType
Name as String
Num as long
End type
[/VB]
so in the client app, i assigned it like
MyType obj
Private ob_newEvent(String Name,Long num)
ob.Name = Name
obj.num=num
End sub
so i didn't find the need. But the terror strikes again,... soon i'll have to get these arguments in the method itself just like we did with Events.i'll try it at that time..so we'll meet again very soon.
[sorry for delay, just now i clicked on ATL ]
V
|
|
|
|
|
I know there are many interfaces can operate the html document.but i don't know how can get them.
I can get the IHTMLDocument2 interface pointer,but,how can i get the specified item interface in the document?i check the sdk document and know the IHTMLDocument2 has an collection property named "all",I don't know how to use this property.
my code as follow:
//get the container interface
CComPtr<iolecontainer> spIE;
m_spClientSite->GetContainer(&spIE);
//get IHTMLDocument2 interface
CComQIPtr<ihtmldocument2 ,="" &iid_ihtmldocument2=""> spDoc(spIE);
//now i can operate the document ,but i don't know how to get the item in it.
where can i get more detailed document? thanks all.
|
|
|
|
|
I caught it.Get IElementCollection interface through "all" property of document.then get IDispatch through item property of IElementCollection and then QI IHTMLElement interface.
|
|
|
|
|
help on writing routines of garbage collection & compaction
|
|
|
|
|
i want to program the video a ram so tht the bit patterns i expect will be displayed on the screen. using C i want to do this. because of lack of interrupt information this is waiting
|
|
|
|
|
Hi,
My problem is the follow one:
who to know, everything that I will go to describe will be about OPOS(Ole Point-of-Service)
I have many Automation Controllers. There are many ocx.
These ocxs are the Control Objects to an specific device( like CashDrawer ). The Control Object make calls to methods that are implemented in a Service Object. Each device or device class has a Service Object. This Service Object can be ATL or MFC.
I need to know how do I have to create a projec in Visual c++ 6.0 to build a Automation Server(Service Object). What steps do i have to do? Like what kind of Server type( Dynamic Link Library, Executable or Service), which check box do I have to check( allow merging of proxy, support MFC and/or support MTS) or
which ATL Object do I have to insert in project?
To show an example, the CrashDrawer's Control object defines the fallow method:
long COPOSCashDrawer::GetOpenResult()
{
long result;
InvokeHelper(0x31, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
How do I have define the Service Object to answer that method? I really dont't know how to do that. Please i need your help!
Grateful!
Hélio
|
|
|
|
|
Hi - a double has max size of e308 and min of e-308 (or 307, irrelevant in this case). I can stream out doubles up (down?) to a size of e-324, but only read them back in at e-308. Any ideas? Test code below - sorry for length....
Cheers
Angel
double dTestarray[30];
dTestarray[0] = 1.23456789e-301;
for (int i = 1 ; i < 30 ; ++i)
dTestarray[i] = dTestarray[i-1] / 10;
std::ofstream fout("c:\\double.txt" , std::ios::out);
for (i = 0 ; i < 30 ; ++i)
fout << dTestarray[i] << std::endl;
fout.close();
double dTest(0);
std::ifstream fin("c:\\double.txt" , std::ios::in);
int Line(1);
while (fin)
{
fin >> dTest;
if (fin.fail())
std::cout << "Failed on line " << Line << std::endl;
else
std::cout << "Line " << Line++ << " read as " << dTest << std::endl;
}
*********************************************
The sooner you fall behind, the longer you have to catch up.
-- modified at 8:46 Wednesday 28th September, 2005
|
|
|
|
|
I made a simple activex control, can't run on win98.the container is ie.
i tried these steps:
1.I tried to reg the control dll,but failed,prompt 'cant load the dll'.
2.I found that there was no atl.dll in win98.so i copied one from win2000 to c:\windows\system
3.reg the control dll by regsvr32 again.(failed,prompt 'cant run unicode version of atl.dll on windows95.Pls install correct version.') my problem:how can i get the correct version?
what shall i do? thanks all.
|
|
|
|
|
Their exist two different versions of atl.dll, one with unicode and one without. Both are provieded by Microsft and can be redistributed by everybody. For example all "better" setup programs include both versions of atl.dll. We avoid this kind of problem by delivering the "ReleaseMinDependency"-build, because this build statically links to atl.dll.
|
|
|
|
|
Ok.I think releaseMinDependency-build is better and easier.will try.Thank you!
|
|
|
|
|
disinterface is not getting created for my component. i dont find anything starting with a "_"(underscore)ISample" i mean _ISample. how to generate it? can we mannually add a disinterface? please help. time critical!
thanks
v
|
|
|
|
|
Are you talking about event source interfaces? If the class wizard has screwed up (which it often does), then create a new ATL project, and create a dummy class. Create the event source interface in its IDL file, and make the classwizard generate the proxy code. Then simply copy the code from that project to your old project.
All that's needed really is a block in the type library, and the proxy code (for easy generation of events).
--
Keep talking! You're the fool, I'm the preacher.
|
|
|
|
|
jorgen, ya your are right, i'm missing the "Fire_"menthods (for raising events) inside template class, which is given in the header file like,
[code]
#ifndef _ATL21CP_H_
#define _ATL21CP_H_
template <class t="">
class CProxy_IIATL21Events : public IConnectionPointImpl<t, &diid__iiatl21events,="" ccomdynamicunkarray="">
{
public:
};
#endif
[/code]
even thought i create methods with the right sequence, only the interface definition is getting created like,
[code]
[id(2), helpstring("method UseCount")] void UseCount([in]long Total);
[/code]
actually, the definition for Fire_ event should have generated in the header file , like
[code]
VOID Fire_UseCount(SHORT Total)
{
T* pT = static_cast<t*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<iunknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<idispatch*>(sp.p);
if (pDispatch != NULL)
{
pvars[0] = TotalMarks;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
}
delete[] pvars;
}
[/code]
So, whatz the problem with my wizard?so everytime should i copy it from the dummy proj(actually its not being generated in the dummy proj also, i'm just copying from another working source)? cant we fix it?
[I HOPE BOTH ARE TALKING ABOUT THE SAME ISSUE]
Thanks buddy
V
|
|
|
|
|
Frankly, I don't know why the wizard acts like that. IIRC, the wizards use special "markers" in the code, to determine where to inject code. What those markers are, I am not sure.
Have you tried recreating the solution/project? If it's not more than 10-20 files, and has few and non-complex build configurations, then it might be worth the effort to generate a new project, and then add back everything by using the wizard. Be sure to retain the old CLSIDs and IIDs, if your components have been published earlier.
I'm sorry I can't be of much help
--
Keep talking! You're the fool, I'm the preacher.
|
|
|
|
|