I've had this question in the back of my mind for a while, and it is surfacing. Why use MFC when you can just program core API? I, personally, love the API!
--Garfield
I've had this question in the back of my mind for a while, and it is surfacing. Why use MFC when you can just program core API? I, personally, love the API!
--Garfield
1978 Silver Anniversary Corvette
..because MFC can speed some things up, and has some useful helper classes. Although it depends what you want to do.
zen
>> because MFC can speed some things up <<
In what way? I thought API would be faster programs.
1978 Silver Anniversary Corvette
I don't mean speed, as in speed of code, but speed of development.
zen
Oh, to me speed of development is not really worth it. I have time.
1978 Silver Anniversary Corvette
It's actually sorta nice if you just need to do something where you don't care about if you know the inner-workings of things, and you just feel like doing the VB-thang and double clicking on an object while you design it to get an action for it...(instead of windows messages)
I never use it, though.
For me it speeds up development time of windows apps by a factor of 10. And I don't think my boss would approve if I tell him I will need 4 years for our next project instead of 5 months...
I mean... can you really imagine building an interface like outlook in pure WinAPI ?
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Try doing a WYSISYG print preview in just the API.
Try a docking/floating toolbar.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Yes, I can imagine doing anything in the API. It is not difficult. In fact it is in many ways more straightforward than using MFC, which is riddled with bugs.
Yes, using MFC can speed things up because so much is already written for you. However, as a seasoned developer with decades of doing all manner of GUIs, compilers and O/Ss, I have libraries of all the stuff I've written.
I can always just cut and paste a function and make a few mods to it. The advantage is that I control every line of code.
If you have time, I recommend using the API, because you can do things with the API that MFC dependent coders will likely never master. For example, if you use the API, you could create menus that tear-off fairly easily. With MFC, you'd have to rewrite portions of MFC to make it work in that new modality.
Using MFC is fine, but it's just that so much powerful understanding is lost if you never explore the API thoroughly. If you only knew how easy it is to actually write a GUI like Windows, it's incredibly simple!
In order to be a really powerful coder, you should be comfortably mixing and matching from both environs.
>> Try doing a WYSISYG print preview in just the API.
Very easy. Simply call your update route to redraw everything, but instead at an arbitrary scale. Same thing to actually print it. Simply update and draw in the printing graphics port instead of in the window portmap.
>>Try a docking/floating toolbar.
Trivial. Simply manage the window list for activation/deactivation using a different window defproc (so it looks like a floater) and then follow the mouse. The truth is, to do this, you simple put wrappers around calls to standard Windows functions.
enjoy.
>>Very easy. Simply call your update route to redraw everything, but instead at an arbitrary scale. Same thing to actually print it.
What arbitrary scale? (For font creation it has to be int ratios)
How do take into account the different ratio (x,y) of a pixcel on the screen to the printer without loosing the int ratio? (approx 1.17 and keep accurate over large tables extending over many pages)
>>Simply update and draw in the printing graphics port instead of in the window portmap.
Sorry I don't know what you mean.
>>Trivial.
Send me some code then!
Make sure it runs in all resolutions (for my laptop and my PC) and I can add my own buttons by loading a bmp from file or creating one (not resource). Oh, and to take into account the MSOffice Quick-start menu my boss has down the side of his screen.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
I have never used MFC. I don't doubt that it is fast to work with, but I have to have classes everywhere when I don't need to. Besides, I'm working in assembler also and you don't have real classes there.
// Gliptic
>> What arbitrary scale? <<
You can set the client area to be of different mapping modes. One of them is isometric where you can make an arbitrary scale and apply it with SetWindowExtEx and SetViewportExtEx.
--Garfield
API all the way!!! I have time.
1978 Silver Anniversary Corvette
Development time.
Businesses, for the most part, don't care how or why the API works - it just does.
They care about the task at hand which is developing their new application in the most cost-efficent manner possible while at the same time providing a high-quality product to their customers.
Customers don't care about window functions, font functions, or the guts of the API. They care about the GUI, performance, versatility, stablity, and cost to name a few. Libraries and utilities allow business to concentrate and perfect what the customer will see and use, rather than on the minute details behind it all.
It keeps costs down, it's easier, it's efficient, it's a huge time saver, and it's good business. Why complicate the matter?
Does a carpenter refuse to use a hammer or a saw just because he/she did not craft it and it does not do everything they would like it to do? Of course not.
So why should a programmer refuse to use the tools provided to him/her to get a job done?
For personal use, you may have time to craft that hammer and saw to your exact needs. For business - you just use the hammer and saw and move on.
And you've forgotten one more thing: API calls use to crash in multithreaded apps, while MFC seems to be a bit better.
[R]evolution!
Programming related articles, downloads, demos