Jump to content

.NET Framework Tutorials?


Jon
 Share

Recommended Posts

  • Administrators

I fancy doing some GUI apps with minimal hassle (compared to native c++ like the AutoIt tools). I know that VC 2008 has just had a feature pack released that brings MFC up to date (ribbons etc) but from the articles/videos i've watched it seems to be more to support existing MFC users rather than to encourage new MFC dev. So .NET it is.

Looking for some basic c++ to c# type stuff and maybe some simple GUI tutorials for C# and .NET.

Link to comment
Share on other sites

  • Administrators

I just watched a vid interview with someone at MS about the MFC updates. It does look pretty cool. I just don't know what to invest time in. I naturally gravitate to the less runtime heavy stuff. But on the other hand doing stuff natively (like trying to draw an icon on a menu) makes me want to kill myself.

Link to comment
Share on other sites

If you've got Visual Studio with C# installed, the GUI stuff is pretty much drag and drop. Then just select a control, go to the properties pane and find the lightning bolt to access events. Double click the event to have it automatically inserted into the code.

Or you can do it manually by inheriting from System.Windows.Forms.Form and add controls to this.Controls. To add event handlers you use varname.event += new EventHandler(function). Visual Studio will walk you through that too with intellisense popups.

Link to comment
Share on other sites

  • Administrators

Have you seen the new MFC stuff? You can see the sample apps when you install the VC2008 Feature Pack and they are in the Sample folder in a zip file:

http://blogs.msdn.com/vcblog/archive/2008/...ng-samples.aspx

They look pro and I am really tempted, but I think it might be more useful to learn C# and WinForms at this point in case MFC is left to rot again...

Link to comment
Share on other sites

I haven't done anything with MFC but WinForms seems appropriate. It's quite simple.

And theres also the WPF that might be useful in really big projects. My stuff is small and I'm a newbie in .NET so WinForms is the thing.

Link to comment
Share on other sites

What's so hard about C#?

Well the language itself isn't so bad but the Framework. There are so many ways you can do stuff with it.

Well explaining thing is that I'd choose OS X over some Linux OS because of the simplicity. Less options feels safe and it's easy to understand.

I'm just spoiled in the AutoIt world. It took couple days to understand the whole thing.

Link to comment
Share on other sites

  • Administrators

What's so hard about C#?

The fact that it uses c++ keywords, ideas and symbols to mean completely different things. It will also take some getting used to the whole pointers/references/objects/arrays/strings/boxing/unboxing things. All the websites I found on it are really bad at explaining. I might have to do the unthinkable and read a book. *gasp*

I'm slowly going through the MSDN C# reference, slowly as each topic raises more questions about keywords which then branch off into things that I don't understand yet :P

Link to comment
Share on other sites

  • Administrators

I recommend this: http://www.amazon.com/2008-NET-Platform-Fo...t/dp/1590598849

It explains the core features but is still thick as a brick.

Got the book - it's pretty good so far. Definately better than trying to makes sense of the crap-tastic articles on the net.

Worse thing so far, Visual Studio 2008 defaults to spaces instead of tabs for c#. O. M. G. I could literally weep :P

Link to comment
Share on other sites

  • 2 weeks later...

Hmm, I guess C# is kind of neat in some ways. But it's pretty intimidating trying to figure out the magic to how it works when you're trying to modify an existing application (small, fortunately). I did manage to figure out how to do what I wanted, though.

Just for curiosity's sake, how would somebody who actually knows C# handle the following situation:

I had an application that allowed you to choose an item from a list and it would then act on that item. I wanted to add command line support so that it could be automated. Specifying something on the command line causes the program to act on that item and then close. Problem is, how do you keep the form from appearing *and* how do you actually get the program to close when it's done? What I had to do was set the form to minimize and to have no taskbar icon which seemed to make it hidden. Then I create a thread and set it to start when the form was shown (but not really user visible). When my thread is done it closes the form and the program terminates. I had to it this way because you apparently can't close a form in it's constructor and all other methods I tried lead to a crash.

So, did I go about this something close to the right way? What I've done works fine, no crashes, no visible form, I get the behavior I want and the process doesn't linger. But is it the most correct way or is it a kludge?

Link to comment
Share on other sites

Forms have a property called Visible. If you set that to false, it's hidden.

A better way to do it is to take the necessary functions out and copy them to another location then modify the Main function and don't call "Application.Run". Application.Run will use the form object you pass it and wait until it is closed. If you don't use the form at all, you don't have to close it.

Link to comment
Share on other sites

Setting the Visible property seemed to do nothing since I was setting it before the form was shown (during the constructor which is called before the form is shown). Changing the code like you said also occurred to me but seemed like more work.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...