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. Problem converting a CComBSTR to LPCTSTR with CW2CT

Problem converting a CComBSTR to LPCTSTR with CW2CT

Scheduled Pinned Locked Moved The Lounge
helpc++css
14 Posts 8 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.
  • J JC Gauthier

    I have a problem converting a CComBSTR to LPCTSTR with CW2CT. Eveything works fine until my CComBSTR gets around 64 caracters... then the result of the convertion is a long "corrupted" string: "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ" Please help me ! :(( ----- See comments between /* */ for more info ----- LRESULT CListBoxDlg::OnBnClickedBtngetselitems(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { LPCTSTR sTitle; // Message box title int arrSelList[12]; // Message buffer TCHAR pszBuf[128] = "";// Message buffer int iMaxNum = 12; // Max number of selected items LRESULT iSelCount = 0; // Total selected items in the list LPCTSTR sMsg = 0; // Message to put in the message box CComBSTR bsMessage; // Message accumulator iSelCount = this->SendDlgItemMessage(IDC_AVSCODES, LB_GETSELITEMS, WPARAM(iMaxNum), LPARAM(arrSelList)); if (iSelCount != LB_ERR) { bsMessage.Append("You have selected the fields: "); _stprintf(pszBuf, "%li", arrSelList[0]); bsMessage.Append(pszBuf); for (int i = 1; i < iSelCount; i++) { bsMessage.Append(", "); _stprintf(pszBuf, "%li", arrSelList[i]); bsMessage.Append(pszBuf); } bsMessage.Append("."); /* The following line will fails if bsMessage.m_str contains: "You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11." But will not fail if it bsMessage.m_str contains: "You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10." (4 caracter less) but long size is not suppose the cause problems with ATL 7.0 c

    L Offline
    L Offline
    lucy 0
    wrote on last edited by
    #2

    post it in VC++ forum and you will get answer.

    N 1 Reply Last reply
    0
    • L lucy 0

      I am sorry about my English. How could I phrase it milder and nicer?

      J Offline
      J Offline
      JC Gauthier
      wrote on last edited by
      #3

      oops sorry, I kinda didn't notice I was in the wrong forum :) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= JiCi - http://www.grandmenhir.com/

      1 Reply Last reply
      0
      • L lucy 0

        post it in VC++ forum and you will get answer.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #4

        That was a bit harse. Don't want to offend anyone. :)

        L C J 3 Replies Last reply
        0
        • N Not Active

          That was a bit harse. Don't want to offend anyone. :)

          L Offline
          L Offline
          lucy 0
          wrote on last edited by
          #5

          I am sorry about my English. How could I phrase it milder and nicer?

          J N 2 Replies Last reply
          0
          • L lucy 0

            I am sorry about my English. How could I phrase it milder and nicer?

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #6

            Your english is fine, my humor is not:((

            L 1 Reply Last reply
            0
            • N Not Active

              Your english is fine, my humor is not:((

              L Offline
              L Offline
              lucy 0
              wrote on last edited by
              #7

              not fine. Most of the time I cannot get the correct tone. Like when watching TV, cannot laugh when a joke was told. :-(

              S S S 3 Replies Last reply
              0
              • N Not Active

                That was a bit harse. Don't want to offend anyone. :)

                C Offline
                C Offline
                ColinDavies
                wrote on last edited by
                #8

                LOL :-) Nice one. Poor Lucy. Regardz Colin J Davies

                Sonork ID 100.9197:Colin

                More about me :-)

                1 Reply Last reply
                0
                • N Not Active

                  That was a bit harse. Don't want to offend anyone. :)

                  J Offline
                  J Offline
                  John Aldrich
                  wrote on last edited by
                  #9

                  Mark, No offense intended or anything, but are you naturally a prick or do you make a concious effort? ;P Can you imagine Darth Maul on speed?

                  N 1 Reply Last reply
                  0
                  • J John Aldrich

                    Mark, No offense intended or anything, but are you naturally a prick or do you make a concious effort? ;P Can you imagine Darth Maul on speed?

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #10

                    No I've developed a thick foreskin.

                    1 Reply Last reply
                    0
                    • L lucy 0

                      not fine. Most of the time I cannot get the correct tone. Like when watching TV, cannot laugh when a joke was told. :-(

                      S Offline
                      S Offline
                      Stuart van Weele
                      wrote on last edited by
                      #11

                      Try listening to a talk radio station. My wife, who came from Shanghai in her 20's, claims that listening to talk radio is the best way to really learn english, since it includes all of the slang. Of course being married to an Americian whose command of Chinese is limited to Ni Hou. also helps. :)

                      1 Reply Last reply
                      0
                      • L lucy 0

                        not fine. Most of the time I cannot get the correct tone. Like when watching TV, cannot laugh when a joke was told. :-(

                        S Offline
                        S Offline
                        Steve T
                        wrote on last edited by
                        #12

                        ...Most of the time I cannot get the correct tone. Like when watching TV, cannot laugh when a joke was told. Don't worry Lucy, if the comedy on TV up there in Canada is as bad here in the USA then the problem is the jokes ... not your sense of humor :) Steve T.

                        1 Reply Last reply
                        0
                        • L lucy 0

                          not fine. Most of the time I cannot get the correct tone. Like when watching TV, cannot laugh when a joke was told. :-(

                          S Offline
                          S Offline
                          Shog9 0
                          wrote on last edited by
                          #13

                          lucy wrote: Like when watching TV, cannot laugh when a joke was told. Many people have this problem, as it can take months for the casual viewer to memorize all the jokes on TV, and many are easy to forget. That's what laugh tracks are for. ;) --------

                          You can change the extention so it reads ASP even though it is PHP which is kind of cool. - Martin Marvinski

                          --Shog9 --

                          C 1 Reply Last reply
                          0
                          • S Shog9 0

                            lucy wrote: Like when watching TV, cannot laugh when a joke was told. Many people have this problem, as it can take months for the casual viewer to memorize all the jokes on TV, and many are easy to forget. That's what laugh tracks are for. ;) --------

                            You can change the extention so it reads ASP even though it is PHP which is kind of cool. - Martin Marvinski

                            --Shog9 --

                            C Offline
                            C Offline
                            ColinDavies
                            wrote on last edited by
                            #14

                            I don't know why they don't put up a laugh placard like they do for audiences on Shows like the "Letterman Show" that way people at home could join in. Regardz Colin J Davies

                            Sonork ID 100.9197:Colin

                            More about me :-)

                            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