Sign in to follow this  
ShadowP13

[.net] Moving away from VC++ 6 and confused.

Recommended Posts

I've only recently gotten VS.Net and I'm very baffled. Previously I used VC++ 6 for everything. C++ .Net seems to make windows like this: System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA; Application::Run(new Form1()); As apposed to VC++ 6 when I used to use RegisterClassEx and CreateWindow. Should I keep using these functions and just delete the new System::Threading::Thread (so on) function? Is there a way to get a HWND from the System::Threading... window? I need a HWND to create a device in Direct3D. Also, if I go to New Project->C++ Projects->.Net->Empty Project (.Net) and just start programming like I used to in version 6, am I using managed code already, or is there special syntax and conventions I have to use? Sorry to ask just basic questions like this. I wasn't sure if this should go in beginers forum or here.

Share this post


Link to post
Share on other sites
Yeah, I was expecting that actually. Believe it or not, I have read all of the MSDN information I could find that I thought was relavent and I bought and read a book on Visual Studio. I'm trying to stubornly continue using c++ since I'm used to it, and simultaneously use Managed DirectX. Unfortunatly, unless you can recomend a better manual then the one I've been looking through (and am still looking through actually) I'm pretty much stuck :/

Share this post


Link to post
Share on other sites
Crud, just a link to a website that discusses how managed c++ syntax is different from C++ might be helpfull (Especially if I am just being retarded and need to RTFM) . The only things I can find online are about C#. I can't seem to find the relavent FM to read. I try to wait tell the last moment to ask a question on GameDev, as I know how many of you get mad if you think the answer is easy to come by.

Share this post


Link to post
Share on other sites
The syntax is a bit different, but it looks like what you're really running into here is the API difference. In managed C++, you're using the .NET framework for stuff, which is completely different from the Win32 API (though it accomplishes many of the same tasks). You don't HAVE to make your apps in Managed C++, even if you're using Visual Studio.NET... so if you're more comfortable with the Win32 API, you can use it without sticking to the VS6 IDE.

BTW, don't let the APs get you down. We aren't all jerks. [smile]

Share this post


Link to post
Share on other sites
I've also been struggling to convert some of my VB coding to use .NET and finding it to be fairly a undocumented process. You're using Managed C++ so perhaps it's even less documented for you, something I don't envy. All I can say is that if you can afford it to go out and buy one of the big .NET books that discusses the API. I've just started scratching the surface and there's huge aspects that are alien to me, especially being of a Win32 C++ background normally - things just seem more complicated, but I assume that there's some logical order to things. Just keep at it, grab a good book and hit google and MSDN as hard as you can. Luckily MSDN has VB/C#/C++ versions of most of it's examples which can only be a good thing when trying to make sense of things. If you're able to understand the basic concepts then you should be able to read some C# code and port it over to C++/VB with (hopefully) little trouble.

Good luck!

Share this post


Link to post
Share on other sites
Hey, thanks for the information. I kind of like the new namespace system and some of the other things I've been reading about. The main reason I'm trying to use Managed Code is that I have really simple needs for DirectX (I make 2D games) and the Managed DirectX SDK makes the Sprite class look more robust if you use Managed DirectX (The C++ DirectX Sprite doesn't even seem to support stretching the sprite for some reason). If it is true that you need to use Managed Code to use the Draw2D feature I want to figure out how this works :( Most of the example of creating a device in Direct3D involve passing the this pointer (when I try that I get the "error C2673: 'WinMain' : global functions do not have 'this' pointers" error.

Is there a quick answer to this? The Third parameter of the function to create the device wants a "Control *renderWindow". I'm having trouble figuring out what that is. An HWnd I've been assuming but I don't know how to pull an HWnd out of a window created in .Net. This really is turning more into a DirectX question actually. I'm not sure if I'm needing help with DirectX or .Net though :P (This problem really seems to elementry. I've totally already made 4 or 5 directX applications with DirectX8 before. Creating the Device never seemed this hard)

Share this post


Link to post
Share on other sites
Shadow,

for the control, you can just pass in a reference to the window. The Window class in .NET derives from the Control class. Since most UI controls derive from the Control class, you can essentially pass in almost any UI control into the CreateDevice() function. This can be especially cool if you are developing an editor and want a "panel" to show the results from the editor using the actual engine.

Share this post


Link to post
Share on other sites
Ok, thanks everyone. I'm going to spend more time on the tutorial site lonesock recomended and then perhaps just end up getting another book :/ I think I've tried the last Form1::get_Handle type thing that I could think of.

Share this post


Link to post
Share on other sites
I say that .net has helped a ton on programming

the windows api is now object oriented and you can create a new window in one line of code

dim mainForm as new form1

and dll implementation can't get any easyer.

dim d3d9device as new microsoft.Directx.Direct3d.device

just include the dll as a reference and create it pretty much like any other object

I've tried to create an object oriented, multithreaded window that can be created in only one line in c++ but windows forms have taken over.

I really do think that visual basic has bennifited the most from going .NET

No longer is it tied to its unruly slow qbasic roots anymore... everything is just as powerfull as c++ since the .NET compiler would break it down into clr code. it is truly object oriented and I had instantly moved from programming in dos using c++ to the windows enviroment.

don't get me wrong. c++ is fast, powerful, and holy within the programming community, but if your planing to use the .net compiler. c# and even vb.Net are better canidates for game programming. You get the same bang for less buck sorta speak.

still into c++... it's ok. All .NET languages are interchangeable. You might like to still write your windows in a traditional c way (although I don't see the point in obscuring your game code with the windows sdk)and yet, you can access some directx library made in c# or vb.net.

microsoft has made sure everyone is satisfied with the .NET compiler, so I bet that once you know .net like the back of your hand, tranfering your thoughts into applications are near instantanious.

and sneftel it's the vs7IDE, not the vs6IDE

Share this post


Link to post
Share on other sites
Actually, it was QBasic that I learn the vast majority of how to program from. Then Visual Basic, and eventually when I became unsatisfied with it's speed and power (not to mention Microsoft didn't have DirectX supporting VB back then) I moved into C++. Now that Visual Basic is up to snuff, I almost feel like going back to it.

Oh, btw, after about 5 days of trying to figure out how to work with .Net, what has helped me the most is this url

http://www.functionx.com/vcnet/articles/gcclass.htm

I don't mean to keep bumping this thread, but I wanted to make sure that if someone else found this thread doing searches (which is how I find a lot of my solutions) that maybe they can benifet from that URL like I did. I'm now capable of solving my original problem with creating the device, at least concerning the third parameter of that call. (was just a simple OOP problem. I'm still not very good about OOP , never got much further then the struct)

[Edited by - ShadowP13 on September 24, 2004 7:10:48 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this