CString Help ( Specifically Empty() && GetLength() )

CString Help ( Specifically Empty() && GetLength() )

Post by Carl » Wed, 16 May 2001 22:25:34



VC++ 6.0 Professional Edition
I've got a class that correctly reports the XOR value of a string.  I report
the XOR value of the string and also it's length.  lets say my string length
is 96 characters, shall we?  The program reports String Len =  96 and the
correct XOR value of the string I entered.

Then I clear the CString object via a 'Clear' button (I know it's lame, but
work with me here.):

 void CXor_ValuesDlg::OnClear()        // My clear button
{
 m_cCreateChkSum.EnableWindow( TRUE );
 m_sEvalString.Delete(0, m_sEvalString.GetLength());
 m_sEvalString.Empty();

 m_sResult.Delete(0, m_sResult.GetLength());
 m_sResult.Empty();

 m_iXorrec = 0;

 UpdateData( FALSE );

Quote:}

and enter the same string to analyze again (For giggles -- I could enter
anything but get similar results).

It reports the string length to be String Len =  '9696' with the correct XOR
value.  My length isn't being cleared properly.  I could also get '9636' if
my second string was 36 characters long.

And so on and so forth.  If I continue on I'll eventually get String Len =
96969696969696...

It correctly clears the contents of  m_sEvalString, I know, because I have a
check on the CreateChkSum Value button to ensure string length is not zero
(0) and if I don't enter anything, it tells me so (Only when I haven't
entered
any previous data.).

So, there you have it.  Could someone help me out, please?  This is my first
'real' Windows program (In that is does something _useful_ for me!).  I've
got one version that is pretty good, but, I'd like to 'enhance' it a little.
(Typical programmer, nothing is ever done.)

Thanks.

 
 
 

CString Help ( Specifically Empty() && GetLength() )

Post by Alex Blekhma » Thu, 17 May 2001 15:15:22



Quote:> VC++ 6.0 Professional Edition
> I've got a class that correctly reports the XOR value of a string.
I report
> the XOR value of the string and also it's length.  lets say my
string length
> is 96 characters, shall we?  The program reports String Len =  96
and the
> correct XOR value of the string I entered.

> Then I clear the CString object via a 'Clear' button (I know it's
lame, but
> work with me here.):

>  void CXor_ValuesDlg::OnClear()        // My clear button
> {
>  m_cCreateChkSum.EnableWindow( TRUE );
>  m_sEvalString.Delete(0, m_sEvalString.GetLength());
>  m_sEvalString.Empty();

>  m_sResult.Delete(0, m_sResult.GetLength());
>  m_sResult.Empty();

>  m_iXorrec = 0;

>  UpdateData( FALSE );
> }

> and enter the same string to analyze again (For giggles -- I could
enter
> anything but get similar results).

> It reports the string length to be String Len =  '9696' with the
correct XOR
> value.  My length isn't being cleared properly.  I could also get
'9636' if
> my second string was 36 characters long.

> And so on and so forth.  If I continue on I'll eventually get String
Len =
> 96969696969696...

> It correctly clears the contents of  m_sEvalString, I know, because
I have a
> check on the CreateChkSum Value button to ensure string length is
not zero
> (0) and if I don't enter anything, it tells me so (Only when I
haven't
> entered
> any previous data.).

> So, there you have it.  Could someone help me out, please?  This is
my first
> 'real' Windows program (In that is does something _useful_ for me!).
I've
> got one version that is pretty good, but, I'd like to 'enhance' it a
little.
> (Typical programmer, nothing is ever done.)

You don't need to call Delete() before Empty(). Calling Empty() is
enough to clean CString object. How do you fill the string?

 
 
 

1. книга c\с++

нужны
линки на subj
(не visual)по
программированию
сокетов и
для
написания
софта для tcp\ip
и вообще
для сети(!!!не
локально-вычислительных).
ответы
кидать на

2. Will CGI Work w/CGI?

3. учебник по с\с++

4. Local client Resolution

5. &&& Moles and Mazes &&&

6. No of companies with turnover > $10Mill

7. مثففشق

8. CDRW's with 1M or 2M Buffer and opinions

9. HELP: AttachThreadInput () && Keyboard && TListItem ???

10. 推荐一个C++论坛 (C++探路者) http://cpp.aosee.com/

11. CString Help (Specifically, string length)

12. MSDN&WIN95&MFC&BORLAND&DE

13. Meaning of HDN_DIVIDERDBLCLICKW & WM_KEYDOWN ((wParam == VK_ADD && GetKeyState(VK_CONTROL) & 0x80)???