Thread: Why MFC when you can just use API?

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Why MFC when you can just use API?

    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

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    ..because MFC can speed some things up, and has some useful helper classes. Although it depends what you want to do.
    zen

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> because MFC can speed some things up <<

    In what way? I thought API would be faster programs.
    1978 Silver Anniversary Corvette

  4. #4
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    I don't mean speed, as in speed of code, but speed of development.
    zen

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Oh, to me speed of development is not really worth it. I have time.
    1978 Silver Anniversary Corvette

  6. #6
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    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.

  7. #7
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    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.

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    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

  9. #9
    Sayeh
    Guest
    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.

  10. #10
    Sayeh
    Guest
    >> 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.

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>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

  12. #12
    Registered User
    Join Date
    Sep 2001
    Posts
    164
    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

  13. #13
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> 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

  14. #14
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

  15. #15
    Normal vector Carlos's Avatar
    Join Date
    Sep 2001
    Location
    Budapest
    Posts
    463
    And you've forgotten one more thing: API calls use to crash in multithreaded apps, while MFC seems to be a bit better.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 05:57 PM
  2. Thread Synchronization :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 08-09-2002, 09:09 AM
  3. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  4. MFC or Windows API
    By aresashura in forum Windows Programming
    Replies: 7
    Last Post: 12-01-2001, 10:21 PM
  5. Difference between MFC and API
    By Garfield in forum Windows Programming
    Replies: 5
    Last Post: 09-23-2001, 06:12 PM