|
Can a C++ DLL developed with Microsoft Visual Studio .NET 2003 be used by Delphi, Borland C++ and other object-oriented languages? I am hoping to write a C++ DLL with ADO and CAsynSocket capability wrapped in some classes. Would there be any problem with Delphi, VB.NET, Borland C++ etc., e.g. name mangling due to different compiler vendors, if I export the classes in the C++ DLL? Can the Delphi, VB.NET, Borland C++ access and those exported classes? Thanks.
|
|
|
|
|
If you want cross platform/language, without giving into .NET, I advise you to go the COM route, as that's the only common denominator between the languages you mention (AFAIK).
--
Pictures[^] from my Japan trip.
|
|
|
|
|
So meaning that in this case I should wrap the C++ classes in a COM instead of a C++ DLL? Can Delphi, Borland C++ and other OOP languages use COM? What about a C DLL developed with Microsoft Visual Studio .NET? Can Delphi, Borland C++, VB .NET use the C DLL without any issue? Thank you very much.
|
|
|
|
|
Basically all languages and environments implemented for the Windows environmnt has support for COM, including C.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
If you wrap your C++ classes in a 'C'-style interface, then Delphi, etc. would be able to use your DLL. Note that you lose the notion of 'classes' then. Here's an example:
class MyClass {
public:
MyClass(int arg1,double arg2);
~MyClass();
void Function1(int arg3);
};
extern "C" {
typedef void *MyClass;
MyClass *MyClass_constructor(int arg1,double arg2);
void MyClass_destructor(MyClass *instance);
void MyClass_Function1(MyClass *instance,int arg3);
}; The DLL interface defines a 'constructor' function that will return a pointer to a MyClass object. The remaining functions take one of those pointers as their first argument. Note that you will need to be careful to explicitly the destructor function, since the user of the DLL is not C++, and doesn't know to call destructors when an object goes out of scope or is deleted.
Software Zen: delete this;
|
|
|
|
|
That's doable too. The good thing about COM though, is that you get marshalling for free, should you want to do outproc stuff.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Hi Jorgen, can I wrap the ADO (a COM) and MFC CAsyncSocket class capability into a COM? Is it workable if I develop the COM in Visual C++ and use the COM in Delphi, Borland C++ and other non-OOP languages? Any special codes that I need to add into the COM source so that it can cater for a specific language, eg a code section for Delphi and another code section for Borland C++? I would greatly appreciate if you can provide me some sample codes for developing COM in Visual C++ or any reference that I can refer to. Thank you very much.
|
|
|
|
|
I must admit that I have not used Delphi myself, but I do know that it supports ActiveX controls. In order to do that, there must be support for COM1. Borland C++ does have support for COM, that I know for sure.
COM is essentially a set of specifications. COM is built upon the notion that all components are communicated with through an interface. How the interface is represented in memory, is dictated by COM. Hence you will not need to provide different interfaces or implementations for each client language (Delphi, Borland C++, .NET-languages, etc). Write once in Visual C++ (or even Borland C++, VB6, .NET-languages, you name it), and use it in all COM capable client languages. Despite what Microsoft says, there were solutions for cross language development prior to .NET.
I should warn you though that COM has a rather steep learning curve. But in all honesty, books like Essential COM[^], and ATL Internals[^] makes that learning curve much flatter. ATL by the way, is a C++ class library, which takes care of much of the "boiler plate coding" needed for COM. It allows you to use wizards, as well as hand wire COM stuff quite easily. Should you chose the COM route, please use ATL. It'll spare your fingers from all that typing.
1 Well, to be honest, there doesn't have to be support for COM. It could be that all COM/ActiveX details are embedded into the language itself, shielding the programmer from COM. I doubt that though, because that would be utterly stupid, should the COM and ActiveX specifications change.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Agreed. I brought up my suggestion in case FFKONG needed something quick and simple (i.e. didn't have time to learn COM).
Software Zen: delete this;
|
|
|
|
|
Hi all,
this is my first time using port communcation, so I am a bit confused. I have read the msdn and several articles, but I still don't understand exactly how to do what I want.
Basically, I have a peripheral on my machine that I want to send messages to and receive messages from. I downloaded the CSerialCom[^] library from codeproject, so reading and writing is not a problem.
The problem is that the system requires programatic-management of control flow mechanish (DTR/DSR), which means that I must assert the DTR to get the peripheral's attention, and then I must wait for the DSR assertion before I can transmit data.
Can someone provide a demo that shows how to communicate with a peripheral with these contraints?
Thanks,
-----------------
Genaro
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/monitoring_communications_events.asp
and
http://www.codeproject.com/system/serial_com.asp
|
|
|
|
|
Thank you for your response. However, I still don't understand how to set the DTR high before monitoring for the DSR flag. Could you please explain that?
Thank you,
-----------------
Genaro
|
|
|
|
|
I think that you have null modem connection. DTR -> DSR are continual signal. When you set DTR signal on high that means you are redy to send data but when your DSR become high that mean you can receive data from device. When you start to configure port set DTR signal with DTR_CONTROL_DISABLE and fDsrSensitivity in DCB with TRUE to avoid flow, but watch all changing are valid after calling function SetCommState. Now you can control DTR with function EscapeCommFunction and monitoring DSR. My recommmendation is whenever use EscapeCommFunction(hFile, CLRDTR | CLRRTS ) or EscapeCommFunction(hFile, SETDTR | SETRTS).
|
|
|
|
|
Hi everyone
I'm in the first phase of a project where I just plan stuff, and it seems I'll be developing a plugin system for my app. I'm working in MFC, I don't really have much experience with dll's, there are still things bugging me (and we all hate bugs ) Now the questions..
a) Is it possible for the main app to load a dialog from dll and display it as a child window of tab control? or..
b) ..would it be better if the dll itself displays a standalone dialog using main app window as it's parent?
Which one of these would be easier to implement? Every dll would be a plugin, and giving the plugins an option to display windows is a nice thing to do.
c) Is there a way for dll plugins to add a menu to the main app window, and get notifications when the user clicks on them?
Any kind of help is appreciated, links to articles etc.. Also, if you have a good tip on plugin system development, please share it
thx
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
In the end, war is not about who's right, it's about who's left.
|
|
|
|
|
|
That's a great article indeed, but unfortunately I can't use much of the code, my app will be dialog based, and I have the basic idea of plugin system. Has some good tricks in it though, might use some of it.
Also, using MESSAGE_MAPs is a bit too much for my app, I was thinking more like please-notify-me-of-an-even-using-my-exported-function kind of plugin.
My only trouble is displaying a window and/or a menu from dll, not sure if this could work properly..
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
In the end, war is not about who's right, it's about who's left.
|
|
|
|
|
I don't know why I'm getting this error. I'm trying to make a MDI edit type application and implement it with plugins based off the code i found while looking through MSDN.
Here's the code for the First Part:
void CChildView::OnPluginCmd(UINT id)
{
CEdit& edit = GetEditCtrl();
int begin,end;
edit.GetSel(begin,end);
if (end>begin) {
Object* obj = theApp.m_plugins.GetPlugin(id - IDC_PLUGIN_BASE);
ASSERT(obj);
ITextPlugin* plugin = dynamic_cast<ITextPlugin*>(obj);
if (plugin) {
CString text;
edit.GetWindowText(text);
text = text.Mid(begin, end-begin);
text = plugin->Transform(text);
edit.ReplaceSel(text);
edit.SetSel(begin,end);
}
}
}
------------------------------------------
Here's the code for the second error:
void CChildView::OnPluginCmdUI(CCmdUI* pCmdUI)
{
CEdit& edit = GetEditCtrl();
int begin,end;
edit.GetSel(begin,end);
pCmdUI->Enable(begin!=end);
}
|
|
|
|
|
CChildView must be derived from CEditView for this to work.
Software Zen: delete this;
|
|
|
|
|
how do you register small and regular icons for a program so that when you look at the program in windows explorer, you see your own icon instead of the default (IDI_APPLICATION) icon
PPLSHERO54 give his thanks
|
|
|
|
|
By default, Windows Explorer uses the 'first' icon it finds. First, in this case, means the icon with the lowest-numbered resource identifier.
Software Zen: delete this;
|
|
|
|
|
Im looking for a good example to show me how to use a slider control. Ive some useful things through googling, but wondering if anyone knows of a good tutorial sorta thing. Some the questions im looking to get solved is, i have a vertical slider, and it increases as the thumb goes down, and i want that inveresed. The other is how to limit the interval of the thumb? I have set the range from 0 - 3000 and only want it in multiples of 50. Some others would be how to implement the VM_VSCROLL deal, im not quite sure how to do that. And on and on... Thanks in advance.
-Jader89
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Not so much graphically, but functionality
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Jader89 wrote: Im looking for a good example to show me how to use a slider control.
This would be a good place to start.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I've been there, doesnt help much on what i want to do. Unless im blind and missing a blantantly obvious method, among other things.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
You need to use the TBS_DOWNISLEFT style, although this style may just be ignored by the control.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|