|
I am trying to load an dll written in vb in my MFC dialog program. Does anyone know how to do this? Thanks.
|
|
|
|
|
Is it a COM dll ? Then the fact that it's VB is irrelevent. Can you #import a VB COM dll ? I don't know, but if you can, that's the nicest way to use a COM dll.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
It is infact an ACTIVEX dll. I've follow the steps from the this article, but I still get errors when compiling. (http://www.codeproject.com/dll/vbactivexwithvc.asp[^]). The generated .tlh file contains a method from the dll file which generates the error.
HRESULT OUT (
unsigned char OUTNUM,
VARIANT_BOOL VALUE );
error: C2027: use of undefined type 'HRESULT'
Thanks for following up.
|
|
|
|
|
ActiveX is COM, that's why it returns HRESULTs. What sort of project are you creating, that it doesn't contain any COM stuff ? afxwin.h defines HRESULT, it's just a long.
This article is showing you how to do things the hard way, unless it's impossible to #import an ActiveX dll and then instantiate it the same way you do other COM dlls.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You can definitely #import an ActiveX component - I've had to do that many times including a current project that uses the MS Script ActiveX control.
Tom Archer - Visual C++ MVP
Archer Consulting Group.com
|
|
|
|
|
Yes, but can you use code like this:
HRESULT hr = File.CreateInstance(__uuidof(Avi::AVIFileInProc));
or do you need to use the CreateObject type code the article was providing ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Bascially, I just want to import this dll in a vc++ class and use its functions.
Since this dll is given by another person, I cannot change its format nor obtain the orginal source code.
http://www.geocities.com/red90000/TECHNO.zip[^]
|
|
|
|
|
That doesn't matter, I'm saying that if it's a COM dll, I don't see why you need the messy code that article gave you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello, is there a way to play multiple sounds (.wav files) using managed C++ in .NET for my application? I am a newbie so I need details.
Mike - I love to program!
|
|
|
|
|
DirectX is what you need. You need to download and install the SDK ( which means the runtime is required for your app ). There is sample code with the SDK.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the reply, and this may sound stupid, but I dont know what SDK means, or how to use that with Managed C++ .NET. Would a tutorial be provided?
|
|
|
|
|
SDK stands for software development kit. Basically, it's a load of files that you need to use a library that didn't come with your compiler. Yes, if you google DirectX and go to the Microsoft site for downloading, the installer will give you all you need, docs included.
BTW, if you're starting out, why did you choose managed C++ ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the help, and to answer your question, I was provided with Visual Studio .NET, and I wanted to make a forms application. Since I prefer C++ and I heard MFC was hard to understand, so I went the Managed C++ for my forms app.
Mike - I love to program!
|
|
|
|
|
allenmpcx wrote:
I was provided with Visual Studio .NET, and I wanted to make a forms application. Since I prefer C++ and I heard MFC was hard to understand, so I went the Managed C++ for my forms app.
Honestly, you're headed into hell. I love doing winforms in C#, much easier than MFC in C++, but MFC is not really hard, it's just that C# is easy. And doing winforms in MC++ is my personal vision of hell. But if you have a deep understanding of C++ already, and you don't know MFC, it may be a toss of the dice. It's certainly, definately, not going to be easier than using MFC though, and you end up with an app that requires the .NET framework. Why have that if you don't need to ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In all honesty, I have only been programming for about two years, and most of it has been basic console programs with C++. I was going to be an architect. This is all very new to me, and I have tried other languages, but it doesn't mean I'm not open to others. I understand .NET MC++ easier than the others I have tried. I've heard C# is easier and it looks exactly like C++ to me. Thanks for the information though, maybe I'll investigate MFC.
Mike - I love to program!
|
|
|
|
|
allenmpcx wrote:
I understand .NET MC++ easier than the others I have tried. I've heard C# is easier and it looks exactly like C++ to me. Thanks for the information though, maybe I'll investigate MFC.
I don't know what you've tried, but MFC apps are pretty simple, if you know a bit of C++. The framework is not perfect, but it's a huge improvement on Win32. C# looks a lot like C++, so it's easy to move, and it's definately a much easier way to get to WinForms than MC++ is.
I'd investigate C# and MFC as good alternatives. DirectX is available in both, but it's a ton easier in C#, because C# handles all the COM pointer stuff for you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Now I'm extremely intrigued. Most of my application was written in MC++ and if I were to transfer it over to C#, would .NET still create the .exe file, and would I get that Resource Editor GUI that is provided? If so, I'd switch my application to C# right now.
Mike - I love to program!
|
|
|
|
|
allenmpcx wrote:
Most of my application was written in MC++ and if I were to transfer it over to C#,
There's no automatic conversion, but you could certainly put your existing non GUI code in a dll and call it from C#.
allenmpcx wrote:
would I get that Resource Editor GUI that is provided?
I believe the resource editor in C# is better than the C++ one, unless MC++ gives you the same one.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Not to prolong this, but how would I put all my code inside of a .dll and call it from C#? If its too complicated, or takes too long, I might just re-write everything to make it more efficient and learn C#. As long as I can have the .exe and the Resource Editor, I'll be fine. Thanks for the information, I love programming epiphanies.
Mike - I love to program!
|
|
|
|
|
Well, you'd basically create a managed C++ dll and move the code into it. Your current project would be set up to create an exe. If the code can be easily ported to c#, I'd do that instead, the cross language thing could be a pain later.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How would I create a C# Forms application using Microsoft Visual Studio .NET?
Mike - I love to program!
|
|
|
|
|
new/project/c#/windows application. Something like that.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
One last question, then I'm all done, and I greatly appreciate the information:
Would you happen to know how to add a double buffer to a Panel? In C++ I did this:
Panel->SetStyle(ControlStyles::UserPaint, true);
Panel->SetStyle(ControlStyles::AllPaintingInWmPaint, true);
Panel->SetStyle(ControlStyles::DoubleBuffer, true);
However I got errors about accessing SetStyles when it is of type Panel. However, I paint everything on the panel. Is there a way to add a double buffer?
Mike - I love to program!
|
|
|
|
|
I use those same calls to make my app double buffer. I wonder why you can't do it to a control.
I draw all my images myself, and if you do that, you can certainly set double buffering up like that in your main window.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
A piece of advice - the MVP next to Christian's name means "Microsoft Valued Partner" and there are about 70 for C++ on the planet so you have one of the top guys around helping you out.
I would suggest MFC too, the DirectX SDK comes with lots of examples including ones on playing sound.
Basically you put individual sounds into secondary buffers and they are combined into the output buffer which goes to the output device.
For samples under 1MB you can just read them into the secondary buffers, above that it is reccomended you use streaming into the secondary buffers.
I hope this helps.
Elaine
The tigress is here
|
|
|
|