hi i am basically a c/c++ programer. i have to start working on windows programing and need to take a decision. for windows programing i can use win32 SDK or MFC also as basically MFC are the wrapper classes over win32 APIs..fine. recently, i come to know that i can program windows using c# also, can anybody please suggest me which technology is the best to do windows programing, MFC or C#? whats really the difference between these 2 as related to windows programing?
Comments
:
[blue]C# is based on .NET platform, and it is the future of Windows programming. New Windows 'Vista' (or Longhorn - old name) will be using C# and VB .NET mainly for applications.
Win32 is a little faster and has more control over the system. When I was coding some GUI - I did not find (in C#) a few functions I needed. But, C# and Win32 can be mixed (you can use Win32 API inside C# code), so that was not a huge problem, just an annoyance.
C# is portable (or so Microsoft boasts), so the code compiled on Intel, should run on Mac and vice versa.
Also, if you go with C# - you need to get up to speed on .NET platform - just read MSDN - it has a whole description of all classes and namespaces in .NET and what they needed for.
Now, MFC: one thing - it is old (very old). It is still supported. I just wrote MFC application using VS .NET 2003.
When you write Windows application (not Web app.) in C# - you need to use new approach to programming. Example: I needed to move a window. The .NET class Form provides the window functionality, so I was looking for a function to move a window (MoveWindow in Win32). Did not find it. The way to move a Form is to set Left, Top and Size properties:
[code]
Form wnd;
wnd.Left = 64;
wnd.Top = 64;
wnd.Size = new Size (400, 500);
//wnd.Width = 400;
//wnd.Height = 500;
// That ^ is better (not creating a new object)
[/code]
That code will move a window on screen. Weird!..[/blue]
: :
: [blue]C# is based on .NET platform, and it is the future of Windows programming. New Windows 'Vista' (or Longhorn - old name) will be using C# and VB .NET mainly for applications.
:
: Win32 is a little faster and has more control over the system. When I was coding some GUI - I did not find (in C#) a few functions I needed. But, C# and Win32 can be mixed (you can use Win32 API inside C# code), so that was not a huge problem, just an annoyance.
:
: C# is portable (or so Microsoft boasts), so the code compiled on Intel, should run on Mac and vice versa.
:
: Also, if you go with C# - you need to get up to speed on .NET platform - just read MSDN - it has a whole description of all classes and namespaces in .NET and what they needed for.
:
: Now, MFC: one thing - it is old (very old). It is still supported. I just wrote MFC application using VS .NET 2003.
:
: When you write Windows application (not Web app.) in C# - you need to use new approach to programming. Example: I needed to move a window. The .NET class Form provides the window functionality, so I was looking for a function to move a window (MoveWindow in Win32). Did not find it. The way to move a Form is to set Left, Top and Size properties:
:
: [code]
: Form wnd;
:
: wnd.Left = 64;
: wnd.Top = 64;
: wnd.Size = new Size (400, 500);
:
: //wnd.Width = 400;
: //wnd.Height = 500;
: // That ^ is better (not creating a new object)
: [/code]
:
: That code will move a window on screen. Weird!..[/blue]
thanks AsmGuru62, u gave me the best possible and to the point reply, thank you very much for ur advice. my employer has choice for me to go either for vc++ or c#. as advised by u, certainly i m going to choose c#, one for its the latest n secondly as u told i still can use win32 APIs through it...thanks a bunch n gud luck!!
Also, lastly, could u please suggest me the best book or resources to learn C# which could give me indepth knowledge, at beginers n advanced level, about C#?
http://msdn.microsoft.com/vcsharp/downloads/samples/
or here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpqstart/html/_NET_Framework_QuickStart_Samples.asp
No idea about the actual book - I learned from samples.
Also, here are .NET classes:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp
If you can learn all classes from above - you will be the King!
You will need a few years for that... :-)
[/blue]
I program a little of this and a little of that. Well, mostly Win32 but I'm at the very editin a C# console program of mine.
I take it you have experience with C++ or at least C as you are about to start on windows programming. In that case I would choose C#. Programming win32 is like writing code in a whole new language if you have no former experience with it.
bool is no longer bool, it's BOOL... char* is LPSTR, const char* is LPCSTR, TCHAR is either char or wchar_t and so on. Windows will be represented by a HWND struct. Obviously you can get used to it, I'm just saying it may seem confusing in the beginning.
But as I also said, I program both C w/ win32 and C#, so that's definitely also a possibility. Here's one of the reasons why C# is so damn good at windows programming and why the person who stated that C# was the future in programming windows wasn't wrong:
Say I have this window and I want to change it's caption (the text in the bar above the window; if you have any experience with HTML, it's the text that you between the .)
In C w/ win32 you would most likely do this:SetWindowText(myWindow, TEXT("My new caption"));
In C# the same is reduced to this:
myWindow.Text = "My new caption";
But in reality this is your decision, and you should choose whatever you like most. Maybe take at look at both C# and win32, but stay away from MFC as far as I'm concerned.
I'd recommend C++ or if you're not familiar with OO programming, C. The choice is yours though.
-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]