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. how hard to rewrite a legacy software from C++ to C# in WinForm?

how hard to rewrite a legacy software from C++ to C# in WinForm?

Scheduled Pinned Locked Moved The Lounge
csharpc++question
26 Posts 18 Posters 1 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.
  • J Jo_vb net

    Don't fear the reaper... ... just start re-writing the code. For smaller parts you can use https://www.codeconvert.ai/c++-to-csharp-converter[^] But you have to revise this converted code anyway.

    S Offline
    S Offline
    Southmountain
    wrote on last edited by
    #12

    :rose::rose::rose:

    diligent hands rule....

    1 Reply Last reply
    0
    • R RedDk

      It's easy. Start a new project in the target language of your choice. Copy the bare minimum from the source language, paste it in the new language target husk, and attempt to compile. You'll get tons of errors and warnings. Pick through them and eliminate them one-by-one. Obviously there's a lot of personal experience in "attempting" to do anything using a compiler and a linker. Done this, have I. Learned much have I.

      O Offline
      O Offline
      obermd
      wrote on last edited by
      #13

      This is exactly how I converted about 10,000 lines of VB6 code to VB 2005. The biggest changes were file handling and error reporting. To this day I'll occasionally use On Error Resume Next in short Subs and Functions when it's appropriate. Otherwise I use Try/Catch/Finally.

      R N 2 Replies Last reply
      0
      • O obermd

        This is exactly how I converted about 10,000 lines of VB6 code to VB 2005. The biggest changes were file handling and error reporting. To this day I'll occasionally use On Error Resume Next in short Subs and Functions when it's appropriate. Otherwise I use Try/Catch/Finally.

        R Offline
        R Offline
        RedDk
        wrote on last edited by
        #14

        That's it exactly. Initially posting line-numbered QBASIC code into a C++ project ... I was surprised how little squawking the VS interface returned. I like that "On Error Resume" trick. Next time ...

        1 Reply Last reply
        0
        • O obermd

          This is exactly how I converted about 10,000 lines of VB6 code to VB 2005. The biggest changes were file handling and error reporting. To this day I'll occasionally use On Error Resume Next in short Subs and Functions when it's appropriate. Otherwise I use Try/Catch/Finally.

          N Offline
          N Offline
          Nelek
          wrote on last edited by
          #15

          obermd wrote:

          To this day I'll occasionally use On Error Resume Next

          as long as you put something in between... :rolleyes: ;P :laugh:

          M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

          O 1 Reply Last reply
          0
          • S Southmountain

            I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

            diligent hands rule....

            A Offline
            A Offline
            Amarnath S
            wrote on last edited by
            #16

            Outsource to someone here (me?).

            1 Reply Last reply
            0
            • S Southmountain

              I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

              diligent hands rule....

              B Offline
              B Offline
              Bruno van Dooren
              wrote on last edited by
              #17

              Does it 'need' to be C#? Or can you use C++/CLI? Because the latter would be much simpler, in the sense that you can keep your algorithms and the back end stuff in C++, and do the user interface in C++/CLI. Is your user interface in MFC, or WTL or something else? The user interface would have to be re-built from scratch

              1 Reply Last reply
              0
              • S Southmountain

                I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

                diligent hands rule....

                G Offline
                G Offline
                Gary R Wheeler
                wrote on last edited by
                #18

                You're going to have to rewrite UI code regardless. The one advantage going to WinForms would be correspondence in the UI. WinForms is something of a wrapper around Windows GDI controls for C#, in the same sense that MFC is a wrapper for C++.

                Software Zen: delete this;

                1 Reply Last reply
                0
                • S Southmountain

                  I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

                  diligent hands rule....

                  M Offline
                  M Offline
                  MSBassSinger
                  wrote on last edited by
                  #19

                  In my experience of rewriting from one language into C#, there are a few principles I applied that helped me. 1 - Understand the requirements, architecture, and intent of the original code (which may have to be determined with only the original code at hand). 2 - Understand WHAT the original code is doing. 3 - In the new language (e.g. C#), determine how it best does what the original code did. Just translating code from original to new is a trap. 4 - What does the new language offer (including third party components if you want) that would be useful, that was not used for the original app with the original language? 5 - What new language architecture gives you the lowest total SDLC cost with the best acceptable performance, scalability, and support? Apply these principles and you will avoid a myriad of booby-traps and sloughs of despond.

                  1 Reply Last reply
                  0
                  • S Southmountain

                    I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

                    diligent hands rule....

                    B Offline
                    B Offline
                    Behzad Sedighzadeh
                    wrote on last edited by
                    #20

                    Isn't it better to use an existing product? Have you looked at ScottPlot ?

                    Behzad

                    1 Reply Last reply
                    0
                    • S Southmountain

                      I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

                      diligent hands rule....

                      O Offline
                      O Offline
                      obeobe
                      wrote on last edited by
                      #21

                      I bet ChatGPT can do it.

                      1 Reply Last reply
                      0
                      • S Southmountain

                        I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

                        diligent hands rule....

                        T Offline
                        T Offline
                        Thornik
                        wrote on last edited by
                        #22

                        Nothing hard. After C++ you'll write C# code like a song.

                        1 Reply Last reply
                        0
                        • R RedDk

                          It's easy. Start a new project in the target language of your choice. Copy the bare minimum from the source language, paste it in the new language target husk, and attempt to compile. You'll get tons of errors and warnings. Pick through them and eliminate them one-by-one. Obviously there's a lot of personal experience in "attempting" to do anything using a compiler and a linker. Done this, have I. Learned much have I.

                          J Offline
                          J Offline
                          jschell
                          wrote on last edited by
                          #23

                          At least to me the OP suggested that they want to use WinForms and that existing code does not use that. So that is a complete rewrite at least for that part.

                          1 Reply Last reply
                          0
                          • S Southmountain

                            I have a legacy software to draw very sophisticated charts. but I only need a small piece of these charts. I want to re-write the code charting this small piece of charts. How hard it is to do this? any experience to share?

                            diligent hands rule....

                            J Offline
                            J Offline
                            jochance
                            wrote on last edited by
                            #24

                            There are good charting controls available off the shelf for WPF, maybe for winforms but just go WPF. If those just won't do, you probably want to look for "using GDI+ from WPF" if you're looking to draw your own charts. If you're really wanting to visualize data in interesting ways, it might not be insane to look into using Unity. Custom rendering with GDI+ is.... hard to get a positive return on investment unless you're a company that sells components for WinForm/WPF.

                            1 Reply Last reply
                            0
                            • N Nelek

                              obermd wrote:

                              To this day I'll occasionally use On Error Resume Next

                              as long as you put something in between... :rolleyes: ;P :laugh:

                              M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                              O Offline
                              O Offline
                              obermd
                              wrote on last edited by
                              #25

                              On Error Resume Next is really useful for short clean up routines where the code would look like this

                              try {statement1} catch {}
                              try {statement2} catch {}
                              ...

                              N 1 Reply Last reply
                              0
                              • O obermd

                                On Error Resume Next is really useful for short clean up routines where the code would look like this

                                try {statement1} catch {}
                                try {statement2} catch {}
                                ...

                                N Offline
                                N Offline
                                Nelek
                                wrote on last edited by
                                #26

                                what (empty catch blocks) actually is something I do not like, have already lost some precious time tracking down things done by people thinking it is not needed.

                                M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                                1 Reply 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