×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

CString text being hidden or truncated by a special character?

CString text being hidden or truncated by a special character?

CString text being hidden or truncated by a special character?

(OP)
I am accessing a MS Access database to get some information to show as a tooltip over a tree control.

There are 2 fields in particular that are causing some interesting effects on a CString variable.  The field types are (in Access) Currency, and Memo.  This issue only appears with these 2 fields.

Here is the code that has the issue:

CODE

CString strTemp;

// Plan Name
sTipText += _T(" Plan: ") + value;

// Minutes
cRS.GetFieldValue( (short)2, key );
strTemp.Format( _T("%d"), key.m_iVal );
key.Clear();
sTipText += _T("\r\n Minutes: ") + strTemp;
strTemp = _T("");

// Price
cRS.GetFieldValue( (short)3, strTemp );
strTemp.Replace(_T("00"), _T(""));
sTipText += _T("\r\n Price: ") + strTemp;
strTemp = _T("");

// Description
cRS.GetFieldValue( (short)4, strTemp );
strTemp.Replace(_T("&"), _T("and"));
sTipText += _T("\r\n Description: ") + strTemp;
strTemp = _T("");

data->SetToolTipString( sTipText );
CString sLength;
sLength.Format(_T("%d"), sTipText.GetLength() );
AfxMessageBox( sLength );
AfxMessageBox( sTipText );

An interesting thing happens when stepping through the code.  When setting the description, the line:

sTipText += _T("\r\n Description: ") + strTemp;

Does not appear to do anything.  On all other lines where sTipText gets concatenated with another string, it turns to red to show it's the value being worked with, however it doesn't on that line.  It's like that line is being ignored.

However, if I just add some generic text over those 4 lines, instead of the data from the database, there is no issue.

Are there non-printable characters that would prevent concatenation to a CString variable that might be in the data and I can't tell?

Anyone have any suggestions?

RE: CString text being hidden or truncated by a special character?

(OP)
I figured out the issue.

These fields were tacking on null termination characters at the end of the string.

I simply got a substring of the original string that didn't include those characters, and all worked smoothly.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close