Loading ...
Sorry, an error occurred while loading the content.

RE: [wtl] ATL::CString doesn't have conversion operator for LPTSTR...

Expand Messages
  • Anna-Jayne Metcalfe
    Hi Richard, ... DDX_TEXT macro saying cannot convert parameter 2 from ATL::CString to LPTSTR . ... add a LPTSTR conversion operator is obviously not
    Message 1 of 5 , Jun 9, 2011
    • 0 Attachment
      Hi Richard,

      > While playing around with DDX and WTL, I got a compilation error for the
      DDX_TEXT macro saying "cannot convert parameter 2 from 'ATL::CString' to
      'LPTSTR'".

      > I would prefer to keep using ATL's CString, and modifying atlstr.h to
      add a LPTSTR conversion operator is obviously not ideal, so any ideas on
      how best to handle this ?

      I've not seen this with DDX.

      Without digging through the code I can't be sure, but surely with LPTSTR
      being a non-const type adding a conversion operator would be dangerous at
      best.

      operator LPCTSTR() is of course a different beast entirely. That's
      definitely there - I use it all the time.

      Or am I missing something? (possible - it's nearly midnight and I'm about to
      crash).


      Kind Regards,

                      Anna-Jayne Metcalfe
                      Product Manager,
                      Riverblade Limited

                      http://www.riverblade.co.uk


      Riverblade Limited, 3 Wellington Road, Bournemouth, Dorset BH8 8JQ, United
      Kingdom
      Registered in England no. 5187132. VAT Registration no. 847 0045 38
      Please direct general enquiries to enquiries@....

      ACCU 2012 - http://www.accu.org/conference - 24-28th April 2012, Oxford UK.
    • Richard B.
      You are right - it should be LPCTSTR. Problem solved - I was including atlstr.h after all other ATL/WTL includes. When I placed it earlier, after atlbase.h,
      Message 2 of 5 , Jun 9, 2011
      • 0 Attachment
        You are right - it should be LPCTSTR.

        Problem solved - I was including atlstr.h after all other ATL/WTL
        includes. When I placed it earlier, after atlbase.h, the compilation
        error disappeared.

        Best Regards,
        Richard B.

        On 09/06/2011 23:52, Anna-Jayne Metcalfe wrote:
        > Hi Richard,
        >
        > > While playing around with DDX and WTL, I got a compilation error for the
        > DDX_TEXT macro saying "cannot convert parameter 2 from 'ATL::CString' to
        > 'LPTSTR'".
        >
        > > I would prefer to keep using ATL's CString, and modifying atlstr.h to
        > add a LPTSTR conversion operator is obviously not ideal, so any ideas on
        > how best to handle this ?
        >
        > I've not seen this with DDX.
        >
        > Without digging through the code I can't be sure, but surely with LPTSTR
        > being a non-const type adding a conversion operator would be dangerous at
        > best.
        >
        > operator LPCTSTR() is of course a different beast entirely. That's
        > definitely there - I use it all the time.
        >
        > Or am I missing something? (possible - it's nearly midnight and I'm about to
        > crash).
        >
        > Kind Regards,
        >
        > Anna-Jayne Metcalfe
        > Product Manager,
        > Riverblade Limited
        >
        > http://www.riverblade.co.uk
        >
        > Riverblade Limited, 3 Wellington Road, Bournemouth, Dorset BH8 8JQ, United
        > Kingdom
        > Registered in England no. 5187132. VAT Registration no. 847 0045 38
        > Please direct general enquiries to enquiries@...
        > <mailto:enquiries%40riverblade.co.uk>.
        >
        > ACCU 2012 - http://www.accu.org/conference - 24-28th April 2012, Oxford UK.
        >
        >
      • Michael Stephenson
        As a note, the canonical way to convert a CString to an LPTSTR has been to double cast it via (LPTSTR)(LPCTSTR) or something similar using the C++-specific
        Message 3 of 5 , Jun 10, 2011
        • 0 Attachment
          As a note, the "canonical" way to convert a CString to an LPTSTR has been to
          double cast it via (LPTSTR)(LPCTSTR) or something similar using the
          C++-specific cast expressions.

          This should, of course, only be done if you are sure you are not going to
          alter the string.

          -----Original Message-----
          From: wtl@yahoogroups.com [mailto:wtl@yahoogroups.com] On Behalf Of Richard
          B.
          Sent: Thursday, June 09, 2011 7:35 PM
          To: wtl@yahoogroups.com
          Subject: Re: [wtl] ATL::CString doesn't have conversion operator for
          LPTSTR...

          You are right - it should be LPCTSTR.

          Problem solved - I was including atlstr.h after all other ATL/WTL includes.
          When I placed it earlier, after atlbase.h, the compilation error
          disappeared.

          Best Regards,
          Richard B.

          On 09/06/2011 23:52, Anna-Jayne Metcalfe wrote:
          > Hi Richard,
          >
          > > While playing around with DDX and WTL, I got a compilation error
          > for the DDX_TEXT macro saying "cannot convert parameter 2 from
          > 'ATL::CString' to 'LPTSTR'".
          >
          > > I would prefer to keep using ATL's CString, and modifying atlstr.h
          > to add a LPTSTR conversion operator is obviously not ideal, so any
          > ideas on how best to handle this ?
          >
          > I've not seen this with DDX.
          >
          > Without digging through the code I can't be sure, but surely with
          > LPTSTR being a non-const type adding a conversion operator would be
          > dangerous at best.
          >
          > operator LPCTSTR() is of course a different beast entirely. That's
          > definitely there - I use it all the time.
          >
          > Or am I missing something? (possible - it's nearly midnight and I'm
          > about to crash).
          >
          > Kind Regards,
          >
          > Anna-Jayne Metcalfe
          > Product Manager,
          > Riverblade Limited
          >
          > http://www.riverblade.co.uk
          >
          > Riverblade Limited, 3 Wellington Road, Bournemouth, Dorset BH8 8JQ,
          > United Kingdom Registered in England no. 5187132. VAT Registration no.
          > 847 0045 38 Please direct general enquiries to
          > enquiries@... <mailto:enquiries%40riverblade.co.uk>.
          >
          > ACCU 2012 - http://www.accu.org/conference - 24-28th April 2012, Oxford
          UK.
          >
          >


          ------------------------------------

          Yahoo! Groups Links
        • jack lin
          ________________________________ From: Michael Stephenson To: wtl@yahoogroups.com Sent: Fri, June 10, 2011 3:35:16 PM Subject: RE:
          Message 4 of 5 , Jun 27, 2011
          • 0 Attachment
            ________________________________
            From: Michael Stephenson <domehead100@...>
            To: wtl@yahoogroups.com
            Sent: Fri, June 10, 2011 3:35:16 PM
            Subject: RE: [wtl] ATL::CString doesn't have conversion operator for LPTSTR...

             
            As a note, the "canonical" way to convert a CString to an LPTSTR has been to
            double cast it via (LPTSTR)(LPCTSTR) or something similar using the
            C++-specific cast expressions.

            This should, of course, only be done if you are sure you are not going to
            alter the string.

            -----Original Message-----
            From: wtl@yahoogroups.com [mailto:wtl@yahoogroups.com] On Behalf Of Richard
            B.
            Sent: Thursday, June 09, 2011 7:35 PM
            To: wtl@yahoogroups.com
            Subject: Re: [wtl] ATL::CString doesn't have conversion operator for
            LPTSTR...

            You are right - it should be LPCTSTR.

            Problem solved - I was including atlstr.h after all other ATL/WTL includes.
            When I placed it earlier, after atlbase.h, the compilation error
            disappeared.

            Best Regards,
            Richard B.

            On 09/06/2011 23:52, Anna-Jayne Metcalfe wrote:
            > Hi Richard,
            >
            > > While playing around with DDX and WTL, I got a compilation error
            > for the DDX_TEXT macro saying "cannot convert parameter 2 from
            > 'ATL::CString' to 'LPTSTR'".
            >
            > > I would prefer to keep using ATL's CString, and modifying atlstr.h
            > to add a LPTSTR conversion operator is obviously not ideal, so any
            > ideas on how best to handle this ?
            >
            > I've not seen this with DDX.
            >
            > Without digging through the code I can't be sure, but surely with
            > LPTSTR being a non-const type adding a conversion operator would be
            > dangerous at best.
            >
            > operator LPCTSTR() is of course a different beast entirely. That's
            > definitely there - I use it all the time.
            >
            > Or am I missing something? (possible - it's nearly midnight and I'm
            > about to crash).
            >
            > Kind Regards,
            >
            > Anna-Jayne Metcalfe
            > Product Manager,
            > Riverblade Limited
            >
            > http://www.riverblade.co.uk
            >
            > Riverblade Limited, 3 Wellington Road, Bournemouth, Dorset BH8 8JQ,
            > United Kingdom Registered in England no. 5187132. VAT Registration no.
            > 847 0045 38 Please direct general enquiries to
            > enquiries@... <mailto:enquiries%40riverblade.co.uk>.
            >
            > ACCU 2012 - http://www.accu.org/conference - 24-28th April 2012, Oxford
            UK.
            >
            >

            ------------------------------------

            Yahoo! Groups Links




            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.