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. General Programming
  3. C / C++ / MFC
  4. problem with code after switching to visual studio 2005

problem with code after switching to visual studio 2005

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpvisual-studio
8 Posts 2 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.
  • S Offline
    S Offline
    swatgodjr
    wrote on last edited by
    #1

    just recently got visual studio 2005 and well to put a long story short it has been driving me crazy lol. but anyways i had to switch from using soem of the old libraries to usign the new ones and it has caused nothing but trouble. in my vc 6 i had a piece of code that would put any text i passed into a ostrstrea object(which in 2005 now is ostringstream) and it was stored into a char buffer which i would pass the buffer off to the setwindowtext function of a cedit control and it would display any text in the buffer but after a few changes to allow my program to compile the text will not display and i am not quite sure why. i have the code set up to work as it did in vc 6 but i am not sure what changes were made that now causes it to fail in vc 8, if someone could help me figure out what might be wrong i would greatly appreciate it.

    C 1 Reply Last reply
    0
    • S swatgodjr

      just recently got visual studio 2005 and well to put a long story short it has been driving me crazy lol. but anyways i had to switch from using soem of the old libraries to usign the new ones and it has caused nothing but trouble. in my vc 6 i had a piece of code that would put any text i passed into a ostrstrea object(which in 2005 now is ostringstream) and it was stored into a char buffer which i would pass the buffer off to the setwindowtext function of a cedit control and it would display any text in the buffer but after a few changes to allow my program to compile the text will not display and i am not quite sure why. i have the code set up to work as it did in vc 6 but i am not sure what changes were made that now causes it to fail in vc 8, if someone could help me figure out what might be wrong i would greatly appreciate it.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      swatgodjr wrote:

      i passed into a ostrstrea object(which in 2005 now is ostringstream)

      I suspect this means you used to use strstream.h. The standard headers you're now using in VC2005 were there in VC6, but it's taken this long for the headers that are not part of standard C++ to be removed from the Microsoft compiler.

      swatgodjr wrote:

      but i am not sure what changes were made

      All the the changes made were to make the compiler more standards compliant, in other words, if your code had been legal C++, it would not have caused any problems.

      swatgodjr wrote:

      if someone could help me figure out what might be wrong i would greatly appreciate it.

      I'm more than happy to help. Not much I can do without seeing the code :-)

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      S 1 Reply Last reply
      0
      • C Christian Graus

        swatgodjr wrote:

        i passed into a ostrstrea object(which in 2005 now is ostringstream)

        I suspect this means you used to use strstream.h. The standard headers you're now using in VC2005 were there in VC6, but it's taken this long for the headers that are not part of standard C++ to be removed from the Microsoft compiler.

        swatgodjr wrote:

        but i am not sure what changes were made

        All the the changes made were to make the compiler more standards compliant, in other words, if your code had been legal C++, it would not have caused any problems.

        swatgodjr wrote:

        if someone could help me figure out what might be wrong i would greatly appreciate it.

        I'm more than happy to help. Not much I can do without seeing the code :-)

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        S Offline
        S Offline
        swatgodjr
        wrote on last edited by
        #3

        ok not a problem, i been constantly looking for ways to redo the code correctly but not much luck yet well heres the code to one part of my program: const int TEXT_SIZE = 5000; char szbuf[TEXT_SIZE]; std::ostringstream str(szbuf); void CHelpDialog::help_mes(char num[], bool cnt, char mess[]) { if(cnt == true) { str << " " << num << ". " << mess << "\r" << std::endl; } if(cnt == false) { str << " " << mess << "\r" << std::endl; } } BOOL CHelpDialog::OnInitDialog() { CEdit *pHelpText; pHelpText = (CEdit *) GetDlgItem(IDC_HELPTEXT); str.seekp(0); help_mes("1", true, "Everything entered in this program is case-sensitive so if"); help_mes("", false, "your program fails to load when you type in name of the plug"); help_mes("", false, "in to load, check if you spelled it correctly with the right"); help_mes("", false, "capitalization.\n"); help_mes("2", true, "If the program you enter fails to load, make sure you have the"); help_mes("", false, "required dll files needed for the program."); help_mes("3", true, "If there is any more bugs found than please contact me to let me"); help_mes("", false, "know. I can be reached at swatgod@gmail.com.\n"); pHelpText->SetWindowText(szbuf); memset(szbuf, 0, sizeof(szbuf)); return true; } that is all the code that basically deals with the problem area, any advice is very much appreciated :).

        C 1 Reply Last reply
        0
        • S swatgodjr

          ok not a problem, i been constantly looking for ways to redo the code correctly but not much luck yet well heres the code to one part of my program: const int TEXT_SIZE = 5000; char szbuf[TEXT_SIZE]; std::ostringstream str(szbuf); void CHelpDialog::help_mes(char num[], bool cnt, char mess[]) { if(cnt == true) { str << " " << num << ". " << mess << "\r" << std::endl; } if(cnt == false) { str << " " << mess << "\r" << std::endl; } } BOOL CHelpDialog::OnInitDialog() { CEdit *pHelpText; pHelpText = (CEdit *) GetDlgItem(IDC_HELPTEXT); str.seekp(0); help_mes("1", true, "Everything entered in this program is case-sensitive so if"); help_mes("", false, "your program fails to load when you type in name of the plug"); help_mes("", false, "in to load, check if you spelled it correctly with the right"); help_mes("", false, "capitalization.\n"); help_mes("2", true, "If the program you enter fails to load, make sure you have the"); help_mes("", false, "required dll files needed for the program."); help_mes("3", true, "If there is any more bugs found than please contact me to let me"); help_mes("", false, "know. I can be reached at swatgod@gmail.com.\n"); pHelpText->SetWindowText(szbuf); memset(szbuf, 0, sizeof(szbuf)); return true; } that is all the code that basically deals with the problem area, any advice is very much appreciated :).

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I'd replace it all with the following: BOOL CHelpDialog::OnInitDialog() { std::ostringstream str(); str << "enter your text here, the helper function doesn't seem that useful to me"; CEdit *pHelpText; pHelpText = (CEdit *) GetDlgItem(IDC_HELPTEXT); pHelpText->SetWindowText(str.str().c_str()); return true; } Why are you putting \r AND std::endl ? If you must have the helper fumction, I'd use a conditional operator, as in str << " " << ((cnt) ? num : mess) << std::endl; Although as it stands you pass two char arrays each time, and each time use only one, which seems kind of redundant.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          S 1 Reply Last reply
          0
          • C Christian Graus

            I'd replace it all with the following: BOOL CHelpDialog::OnInitDialog() { std::ostringstream str(); str << "enter your text here, the helper function doesn't seem that useful to me"; CEdit *pHelpText; pHelpText = (CEdit *) GetDlgItem(IDC_HELPTEXT); pHelpText->SetWindowText(str.str().c_str()); return true; } Why are you putting \r AND std::endl ? If you must have the helper fumction, I'd use a conditional operator, as in str << " " << ((cnt) ? num : mess) << std::endl; Although as it stands you pass two char arrays each time, and each time use only one, which seems kind of redundant.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            S Offline
            S Offline
            swatgodjr
            wrote on last edited by
            #5

            umm i just noticed something rather interesting. your code works perfectly and yet when i made the small change that you had made i still get no text and i think now i understand why that is. but also i have a function like that since i once had this program being used in a console app and in that version separated a lot of my most common chunks of code into a separate dll that i used in multiple programs and just have not gotten around to redoing the same process in my gui apps. and i also use /r and endl because if i don't it will not terminate and drop other pieces of text to another line with how i was doing text in my cedit boxes in my program.

            C 1 Reply Last reply
            0
            • S swatgodjr

              umm i just noticed something rather interesting. your code works perfectly and yet when i made the small change that you had made i still get no text and i think now i understand why that is. but also i have a function like that since i once had this program being used in a console app and in that version separated a lot of my most common chunks of code into a separate dll that i used in multiple programs and just have not gotten around to redoing the same process in my gui apps. and i also use /r and endl because if i don't it will not terminate and drop other pieces of text to another line with how i was doing text in my cedit boxes in my program.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              OK, so your own code requires the \r and ignores somehow the \r\n being put in by std::endl ? Either way, your problem is solved then ?

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

              S 1 Reply Last reply
              0
              • C Christian Graus

                OK, so your own code requires the \r and ignores somehow the \r\n being put in by std::endl ? Either way, your problem is solved then ?

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                S Offline
                S Offline
                swatgodjr
                wrote on last edited by
                #7

                yes, thanks to your help it is fixed. thank you for the help.

                C 1 Reply Last reply
                0
                • S swatgodjr

                  yes, thanks to your help it is fixed. thank you for the help.

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  no worries - just wanted to make sure we'd solved it :-)

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                  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