Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Windows C++: a bit shocked

Windows C++: a bit shocked

Scheduled Pinned Locked Moved The Lounge
csharpc++javavisual-studio
53 Posts 20 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raddevus
    wrote on last edited by
    #1

    I have Visual Studio 2019 installed on my machine. I just built a C++ desktop app from template. I will continue the shocking part of this story but first a little history... Around 1993 Long ago (1993) I started learning C++. The developers in my group at that time were writing a large program using Visual Studio 1,2,3, etc. and developing on the Windows SDK -- SDK style programming which was basically C wrapped up in Microsoft's way of doing things. MFC : I Thought It Was Fantastic Okay, but at that same time a fantastic thing was born: MFC (Microsoft Foundation Classes) This was true C++ wrappers around the API calls. It was quite fantastic and I began to learn it. It was kind of like C# before C# was released. I was stuck between these amazing devs who knew Win API SDK style programming and the MFC (which used true OOP). The generation in front of me wanted little to do with these "unnecessary wrappers around the API" But I continued into MFC. Finally, around 1999 Microsoft announces C# and I am angry. :mad: Java-like? Throw away this investment into the MFC? :mad: Well, it'll be okay, because people will come to their senses and see that MFC is already doing all this stuff they're only promising with C#. Yeah, that's the ticket! I Jump On Board C# Finally, I jump on board the C# train and it becomes a rocket. It's the Windows API wrapped in OOP. There are missing things (as the .NET libraries become mature) and I understand how to get to those with pinvoke which is based upon my experience with (yes, Visual Basic) and knowing the Win API from MFC, etc. We Now Return To My Original Shock So, now, it's like 20 years later and I build a desktop app from the Visual C++ template and what do I see? Original Windows API stuff!!!! :wtf: :wtf: It's the unwrapped, unvarnished message loop!!!

    // Main message loop:
    while (GetMessage(&msg, nullptr, 0, 0))
    {
    if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }

    It's the old RegisterClass (not related to OOP and classes but related to WNDCLASS).

    //
    // FUNCTION: MyRegisterClass()
    //
    // PURPOSE: Registers the window class.
    //
    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
    WNDCLASSEXW wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);
    
    wcex.style          = CS\_HREDRAW | CS\_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cb
    
    M L K J C 15 Replies Last reply
    0
    • R raddevus

      I have Visual Studio 2019 installed on my machine. I just built a C++ desktop app from template. I will continue the shocking part of this story but first a little history... Around 1993 Long ago (1993) I started learning C++. The developers in my group at that time were writing a large program using Visual Studio 1,2,3, etc. and developing on the Windows SDK -- SDK style programming which was basically C wrapped up in Microsoft's way of doing things. MFC : I Thought It Was Fantastic Okay, but at that same time a fantastic thing was born: MFC (Microsoft Foundation Classes) This was true C++ wrappers around the API calls. It was quite fantastic and I began to learn it. It was kind of like C# before C# was released. I was stuck between these amazing devs who knew Win API SDK style programming and the MFC (which used true OOP). The generation in front of me wanted little to do with these "unnecessary wrappers around the API" But I continued into MFC. Finally, around 1999 Microsoft announces C# and I am angry. :mad: Java-like? Throw away this investment into the MFC? :mad: Well, it'll be okay, because people will come to their senses and see that MFC is already doing all this stuff they're only promising with C#. Yeah, that's the ticket! I Jump On Board C# Finally, I jump on board the C# train and it becomes a rocket. It's the Windows API wrapped in OOP. There are missing things (as the .NET libraries become mature) and I understand how to get to those with pinvoke which is based upon my experience with (yes, Visual Basic) and knowing the Win API from MFC, etc. We Now Return To My Original Shock So, now, it's like 20 years later and I build a desktop app from the Visual C++ template and what do I see? Original Windows API stuff!!!! :wtf: :wtf: It's the unwrapped, unvarnished message loop!!!

      // Main message loop:
      while (GetMessage(&msg, nullptr, 0, 0))
      {
      if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
      {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
      }
      }

      It's the old RegisterClass (not related to OOP and classes but related to WNDCLASS).

      //
      // FUNCTION: MyRegisterClass()
      //
      // PURPOSE: Registers the window class.
      //
      ATOM MyRegisterClass(HINSTANCE hInstance)
      {
      WNDCLASSEXW wcex;

      wcex.cbSize = sizeof(WNDCLASSEX);
      
      wcex.style          = CS\_HREDRAW | CS\_VREDRAW;
      wcex.lpfnWndProc    = WndProc;
      wcex.cb
      
      M Offline
      M Offline
      Munchies_Matt
      wrote on last edited by
      #2

      Build the windows app from MFC rather than the win32 API. Anyway, things change even slower in the kernel. :cool:

      R 2 Replies Last reply
      0
      • M Munchies_Matt

        Build the windows app from MFC rather than the win32 API. Anyway, things change even slower in the kernel. :cool:

        R Offline
        R Offline
        raddevus
        wrote on last edited by
        #3

        Munchies_Matt wrote:

        Build the windows app from MFC rather than the win32 API.

        From the wizard in Visual Studio 2019 I don't see any MFC choices except one: https://i.stack.imgur.com/v3Sgq.png[^] But look, when I choose Desktop app, it removes the Add MFC Headers option (greys it out so it can't be selected) https://i.stack.imgur.com/2GAMh.png[^]

        1 Reply Last reply
        0
        • M Munchies_Matt

          Build the windows app from MFC rather than the win32 API. Anyway, things change even slower in the kernel. :cool:

          R Offline
          R Offline
          raddevus
          wrote on last edited by
          #4

          I went back to the Visual STudio installer and checked and it does mention MFC in the desktop tools installation. https://i.stack.imgur.com/CBHX4.png[^] Maybe I'm just not finding the right template project?? :~ But, this was more about the fact that MFC was just left behind and ignored. Alas. Alas. :sigh:

          M 1 Reply Last reply
          0
          • R raddevus

            I went back to the Visual STudio installer and checked and it does mention MFC in the desktop tools installation. https://i.stack.imgur.com/CBHX4.png[^] Maybe I'm just not finding the right template project?? :~ But, this was more about the fact that MFC was just left behind and ignored. Alas. Alas. :sigh:

            M Offline
            M Offline
            Munchies_Matt
            wrote on last edited by
            #5

            I just installed 2017 and it has MFC stuff in the templates still. Sure you didnt miss it?

            R 1 Reply Last reply
            0
            • M Munchies_Matt

              I just installed 2017 and it has MFC stuff in the templates still. Sure you didnt miss it?

              R Offline
              R Offline
              raddevus
              wrote on last edited by
              #6

              2017 yes. But 2019 doesn't have it. I could just be too far on the cutting edge. :)

              M 1 Reply Last reply
              0
              • R raddevus

                2017 yes. But 2019 doesn't have it. I could just be too far on the cutting edge. :)

                M Offline
                M Offline
                Munchies_Matt
                wrote on last edited by
                #7

                Blimey, I cant imagine why they would drop it, it is still a very useful framework.

                R K 2 Replies Last reply
                0
                • R raddevus

                  I have Visual Studio 2019 installed on my machine. I just built a C++ desktop app from template. I will continue the shocking part of this story but first a little history... Around 1993 Long ago (1993) I started learning C++. The developers in my group at that time were writing a large program using Visual Studio 1,2,3, etc. and developing on the Windows SDK -- SDK style programming which was basically C wrapped up in Microsoft's way of doing things. MFC : I Thought It Was Fantastic Okay, but at that same time a fantastic thing was born: MFC (Microsoft Foundation Classes) This was true C++ wrappers around the API calls. It was quite fantastic and I began to learn it. It was kind of like C# before C# was released. I was stuck between these amazing devs who knew Win API SDK style programming and the MFC (which used true OOP). The generation in front of me wanted little to do with these "unnecessary wrappers around the API" But I continued into MFC. Finally, around 1999 Microsoft announces C# and I am angry. :mad: Java-like? Throw away this investment into the MFC? :mad: Well, it'll be okay, because people will come to their senses and see that MFC is already doing all this stuff they're only promising with C#. Yeah, that's the ticket! I Jump On Board C# Finally, I jump on board the C# train and it becomes a rocket. It's the Windows API wrapped in OOP. There are missing things (as the .NET libraries become mature) and I understand how to get to those with pinvoke which is based upon my experience with (yes, Visual Basic) and knowing the Win API from MFC, etc. We Now Return To My Original Shock So, now, it's like 20 years later and I build a desktop app from the Visual C++ template and what do I see? Original Windows API stuff!!!! :wtf: :wtf: It's the unwrapped, unvarnished message loop!!!

                  // Main message loop:
                  while (GetMessage(&msg, nullptr, 0, 0))
                  {
                  if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                  {
                  TranslateMessage(&msg);
                  DispatchMessage(&msg);
                  }
                  }

                  It's the old RegisterClass (not related to OOP and classes but related to WNDCLASS).

                  //
                  // FUNCTION: MyRegisterClass()
                  //
                  // PURPOSE: Registers the window class.
                  //
                  ATOM MyRegisterClass(HINSTANCE hInstance)
                  {
                  WNDCLASSEXW wcex;

                  wcex.cbSize = sizeof(WNDCLASSEX);
                  
                  wcex.style          = CS\_HREDRAW | CS\_VREDRAW;
                  wcex.lpfnWndProc    = WndProc;
                  wcex.cb
                  
                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  That's the Win32 template, and hasn't been updated since Visual C++ 6.0. AFAIK MFC is an add-on that does not come with VS.

                  R 1 Reply Last reply
                  0
                  • M Munchies_Matt

                    Blimey, I cant imagine why they would drop it, it is still a very useful framework.

                    R Offline
                    R Offline
                    raddevus
                    wrote on last edited by
                    #9

                    Munchies_Matt wrote:

                    Blimey, I cant imagine why they would drop it, it is still a very useful framework.

                    I agree. But from a product standpoint I bet they hate it because they are like,

                    Random Product Manager at Microsoft Visual Studio:

                    "Look people have C# if they want that type of thing and this is just a long-term maintenance and support nightmare."

                    1 Reply Last reply
                    0
                    • L Lost User

                      That's the Win32 template, and hasn't been updated since Visual C++ 6.0. AFAIK MFC is an add-on that does not come with VS.

                      R Offline
                      R Offline
                      raddevus
                      wrote on last edited by
                      #10

                      Richard MacCutchan wrote:

                      MFC is an add-on that does not come with VS

                      How dare you call it a...a... :(( add-on. :(( :laugh: I think they are silently dropping it in 2019.

                      L 1 Reply Last reply
                      0
                      • R raddevus

                        Richard MacCutchan wrote:

                        MFC is an add-on that does not come with VS

                        How dare you call it a...a... :(( add-on. :(( :laugh: I think they are silently dropping it in 2019.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        I used MFC for quite a few years in my last job, and after climbing the learning curve, I actually got to love it.

                        R 1 Reply Last reply
                        0
                        • L Lost User

                          I used MFC for quite a few years in my last job, and after climbing the learning curve, I actually got to love it.

                          R Offline
                          R Offline
                          raddevus
                          wrote on last edited by
                          #12

                          Richard MacCutchan wrote:

                          after climbing the learning curve, I actually got to love it.

                          :thumbsup: It's really a very nice library. Wrapped up things very nicely.

                          R 1 Reply Last reply
                          0
                          • M Munchies_Matt

                            Blimey, I cant imagine why they would drop it, it is still a very useful framework.

                            K Offline
                            K Offline
                            kalberts
                            wrote on last edited by
                            #13

                            I looked into it when it first came out in the early 1990s. My reactions then was that "This framework takes over so much of the program logic that it will hijack the entire application and make it extremely difficult to adapt to another [i.e. non-Windows] application!" The application was planned for multi-platform - Windows was certainly not as dominant then as it has become now. Today, making a Windows-only application is perfectly fine. But as far as I have seen, MFC today is no less (rather more than in the beginning!) a "framework" in the straightjacket sense. It dictates how you write your application logic far more than I appreciate. I wanted to see it as a "library" rather than as a framework, a library that could be replaced by another library (on another platform) without affecting the program logic very much. It didn't appear that way to me, certainly not in the 1990s. For some reason, I never got that same feeling with C# and WPF. Maybe that is because I have more experience now and simply ignore the elements that try to force me into an application design style that doesn't suit me. Porting C# applications to other platforms is not a very relevant question today, nevertheless I feel that I am the master, WPF is my servant. With MFC it was the other way around, as I experienced it.

                            B 1 Reply Last reply
                            0
                            • R raddevus

                              I have Visual Studio 2019 installed on my machine. I just built a C++ desktop app from template. I will continue the shocking part of this story but first a little history... Around 1993 Long ago (1993) I started learning C++. The developers in my group at that time were writing a large program using Visual Studio 1,2,3, etc. and developing on the Windows SDK -- SDK style programming which was basically C wrapped up in Microsoft's way of doing things. MFC : I Thought It Was Fantastic Okay, but at that same time a fantastic thing was born: MFC (Microsoft Foundation Classes) This was true C++ wrappers around the API calls. It was quite fantastic and I began to learn it. It was kind of like C# before C# was released. I was stuck between these amazing devs who knew Win API SDK style programming and the MFC (which used true OOP). The generation in front of me wanted little to do with these "unnecessary wrappers around the API" But I continued into MFC. Finally, around 1999 Microsoft announces C# and I am angry. :mad: Java-like? Throw away this investment into the MFC? :mad: Well, it'll be okay, because people will come to their senses and see that MFC is already doing all this stuff they're only promising with C#. Yeah, that's the ticket! I Jump On Board C# Finally, I jump on board the C# train and it becomes a rocket. It's the Windows API wrapped in OOP. There are missing things (as the .NET libraries become mature) and I understand how to get to those with pinvoke which is based upon my experience with (yes, Visual Basic) and knowing the Win API from MFC, etc. We Now Return To My Original Shock So, now, it's like 20 years later and I build a desktop app from the Visual C++ template and what do I see? Original Windows API stuff!!!! :wtf: :wtf: It's the unwrapped, unvarnished message loop!!!

                              // Main message loop:
                              while (GetMessage(&msg, nullptr, 0, 0))
                              {
                              if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                              {
                              TranslateMessage(&msg);
                              DispatchMessage(&msg);
                              }
                              }

                              It's the old RegisterClass (not related to OOP and classes but related to WNDCLASS).

                              //
                              // FUNCTION: MyRegisterClass()
                              //
                              // PURPOSE: Registers the window class.
                              //
                              ATOM MyRegisterClass(HINSTANCE hInstance)
                              {
                              WNDCLASSEXW wcex;

                              wcex.cbSize = sizeof(WNDCLASSEX);
                              
                              wcex.style          = CS\_HREDRAW | CS\_VREDRAW;
                              wcex.lpfnWndProc    = WndProc;
                              wcex.cb
                              
                              K Offline
                              K Offline
                              kalberts
                              wrote on last edited by
                              #14

                              Actually, I pity that the mainloop didn't catch on as a programming model :-) I am not talking about the mainloop itself, but the idea of event-driven programming - designing and implementing your application as a state table: The FSM driver is 20-30 lines of code. Whenever something happens - an event - it indexes the 2D state table by the current state and the event, to find the action to perform and the next state. The state table is where the program logic is expressed. The action part is application specific code, but you'd be surprise by how few different actions are required, and how simple and fucnctionally isolated they are. 95+ percent of traditional program flow control is replaced by the "next state" logic. In a properly designed FSM application, each state tansition and associated (when required; it often isn't) action is so rapid that there is very little need for any preemptive scheduling (which 16-bit Windows didn't have). In a proper FSM design, event transition is conceptually instantaneous, from one consistent state to another consistent state, avoiding all racing conditions. "Synchronzing" is not a relevant concept. Complete error handling is very easy to achieve: For every emtpy state table entry, i.e. any state/event combination for which there is no well defined meaningful transition from the current consistent state to another consistent state, you fill in an error action. Any table entry that doesn't have a (normal or error) action filled in will glare at you, reminding you: You must handle this error! To keep state tables to a moderate size, it is common to accept a few well defined "state variables" accessible for testing and setting from the action routines. In some FSMs, the logic of testing some of these variables are put into the state table: Each state/event entry may list a small sequence (usually no more than 3 or 4) alternate actions guarded by logical expressions on the state variables. Probably the most complex protocol in the entire OSI protocol stack family, the X.225 Session Protocol, is described by 32 states, 80 events, 79 predicates and 34 transition actions. The 79 predicates can all be expressed as a one-line boolean expression. Most of the 34 actions fill less than 50 lines of code (assuming a proper service interface to the Transport layer). From an FSM modelling point of view, X.225 is a beauty! (I am not saying that the protocol is, I am talking about the modelling of it!) The old Windows message lo

                              R S 2 Replies Last reply
                              0
                              • R raddevus

                                I have Visual Studio 2019 installed on my machine. I just built a C++ desktop app from template. I will continue the shocking part of this story but first a little history... Around 1993 Long ago (1993) I started learning C++. The developers in my group at that time were writing a large program using Visual Studio 1,2,3, etc. and developing on the Windows SDK -- SDK style programming which was basically C wrapped up in Microsoft's way of doing things. MFC : I Thought It Was Fantastic Okay, but at that same time a fantastic thing was born: MFC (Microsoft Foundation Classes) This was true C++ wrappers around the API calls. It was quite fantastic and I began to learn it. It was kind of like C# before C# was released. I was stuck between these amazing devs who knew Win API SDK style programming and the MFC (which used true OOP). The generation in front of me wanted little to do with these "unnecessary wrappers around the API" But I continued into MFC. Finally, around 1999 Microsoft announces C# and I am angry. :mad: Java-like? Throw away this investment into the MFC? :mad: Well, it'll be okay, because people will come to their senses and see that MFC is already doing all this stuff they're only promising with C#. Yeah, that's the ticket! I Jump On Board C# Finally, I jump on board the C# train and it becomes a rocket. It's the Windows API wrapped in OOP. There are missing things (as the .NET libraries become mature) and I understand how to get to those with pinvoke which is based upon my experience with (yes, Visual Basic) and knowing the Win API from MFC, etc. We Now Return To My Original Shock So, now, it's like 20 years later and I build a desktop app from the Visual C++ template and what do I see? Original Windows API stuff!!!! :wtf: :wtf: It's the unwrapped, unvarnished message loop!!!

                                // Main message loop:
                                while (GetMessage(&msg, nullptr, 0, 0))
                                {
                                if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                                {
                                TranslateMessage(&msg);
                                DispatchMessage(&msg);
                                }
                                }

                                It's the old RegisterClass (not related to OOP and classes but related to WNDCLASS).

                                //
                                // FUNCTION: MyRegisterClass()
                                //
                                // PURPOSE: Registers the window class.
                                //
                                ATOM MyRegisterClass(HINSTANCE hInstance)
                                {
                                WNDCLASSEXW wcex;

                                wcex.cbSize = sizeof(WNDCLASSEX);
                                
                                wcex.style          = CS\_HREDRAW | CS\_VREDRAW;
                                wcex.lpfnWndProc    = WndProc;
                                wcex.cb
                                
                                J Offline
                                J Offline
                                Joe Woodbury
                                wrote on last edited by
                                #15

                                When you install Visual Studio 2015 and later, MFC is not installed by default. When installing tools for native, ALWAYS use the install components.

                                R 1 Reply Last reply
                                0
                                • K kalberts

                                  Actually, I pity that the mainloop didn't catch on as a programming model :-) I am not talking about the mainloop itself, but the idea of event-driven programming - designing and implementing your application as a state table: The FSM driver is 20-30 lines of code. Whenever something happens - an event - it indexes the 2D state table by the current state and the event, to find the action to perform and the next state. The state table is where the program logic is expressed. The action part is application specific code, but you'd be surprise by how few different actions are required, and how simple and fucnctionally isolated they are. 95+ percent of traditional program flow control is replaced by the "next state" logic. In a properly designed FSM application, each state tansition and associated (when required; it often isn't) action is so rapid that there is very little need for any preemptive scheduling (which 16-bit Windows didn't have). In a proper FSM design, event transition is conceptually instantaneous, from one consistent state to another consistent state, avoiding all racing conditions. "Synchronzing" is not a relevant concept. Complete error handling is very easy to achieve: For every emtpy state table entry, i.e. any state/event combination for which there is no well defined meaningful transition from the current consistent state to another consistent state, you fill in an error action. Any table entry that doesn't have a (normal or error) action filled in will glare at you, reminding you: You must handle this error! To keep state tables to a moderate size, it is common to accept a few well defined "state variables" accessible for testing and setting from the action routines. In some FSMs, the logic of testing some of these variables are put into the state table: Each state/event entry may list a small sequence (usually no more than 3 or 4) alternate actions guarded by logical expressions on the state variables. Probably the most complex protocol in the entire OSI protocol stack family, the X.225 Session Protocol, is described by 32 states, 80 events, 79 predicates and 34 transition actions. The 79 predicates can all be expressed as a one-line boolean expression. Most of the 34 actions fill less than 50 lines of code (assuming a proper service interface to the Transport layer). From an FSM modelling point of view, X.225 is a beauty! (I am not saying that the protocol is, I am talking about the modelling of it!) The old Windows message lo

                                  R Offline
                                  R Offline
                                  raddevus
                                  wrote on last edited by
                                  #16

                                  Very interesting post, could almost be an article. Better write one up, because FSM application would be very interesting. I agree with you about the program logic part. FSM would make it completely simple technologically and maybe that part of the message loop should be handled that way since it simplifies a lot. OOP : Just Code Organization OOP is just a way of organizing code though and that is what most of the world needs: code organization. Code organization (when done properly) allows maintenance to be done quickly and by a large number of people. Data encapsulation (think hiding algorithms) allows more people who don't necessarily understand the ugly innards of the algo itself to still do maintenance fixes since code is organized into components that work properly as black boxes. That's what I thought was nice about the MFC wrapper. It organized some things that I didn't want to know how they worked so I could put them together in ways to build something. Slow Down & Write K&R C If only we all had the time to slow down and write programs like the K&R C book. But we don't. Things must be hidden and hidden means there will be things I don't understand. Not my first choice but I have to build a product. :) I hope you'll write up an article on FSMs. It would be a great read. :thumbsup:

                                  1 Reply Last reply
                                  0
                                  • J Joe Woodbury

                                    When you install Visual Studio 2015 and later, MFC is not installed by default. When installing tools for native, ALWAYS use the install components.

                                    R Offline
                                    R Offline
                                    raddevus
                                    wrote on last edited by
                                    #17

                                    Yeah, someone had kind of already pointed that out, but that doesn't seem to be the problem. I went back and checked the Visual Studio Installer and it shows that I picked the option for MFC: https://i.stack.imgur.com/CBHX4.png[^]

                                    J 1 Reply Last reply
                                    0
                                    • R raddevus

                                      I have Visual Studio 2019 installed on my machine. I just built a C++ desktop app from template. I will continue the shocking part of this story but first a little history... Around 1993 Long ago (1993) I started learning C++. The developers in my group at that time were writing a large program using Visual Studio 1,2,3, etc. and developing on the Windows SDK -- SDK style programming which was basically C wrapped up in Microsoft's way of doing things. MFC : I Thought It Was Fantastic Okay, but at that same time a fantastic thing was born: MFC (Microsoft Foundation Classes) This was true C++ wrappers around the API calls. It was quite fantastic and I began to learn it. It was kind of like C# before C# was released. I was stuck between these amazing devs who knew Win API SDK style programming and the MFC (which used true OOP). The generation in front of me wanted little to do with these "unnecessary wrappers around the API" But I continued into MFC. Finally, around 1999 Microsoft announces C# and I am angry. :mad: Java-like? Throw away this investment into the MFC? :mad: Well, it'll be okay, because people will come to their senses and see that MFC is already doing all this stuff they're only promising with C#. Yeah, that's the ticket! I Jump On Board C# Finally, I jump on board the C# train and it becomes a rocket. It's the Windows API wrapped in OOP. There are missing things (as the .NET libraries become mature) and I understand how to get to those with pinvoke which is based upon my experience with (yes, Visual Basic) and knowing the Win API from MFC, etc. We Now Return To My Original Shock So, now, it's like 20 years later and I build a desktop app from the Visual C++ template and what do I see? Original Windows API stuff!!!! :wtf: :wtf: It's the unwrapped, unvarnished message loop!!!

                                      // Main message loop:
                                      while (GetMessage(&msg, nullptr, 0, 0))
                                      {
                                      if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                                      {
                                      TranslateMessage(&msg);
                                      DispatchMessage(&msg);
                                      }
                                      }

                                      It's the old RegisterClass (not related to OOP and classes but related to WNDCLASS).

                                      //
                                      // FUNCTION: MyRegisterClass()
                                      //
                                      // PURPOSE: Registers the window class.
                                      //
                                      ATOM MyRegisterClass(HINSTANCE hInstance)
                                      {
                                      WNDCLASSEXW wcex;

                                      wcex.cbSize = sizeof(WNDCLASSEX);
                                      
                                      wcex.style          = CS\_HREDRAW | CS\_VREDRAW;
                                      wcex.lpfnWndProc    = WndProc;
                                      wcex.cb
                                      
                                      C Offline
                                      C Offline
                                      CPallini
                                      wrote on last edited by
                                      #18

                                      MFC were (are?) a thin wrapper around Win32 (now Winapi). If you miss them then the wrapper wasn't that thin, after all. :)

                                      R 1 Reply Last reply
                                      0
                                      • K kalberts

                                        Actually, I pity that the mainloop didn't catch on as a programming model :-) I am not talking about the mainloop itself, but the idea of event-driven programming - designing and implementing your application as a state table: The FSM driver is 20-30 lines of code. Whenever something happens - an event - it indexes the 2D state table by the current state and the event, to find the action to perform and the next state. The state table is where the program logic is expressed. The action part is application specific code, but you'd be surprise by how few different actions are required, and how simple and fucnctionally isolated they are. 95+ percent of traditional program flow control is replaced by the "next state" logic. In a properly designed FSM application, each state tansition and associated (when required; it often isn't) action is so rapid that there is very little need for any preemptive scheduling (which 16-bit Windows didn't have). In a proper FSM design, event transition is conceptually instantaneous, from one consistent state to another consistent state, avoiding all racing conditions. "Synchronzing" is not a relevant concept. Complete error handling is very easy to achieve: For every emtpy state table entry, i.e. any state/event combination for which there is no well defined meaningful transition from the current consistent state to another consistent state, you fill in an error action. Any table entry that doesn't have a (normal or error) action filled in will glare at you, reminding you: You must handle this error! To keep state tables to a moderate size, it is common to accept a few well defined "state variables" accessible for testing and setting from the action routines. In some FSMs, the logic of testing some of these variables are put into the state table: Each state/event entry may list a small sequence (usually no more than 3 or 4) alternate actions guarded by logical expressions on the state variables. Probably the most complex protocol in the entire OSI protocol stack family, the X.225 Session Protocol, is described by 32 states, 80 events, 79 predicates and 34 transition actions. The 79 predicates can all be expressed as a one-line boolean expression. Most of the 34 actions fill less than 50 lines of code (assuming a proper service interface to the Transport layer). From an FSM modelling point of view, X.225 is a beauty! (I am not saying that the protocol is, I am talking about the modelling of it!) The old Windows message lo

                                        S Offline
                                        S Offline
                                        Shuqian Ying
                                        wrote on last edited by
                                        #19

                                        It seems that good stuff never get out of fashion, even in software development ...

                                        Find more in V-NET: connects your resources anywhere[^].

                                        1 Reply Last reply
                                        0
                                        • R raddevus

                                          Yeah, someone had kind of already pointed that out, but that doesn't seem to be the problem. I went back and checked the Visual Studio Installer and it shows that I picked the option for MFC: https://i.stack.imgur.com/CBHX4.png[^]

                                          J Offline
                                          J Offline
                                          Joe Woodbury
                                          wrote on last edited by
                                          #20

                                          I just installed 2019 on a VM, make sure the individual component for MFC x86 was checked and it installed.

                                          R 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups