To make things easier for cosing in Win32 API, MFC is created which wraps Win32 API in classes.

At the beginning i though MFC is there only to aid you making C/C++ GUI Application.

For example, CSocket() wraps the function socket(), printf() gets wrapped in another class, and so on. Why in MFC everything is wrapped into a class even though some parts don't really need to be wrapped, such as socket(), send(), etc.

I think MFC should only wrap GUI API for Windows, since the GUI part requires alot of coding such as keeping a track of messages loop & make sure about the which button is clicked, etc. So in my opinion, winsock API should not be wrapped, e.g. when a user clicks "connect" button, we should use connect() - the main API, not the wrapped one because this wouldn't really effect the user! CSocket() will do exact same thing socket() does. Thus, CSocket() will slower than socket().

Let me explain more, when you want to print a data to static box, you can't use printf(), you need to use a special CStatic class that prints out the text to a static text box. This makes sense, but creating a socket, just happens behind the seen, we do not create a socket and show it on screen! so we do not need a wrapper for it as the wrapper won't do anything new, it just wraps socket() inside CSocket(). Eventually, they both do samething, CSocket() might be slower too.

After all, i think we just need a wrapper that makes objects (Windows Forms) & handle them, such as CStatic. The rest should be coded as it is.

1. Any suggestions? am i right or wrong? why?
2. Can MFC be used with Delphi, C#, etc just like Win API? or Its been made for C++ specifically?

I hope you are getting my point. I apologize for making my explanation long, i'm just trying to reach you what goes in my mind. Please answer me in an easy fashion if you don't mind. I already have enough confusion

1. Obviously, you are wrong. The CSocket object IS NOT equivalent of socket() function call or a "slow variant of a socket handler". Look at the CSocket class description:
http://msdn.microsoft.com/en-us/library/wxzt95kb(VS.80).aspx
The class CSocket presents ready-to-use high level abstraction of a socket with a set of common and useful operations with sockets. It's a very strange statement that a click on the Connect button is the same as a call of Windows API function. Try to write correspondent codes and feel the difference. Is CSocket the best in the world socket wrapper? Of course, answer negative. But it's the other story.
For example, an airplane is "only" a wing wrapper. Well, let's fly on wings only. Hello, USAF bird! ;)...
2. Obviously, MFC is C++ only (and obsolete) Windows API wrapper class library.

Ok ArkM! Well Answered...

For example, an airplane is "only" a wing wrapper. Well, let's fly on wings only. Hello, USAF bird!

Good example! lol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.