|
No, use different names. Technically it's possible, but it's a nightmare. Using different names is easier.
From an "official" point of view, the names of the methods are irrelevant, unless it's IDispatch based, but it's sooo much easier with different names;
addMyObject(BSTR name);
addMyObjectWithAddress(BSTR name, BSTR address);
Remember, the IDL will produce a header file; it could be used in a C++ app, which supports overloading, or in a C app, which doesn't...
Steve S
|
|
|
|
|
Thank you
|
|
|
|
|
I want to paste in my app img. It pastes only from MS Word and IE.Can anyone help me? My app is a rtf app based on dialog box.
Tanks a lot.
|
|
|
|
|
Anyone who use VB will know it's esay to use ListView and ImageList in VB, however i want to use it in VC. I found that i cannot create ListImages object which is used by ImageList, i use the following codes:
I use import directive to import the com class
IImageListPtr imgs;
imgs.CreateInstance(__uuidof(ImageList));
IImagesPtr img;
img.CreateInstance(__uuidof(ListImages));
Can any one tell me what the problem is?
Thanks a lot!
I love C++
|
|
|
|
|
Hi all
I have a trouble in My ActiveX control
I have written a method that has a parameter as VARIANT pointer (VARIANT FAR* lpVarFileInfo)
in my application that use this ActiveX, i passs a struct : FILE_INFO (it's a struct), and in my ActiveX control i want to get all parameter of this struct, but it alway is wrong.
here my code
IN APPLICATION
FILE_INFO FileInfo;
FileInfo.FileName = _T("D:\\GUI");
m_EditorLoader.SetInfo((VARIANT*)&FileInfo);
// m_EditorLoader is an instance of ActiveX control
IN ACTIVEX CONTROL
void CEditorCtrl::SetInfo(VARIANT FAR* lpVarFileInfo)
{
FILE_INFO FileInfo;
FileInfo = *(FILE_INFO*)(lpVarFileInfo);
AfxMessageBox(FileInfo.FileName);
// Value is wrong
}
|
|
|
|
|
A variant per se cannot contain an arbitrary user-defined type. However, it can be a SAFEARRAY of VT_RECORD, providing the record type is assigned a GUID, and is defined somewhere in a type library.
You don't show the rest of your FILE_INFO structure, but if you only want a name, you could pass a BSTR, and if you must have other members, could you not pass OLE Automation compatible types as multiple parameters, rather than as a structure, to keep things 'simpler'...?
Steve S
|
|
|
|
|
ok, FILE_INFO struct is
typedef struct tagFILE_INFO
{
CString FileName;
CString Location;
CString LocationTemp;
}
FILE_INFO;
Because my ActiveX control communicate with an application. I need passing a lot of pararameters as struct.
could you give me example code.
regards
|
|
|
|
|
If you want your active X control to be useful to non-MFC programmers, then don't use CStrings!
In your IDL you can define your structure as you might in C++ (but with no member functions). Your types should be simple oleautomation compatible ones, so CStrings are out, because they can't be marshalled by OLEAUT32.
Steve S
|
|
|
|
|
ok, i have change CString to BSTR, but how can add a method in my ActiveX has parameters as FILE_INFO (example)
define FILE_INFO struct in odl file
typedef struct tagFILE_INFO
{
BSTR szFileName;
BSTR szLocation;
BSTR szLocationTemp;
}
FILE_INFO;
because my component is an ActiveX control so, in my odl file
[id(7)] void SetInfo(FILE_INFO FileInfo);
it will appear Error when you launch to class wizard (passer error). Because in ActiveX control,when you add one method. The parameter type alway has some
PREDEFINE TYPE (short, long ,CURRENTCY... VARIANT....
So how can we define a new type(UDT) for parameter in method.
Regards
TrungHuynh
|
|
|
|
|
Firstly, you should give MIDL some hint about your parameter. Is it being passed into the function ([in] FILE_INFO FileInfo) or being passed back?
([out] FILE_INFO* FileInfo).
Secondly, it's customary for methods to return a status indication (or HRESULT) so that you can easily determine that an error has occurred.
To use a UDT, assign a GUID to the structure definition. Something like this will help.
#ifdef __midl
[
uuid(FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF),
version(1.0),
helpstring("My FILEINFO structure")
]
#else
struct __declspec(uuid("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF")) FILE_INFO;
typedef
#endif
struct FILE_INFO
{
BSTR szFileName;
BSTR szLocation;
BSTR szLocationTemp;
} FILE_INFO;
except you'd replace the dummy guid FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF with your own.
You should then have
[id(7)] HRESULT SetInfo([in] struct FILE_INFO* pFileInfo);
Note that it's a pointer you pass in now, not a structure. UDTs must be passed by reference, not by value.
I suggest you read the MSDN articles located by searching for
UDT IDL parameter
and if you're going to do a lot of this, read the Martin Gudgin book, Essential IDL.
Steve S
|
|
|
|
|
In odl file is ok
but in .h file and .cpp, how can i define a type of FILE_INFO
code:
In .h file
afx_msg void SetSCOFileInfo(FILE_INFO* pFileInfo);
In .cpp file
BEGIN_DISPATCH_MAP(CEditorLoaderCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CEditorLoaderCtrl)
DISP_FUNCTION(CEditorLoaderCtrl, "SetSCOFileInfo", SetSCOFileInfo, VT_EMPTY,"what does type we deine")
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
When i launch to ClassWizard, it will appears error
Parsing error: "FILE_INFO*" is not a valid OLE parameter type
Input line: afx_msg void SetSCOFileInfo(FILE_INFO* pFileInfo)
|
|
|
|
|
in .odl file is ok
But how can define .h and .cpp file of ActiveX control
In .h file
afx_msg void SetInfo(FILE_INFO* lpFileInfo);
In .cpp file
BEGIN_DISPATCH_MAP(CEditorLoaderCtrl, COleControl)
DISP_FUNCTION(CEditorLoaderCtrl, "SetInfo", SetInfo, VT_EMPTY, "what kind of type we define(VTS_BSTR;VTS_VARIANT...)")
END_DISPATCH_MAP()
if we ignore define in cpp file, when we launch to ClassWizard, it will appears an error
Parsing error:"FILE_INFO*" is not a valid OLE type
line:"afx_msg void SetInfo(FILE_INFO* lpFileInfo)"
|
|
|
|
|
And there's your problem. The ClassWizard will only allow you to use OLE Automation compatible types. You can "cheat", because the control is in-process, so there isn't any real marshalling being done, by defining the parameter as a VARIANT, then using the fact that a variant will hold a void*, which you'll need to cast back in your control to be a FILE_INFO*.
But you didn't hear it from me....
This definitely should NOT be considered as an option if there is ANY chance that it will be used out of process, where it won't work.
Steve S
|
|
|
|
|
I need to "talk to" an IE session from another application. I presume this is done either over a COM inteface to IE, or by making the "other application" an ActiveX control and installing it as an IE "plug-in". You can probably tell that I'm not quite sure what I'm talking about here, as I am not very familiar with ActiveX or COM. (However I am an experienced C++, VC and MFC programmer). Can anyone give me a few pointers, and maybe recommend some books, articles or sites. Thanks.
Dave
|
|
|
|
|
If you make code usng ATL, HTML control must be answer.
Core : Your code implements IObjectWithSite then IE will use SetSite() method to pass to your code the IUnknown pointer to its site object. Then you can query IServiceProvider and you get IWebBrowser2 pointer. That's it..!
|
|
|
|
|
helo friends,
how can i embed an activex control in aoutlook mail message
|
|
|
|
|
Just create a mail message in html, if you want to send the control with the message, you need to create a multipart message, where the html message is one part and the control itself the second.
You can also reference other servers from your html code, thus the control can be placed on a server the client has access to.
Please note that some, if not most, users have disabled running activex controls inside Outlook.
|
|
|
|
|
hello firends,
i am developing an activex control(MFC) that we are going to embed in webpage. But my question is Is it important to have a every clientmachine that downloads that webpage should have MFC dlls installed in them?????
please help me.
shankeran.com
|
|
|
|
|
Well the simple answer is yes. I have recently developed an activex control and found that some clients who were lacking mfc42(your letter here).dll and one or two other dependencies did not run.
The solution:
Use a cab utlility (cabarc.exe from Microsoft) to create a cab file of your activex control plus a .inf file. The inf file describes the contents of the cab file and any dependencies it requires. The line to add to the inf file for installing and running the latest mfc dlls is
[mfc42installer]
file-win32-x86=http://activex.microsoft.com/controls/vc/mfc42.cab
run=%EXTRACT_DIR%\mfc42.exe
There are loads of articles on MS site describing the complete procedure.
hope this helps
Carl
|
|
|
|
|
You can also statically link to MFC to avoid having to redistribute the MFC DLLs. Chances are that you're not using all of the MFC library, and thus you'd shorten download times by linking statically. Dead code is removed during link time. If you distributed the DLLs with the CAB, the user will have to download all the code - even that which is not used.
--
I am looking for last year's snow between your legs.
|
|
|
|
|
Hi all,
Can anybody give me some pointers on how to pass the following
complex type through a COM interface ?
typedef struct ComplexType
{
Type type;
union
{
int intVal;
BSTR strVal;
BYTE* pbyteVal;
AnotherComplexType* pcomplexVal;
};
};
The real type contains different fields but you should get the
idea: it basically is just like a VARIANT only with more levels
of indirection.
I need to pass these structures between my COM component and
non-COM legacy code. Unfortunately, there is a threading issue
that causes a proxy and stub to be created even for in-process
deployment of my component, so simply passing a pointer doesn't
work.
Should I resort to custom marshalling ?
Kind regards,
Alwin!
|
|
|
|
|
Define your type(s) in IDL and it will create marshalling code for it.
--
He just smiled and gave me a vegemite sandwich.
|
|
|
|
|
I've spent a week on making COM+ ManagementTool displaying COM+ Catalog Infomation using COMAdminCatalogCollection.
Currently,I'm using VB.NET to do this job.
Most of infomation I'd like to
find was in COMAdminCatalogCollection.
But I couldn't find a way of retrieving imfomation of state of Object activated. I'd like to know how many Object is Activated as if I see the COM+ Management Tool provided in Windows 2003.
Please,Help me.
Any idea will be helpful.
|
|
|
|
|
I used the Object Viewer tool to generate the IDL file for Shocwave Flash control, it appears to be ok. However, when I use MIDL to generate the header file, the methods in the IShockwaveFlashEvents interface are not generated, even if they are present in the IDL file itself.
Is this standard behaviour or am I just stuck with an amateur mistake?
I can generate my sink class based on the information found in the IDL, but I'd rather use MIDL for the task as I'll be interfacing with other controls in the future and want to learn the ins and outs of Visual Studio.NET.
The event interface is in fact based on IDispatch (i.e. dispinterface), is this the reason the methods are hidden from the generated header file? So, even if the methods are present in the IDL along with their disp ids, they won't be automatically included, but force the developer to query for the methods to find the disp ids.
Then again, should my event sink be based on IDispatch as well or should I manually copy the declarations to form the vtable as defined in the IDL?
Please take the time and guide a COM/ATL newbie to a solution.
Thanks!
|
|
|
|
|
Hi,
I am working on this ATL dll, which has one object that implements
connection points. I added some methods in the event interface that take
VARIANT as parameters, so that I may receive the variants in events when I
use the same from VB.
In IDL file it is like
////////////////////////////////////////////////////
[id(3), helpstring("method SampleRecordPkt")] HRESULT SampleRecordPkt([in]
VARIANT vBytes);
////////////////////////////////////////////////////
Now, I am trying to fire this from my code as follows - (All the hard coded
stuff I did for debug only.)
////////////////////////////////////////////////////
BYTE bytes[] = {5, 123, 9, 0, 5, 0, 0, 191, 157};
COleSafeArray saBytes1;
saBytes1.CreateOneDim(VT_UI1,sizeof(bytes));
for(long i = 0; i < sizeof(bytes);i++)
{
BYTE val = bytes[i];
saBytes1.PutElement(&i,&val);
}
file://fire off the appropriate event
VARIANT var = saBytes1.Detach();
Fire_SampleRecordPkt(var);
/////////////////////////////////////////////////////
However, inside "Fire_SampleRecordPkt(var)", the application crashes. The
crash occurs at the line given below (wizard generated code, when "implement
connection point" is chosen.)
////////////////////////////////////////////////////
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&disp, &varResult, NULL, NULL);
////////////////////////////////////////////////////
Can some body help me identify where I am wrong? Any help is appreciated.
Thank you
aby
|
|
|
|
|