CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jul 2010
    Posts
    75

    Creating a Windows API interface

    I think about creating a Win32 namespace/class (haven't decided how stuff will go yet) but I want to hear an opinion about this first.
    Basically I do this because I'm tired of all these annoying Win32 functions that always require MSDN to be opened in the background.
    I want to create my own interface that will include simple functions like WinCreate(name,width,height,x,y,style) etc.

    Is this going to be a total fail?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Creating a Windows API interface

    I guess you should look at the MFC framework.
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2010
    Posts
    75

    Re: Creating a Windows API interface

    I don't like it. It's too big and too Microsoftish.
    Yeah, Microsoftish.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Creating a Windows API interface

    1. Define "too big".
    2. You are posting to
    C++ and WinAPI Discuss Windows API related issues using C++
    what means that all discussed problems are "Microsoftish"...
    So what is the problem?
    Victor Nijegorodov

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Creating a Windows API interface

    Quote Originally Posted by paprica View Post
    I think about creating a Win32 namespace/class (haven't decided how stuff will go yet) but I want to hear an opinion about this first.
    Basically I do this because I'm tired of all these annoying Win32 functions that always require MSDN to be opened in the background.
    To write a C++ wrapper, you must know the Windows API and how to use it properly.
    I want to create my own interface that will include simple functions like WinCreate(name,width,height,x,y,style) etc.
    And what function will "WinCreate" call to create a window? The "annoying" Windows API function, of course.
    Is this going to be a total fail?
    Please read this thread:

    http://www.codeguru.com/forum/showthread.php?t=514257

    And this post:
    http://www.codeguru.com/forum/showpo...1&postcount=13

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; July 17th, 2011 at 12:48 PM.

  6. #6
    Join Date
    Jul 2010
    Posts
    75

    Re: Creating a Windows API interface

    Please don't enhance controversial words that I say, like "annoying".
    What I really meant was that these functions really require nonstop MSDN pages navigations.

    Anyway, I get you. "Wrapping" this library isn't for me. I guess I'll just stick to MFC.

    Victor, here's "too big" and "too Microsoftish" for you.
    http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx

    No straight to the point classes/functions names. Many stuff I'm not looking for. Only thing I get for searching "Create" in my browser is "CCreateContext Structure" which isn't what I'm looking for.

    I might sound like a complete novice but isn't the whole point for wrapping such a library is to make easier and more convenient to use?
    Could be something like
    Code:
    INT WinMain(...)
    {
      CWindow mywindow(par1, par2, par3);
      mywindow.Show();
    }
    I don't know. I google "MFC Tutorial" and I get all these examples without even an entry point for the application.

  7. #7
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Creating a Windows API interface

    Quote Originally Posted by paprica View Post
    Victor, here's "too big" and "too Microsoftish" for you.
    http://msdn.microsoft.com/en-us/library/bk77x1wx(v=vs.71).aspx
    Very bad example. The number of classes is stipulated by internal diversity of various windows. Windows API is as much complex as Windows itself is.

    I might sound like a complete novice but isn't the whole point for wrapping such a library is to make easier and more convenient to use?
    Could be something like
    Code:
    INT WinMain(...)
    {
      CWindow mywindow(par1, par2, par3);
      mywindow.Show();
    }
    I don't know. I google "MFC Tutorial" and I get all these examples without even an entry point for the application.
    You know, you really do.

    This is your WinMain how MFC does it:
    Code:
    class CMyApp: public CWinApp
    {
        BOOL InitInstance()
        {
            CMyDlg dlg;
            dlg.DoModal();
            return FALSE;
        }
    }
    CMyApp theApp;
    Don't you find it looking good enough for you?
    Best regards,
    Igor

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Creating a Windows API interface

    I google "MFC Tutorial" and I get all these examples without even an entry point for the application.
    MFC hides WinMain implementation from user. The very first framework entry available for custom implementation is CWinApp::InitInstance. You really need to start from some good book on MFC rather than messing with on-line tutorials. Or try WTL if you feel MFC is not for you.
    Last edited by Igor Vartanov; July 17th, 2011 at 02:10 PM.
    Best regards,
    Igor

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Creating a Windows API interface

    Quote Originally Posted by Igor Vartanov View Post
    Or try WTL if you feel MFC is not for you.
    +1 for WTL.

    If you already know MFC, then you'll immediately see the beauty and compactness of WTL.

    If not, then you've got some of that dreaded Msdn reading to do.

    Or you can go the other route than some folks find appealing, called reinventing the wheel.

    Folks that do this sort of thing enjoy it, only to be despised by other folks that need to maintain their code.

  10. #10
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Creating a Windows API interface

    paprica,

    In addition to what has already been said.
    I would like to ask two questions:
    How many programs/application have you written and what OS were they for? How much simpler was it in comparison to programming for Windows?

    To write a good application you have to have fairly good knowledge about the OS system MS or not.
    To write a good application you have to be a good knowledge about programming language and set of functions that you use to write a program, no matter what you choose: some kind of framework (MFC, WTL) or raw Windows API.
    All of the above is called experience.
    You can consider C#, or VB. But still you have to understand how to use the language and functionality it provides.
    Anyway, I am not sure why is it customary and fashionable to complain about Microsoft but still trying to write Windows applications.
    If Microsoft-ish and Windows turn you off, switch to Unix-like OS for example and see how window creation is handled in this paradigm.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  11. #11
    Join Date
    Dec 2009
    Posts
    49

    Re: Creating a Windows API interface

    I'd rather use WinAPI than MFC. MFC is just bad - I find it hard to even call it object-oriented. The only promising thing in the future seems to be WinRT.

  12. #12
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Creating a Windows API interface

    Quote Originally Posted by Bssldr View Post
    I'd rather use WinAPI than MFC.
    Could you please share with us how long have you been using WinAPI vs. MFC vs. other framework?
    Quote Originally Posted by Bssldr View Post
    MFC is just bad - I find it hard to even call it object-oriented.
    Could you please elaborate? What is disqualifying MFC as object oriented?
    Quote Originally Posted by Bssldr View Post
    .The only promising thing in the future seems to be WinRT.
    Well, correct me if I am wrong: WinRT is a toolkit used by some to develop drivers. It has nothing to do with programming Windows applications. How promising could that be for applications developers?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  13. #13
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Creating a Windows API interface

    Quote Originally Posted by Bssldr View Post
    I'd rather use WinAPI than MFC. MFC is just bad - I find it hard to even call it object-oriented.
    What is so "bad" in MFC that makes you rather use WinAPI than MFC?
    Victor Nijegorodov

  14. #14
    Join Date
    Dec 2009
    Posts
    49

    Re: Creating a Windows API interface

    Quote Originally Posted by JohnCz View Post
    Could you please share with us how long have you been using WinAPI vs. MFC vs. other framework?
    Could you please elaborate? What is disqualifying MFC as object oriented?
    Well, correct me if I am wrong: WinRT is a toolkit used by some to develop drivers. It has nothing to do with programming Windows applications. How promising could that be for applications developers?
    Quote Originally Posted by VictorN View Post
    What is so "bad" in MFC that makes you rather use WinAPI than MFC?
    WinRT - http://arstechnica.com/microsoft/new...m-reborn.ars/2

    Now about MFC. Modern - returning BOOL when there's bool, hungarian notation? Object oriented - global functions, class methods that are nothing more than WinAPI functions throwed into meaningful classes? Honestly, come on. I'll just use Qt for GUI and since I program for Windows only I'll use WinAPI for the rest - the way MFC mixes C and C++ makes me want to throw up.

  15. #15
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Creating a Windows API interface

    Complaining about BOOL and hungarian notation? Really?

    BOOL existed before there was a boolean data type in C++. Should the MFC folks switch BOOL (an int) to bool and chance breaking existing code?

    Nothing wrong with Hungarian notation. Remember, it was handy before IDE's could tell you datatypes with intellisense or by hovering over variables. Do you think it would be a good idea to rename MFC variables as well?

    In fact, it isn't surprising that MFC is a bit dated, as it was first designed in the Win 3.1 timeframe for 16-bit Windows. Back then, there was a big push to get folks to start writing apps for 32-bit Windows, so it wouldn't have been a good idea to drastically change the classes.

    That's kind of the problem with a framework that achieves the success that MFC has - you can't really alter it much without the risk of breaking your users.

    As an alternative to MFC, you might want to check out ATL (um, WTL). Since it uses templates, it's a bit more modern than MFC.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured