|
You need a java forum not a C++ forum. Give a little more detail when describing your problem.
-- modified at 8:59 Tuesday 27th June, 2006
|
|
|
|
|
Hi,
I have created an ATL executable.
It has only CExeModule (base -> CComModule)
I inserted a dialog. and in _tWinMain ,
I create this dialog and show.
So when I execute this exe itself, dialog shows up.
Now I want this COM exe to be used in a VB program.
I give the reference to this particular component .
But in code how may I use this to show my dialog in my exe COM.
had there been an Interface with method showdialog (where dialo will be created and showed),
I would have used similar to..
Dim obj as Object
Set obj = new MyInterface
obj->showdialog
1. But without such interface , how can I show up my dialog in VB , if the dialog itself is created at the entry point of com i.e. in _tWinMain
2. If the ATL exe has interface and method (to show dialog), then how can I use ATL exe itself to show the dialog.
Thanks
Row
|
|
|
|
|
You souldn't put the call the show the dialog in WinMain . You should use the ATL wizard to add a COM object to the project the put the call to show the dailog in one of the interface methods implemented by the object.
Steve
|
|
|
|
|
I have a win32 library with no interfaces , just only exported functions.
e.g. One of those is .. bool getInfo (char *string, int counter);
I created a ATL exe , inserted a simple object.No I want to link the above library to my ATL project.
So in Project->settings->link, I gave the lib name and directory of the lib file.
Now I want to use this function getInfo in my atl program.
SO I added one method in my interface say CallLibFunction
And in that method I want to call getInfo..
Are these steps ok?
Please let me know, any other precaution or regarding data types???
Kindly let me know.
Row
|
|
|
|
|
You may need to declare the getInfo signatrure to satisfy the compiler.
bool getInfo (char *string, int counter);
Implimentation will be taken from the .lib file.
cheers...milton KB
|
|
|
|
|
You need to include a header file that should be provided with the library.
|
|
|
|
|
I'm trying to create a .dll using ATL, which I want use in C#.
Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string)..
I tried a lot but always faced problem of returing string back to calling function in C#.
I did the same with C++ class library successfully but when it comes to ATL its not the same.
As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL.
Now please guide me to create the methods which I can use in C# to get the string value.
Arun
|
|
|
|
|
I assume that you don't use attributes in your project, and you want to have a property named 'Title' of type BSTR (COM string type)
in your IDL file:
interface IYourInterface: IDispatch{
[propget, id(1), helpstring("property Title")] HRESULT Title([out, retval] BSTR *pVal);
[propput, id(1), helpstring("property Title")] HRESULT Title([in] BSTR newVal);
};
in the header file of your object:
public:
STDMETHOD(get_Title)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Title)(/*[in]*/ BSTR newVal);
private:
_bstr_t m_bstrTitle; // variable holding the property value
and in the implementation file of your object:
STDMETHODIMP CYourClass::get_Title(BSTR *pVal)
{
*pVal = m_bstrTitle.copy();
return S_OK;
}
STDMETHODIMP CYourClass::put_Title(BSTR newVal)
{
m_bstrTitle = _bstr_t(newVal);
return S_OK;
}
-- modified at 15:53 Monday 19th June, 2006
|
|
|
|
|
hello @ Roozbeh69 thanks for that solution but I have faced few problems which are listed below :
I have created property using wizard but when it comes to
<br />
private:<br />
_bstr_t m_bstrTitle;
<br />
and in the implementation file of your object:<br />
<br />
STDMETHODIMP CYourClass::get_Title(BSTR *pVal)<br />
{<br />
*pVal = m_bstrTitle.copy();
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CYourClass::put_Title(BSTR newVal)<br />
{<br />
m_bstrTitle = _bstr_t(newVal);
return S_OK;<br />
}<br />
and As per me the syntax which u have given varies a lot from auto generated one. I'm using VS 2005.
Once again I would like to clear what exactly I'm trying after ...
I want to create a .dll using ATL. After I want to create a method inside this, which I can call from C#.
This method should take Filepath(string) as input while invoking from C# and should return some string back to C#.(not pointer)
Please guide me if possible with a proper working code.
Thanking you,
Arun
|
|
|
|
|
No need to call the .copy() or to create a new _bstr_t out of the BSTR u r gettign into the property put.
corrected code below:
<br />
STDMETHODIMP CYourClass::get_Title(BSTR *pVal)<br />
{<br />
*pVal = m_bstrTitle; <br />
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CYourClass::put_Title(BSTR newVal)<br />
{<br />
m_bstrTitle = newVal;<br />
return S_OK;<br />
}
Regarding the method u need to create, the IDL signature will be:
[id(1), helpstring("your atl method signature")] HRESULT YourATLMethod([in] BSTR Filepath, [out,retval] BSTR* ReturnString);
and the C++ implimentation signature will be:
STDMETHODIMP CYourClass::YourATLMethod(BSTR Filepath, BSTR* ReturnString)<br />
{<br />
_bstr_t bstrFilepath = Filepath;<br />
_bstr_t bstrReturnstring = _T("some string here");<br />
*ReturnString = bstrReturnstring ;<br />
return S_OK;<br />
}
cheers ...milton kb
|
|
|
|
|
Hi Milton,
Yes, it solved my problem. Really thank u very much man.
Thanking U,
Arun
|
|
|
|
|
STDMETHODIMP CYourClass::YourATLMethod(BSTR Filepath, BSTR* ReturnString)
{
use the BSTR FilePath to get the BSTR to return, you can also use a LPCOLESTR
CComBSTR TheReturnString = L"the string";
*ReturnString = SysAllocString(TheReturString.m_str); //or any BSTR or LPCOLESTR to be allocated by the system using the pointer given by the com client
return S_OK;
}
|
|
|
|
|
Hi everybody,
I have a WTL wizard generated MDI application with a form (Dialog based) view. The form has several controls on it. When it looses the focus (for example because of showing a message box) and then gets the focus again, the last active control wont have keyboard focus (In fact the first control gets the keyboard focus instead).
I want to know why it happens and what the solution is?
Thanks in advance
|
|
|
|
|
Hi,
Does anyone know how to declare an enum type in Vs7 so that it is exposed on the COM interface in an ATL project?
It is easy to do this in VS6, you just edit the IDL file, compile and it's done. In VS7 however, the IDL file is
compiled from the ATL interface header file. I've tried declaring the enum in this header file, but when it's
compiled only the interface code appears in the generated IDL file.
Any help greatly appreciated
Ian McLauchlan
|
|
|
|
|
Create an idl file say commonidlItems.idl with contetc as below:
import "oaidl.idl";<br />
import "ocidl.idl";<br />
<br />
typedef [uuid(565699C1-CD68-4d49-A2B0-44D424682489), version(1.0)]<br />
enum {<br />
item1 =0,<br />
item2 = 1,<br />
item3 = 2,<br />
} MyEnum;
include the idl file in the ids if u need to use the enum as paramtyer to com methods. This can be done as below
import "commonidlItems.idl";
To use the enums in the CoClass implimentations, you have to generate the header file.
Type midl commonidlItems.idl in the VS command promt to generate the corresponding header file.
add the generated headerfile to the project.
you are all set then.
cheers...milton Kb
|
|
|
|
|
I need simple ATL activex tutorial
|
|
|
|
|
|
Hello,
I wrote a com object in C++.ATL.
I did a small header file for general definitions.
When I include that file in other classes I got error such as missing ; etc
example of the header file:
#ifndef __LIC_T_H
#define __LIC_T_H
#include
using namespace std;
#define FILE_BUFFER_SIZE 100
#define ENCRYPT_ELEMENT_NUM 4
struct Lic_t
{
};
#endif
thanks
|
|
|
|
|
include stdafx.h as the first #include statement int he header file or disable using porecompiled header file in the project settings.
cheers...milton kb.
|
|
|
|
|
Hi,
I am posting here cos none answers in ATL group.
I have a dialog box in my ATL exe, I want to use/link a C Library. AFter clicking OK button on the dialog on of C functions should execute .
How to do this. linking the Clibrary and opening the C function.
marcoslav
-- modified at 3:10 Friday 16th June, 2006
|
|
|
|
|
extern "C" should work, I believe
|
|
|
|
|
Hi,
I have some problem with this fn.
IMultiMediastream::GetDuration(..);
but this fn. worked well
IMultiMediastream::SetState(STREAMSTATE_RUN);
how to solve this problem
|
|
|
|
|
I need to marshall an interface to a apartment threaded component.The component has type library marshalled interface(oleautomation).
I plan to use CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream(IStream) based marshalling ,but it cannot be sent across as void*(not automation-compatible datatype).
Is there some way to marshall this interface without using GIT?
|
|
|
|
|
rana74 wrote: it cannot be sent across as void*(not automation-compatible datatype).
What does this mean?
"across" what?
If you mean across apartment boundaries it doesn't matter whether the interface is automation compatible or not.
If it's an interface method that takes an interface pointer it should be passed as an IDispatch* if the interface is automation compatible which means it should not be cast into a void*.
What are you trying to do/call that requires a void*?
rana74 wrote: Is there some way to marshall this interface without using GIT?
Sure, CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream is the way to do it.
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Hi all,
I have customized controls for button(ownerdrawn), listbox, listctrls, etc. They were intended for MFC applications. They are working fine in MFC dialogs in ATL.
But when they put directly in ATL composite control, there are many painting problems. Button is not getting painted (a gray rectangle can be seen). List box and list control are painted as default.
What could be wrong? Or is there any limitation between ATL and MFC connectivity?
- NS -
|
|
|
|