|
You can get a handle to it like this GetDlgItem(IDC_RADIO);
|
|
|
|
|
Tnanks!
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
|
there you go bastard ! ROTFL
|
|
|
|
|
Can someone provide some code that shows how to obtain a single character from a CString that could contain upwards of 1024 characters?
I've tried several methods, but none have worked.
Example:
CString str = _T("Can someone provide some code that shows how to obtain a single character from a CString that could contain upwards of 1024 characters? I've tried several methods, but none have worked.");
======================= end example ==========================
A C++ programming language novice, but striving to learn
|
|
|
|
|
TCHAR c = str.GetAt(0);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Whooaaa there cowboy...you did that without using GetBuffer()? Now you're just talkin' crazy
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
oh, sorry...
TCHAR a = *(str.GetBuffer(10)+5);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Ahhh...it's a thing of beauty!
That always makes me smile hehe
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark, Can you explain what you are talking about? Sounds like something I should already know; but I don't. What I am doing is reading back a CStdioFile that I have save data into (collected from User input in dialogs). Some of this data is float numbers, hence the need to check each character in the CString. I have to use atoi(char) to convert the character which doesn't accept a TCHAR.
A C++ programming language novice, but striving to learn
|
|
|
|
|
You can ignore this off topic discussion with cpallini...
It's a running joke about CString's overly misused GetBuffer() method
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
chrs[1] = _T("\0"); // must be NULL terminated!
I get this error: " error C2440: '=' : cannot convert from 'const char [2]' to 'TCHAR'"
any ideas why?
A C++ programming language novice, but striving to learn
|
|
|
|
|
I used the wrong quotes, sorry!
That should be single quotes for a single character...
chrs[1] = _T('\0'); // must be NULL terminated!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
I'm getting a compiler error C1001; even after commenting out all the new code in the function. I tried shutting down the switches as help suggest. That doesn't work either. Any ideas?
A C++ programming language novice, but striving to learn
|
|
|
|
|
What's the error and what's the code involved?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I solved the problem by deleting the debug obj file previously created. works now!
A C++ programming language novice, but striving to learn
|
|
|
|
|
I tried that. Here's my code:
TCHAR chr;
int ch = 0;
chr = str.GetAt(0);
ch += atoi(chr);// ERROR HERE: when I try to convert it to int using atoi(chr)
I get this error: "Error 1 error C2664: 'atoi' : cannot convert parameter 1 from 'TCHAR' to 'const char *' c:\users\larry a mills sr\documents\visual studio 2008\projects\logit\logit\editlog.cpp"
A C++ programming language novice, but striving to learn
|
|
|
|
|
atoi() takes a const char * as an argument, not a TCHAR.
What are you trying to do? Convert the TCHAR you extracted to an int?
If so, you should be using generic text mapped functions, not functions like
atoi() that only work with one character type.
Generic text mapped functions will work for Unicode or non-Unicode builds.
In a Unicode build, a TCHAR is a wchar_t
In a non-Unicode build, a TCHAR is a char
Generic-Text Mappings in Tchar.h[^]
CString is also a generic text class by the way - it's internal character type is based on the Unicode build setting.
Also, you need to pass the correct type of argument to functions.
Maybe something like this:
TCHAR chrs[2];
int ch = 0;
chrs[0] = str.GetAt(0);
chrs[1] = _T("\0");
ch += _tstoi(chrs);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark.
You learn new stuff everyday if you just try.!
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: You learn new stuff everyday
It will be a sad day when I don't
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark, what about
int ch = str.GetAt(0) - _T('0');
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Can anyone help me get on the right track with this program. I am having a hell of a time with this. I have to use De Morgans Law to show the original expression and the new expression:
a) ! ( x < 5 ) && ! ( y >= 7)
b) ! ( a == b ) || ! ( g != 5)
c) ! ( (x <= 8 ) && ( y > 4 ) )
d) ! ( (i > 4 ) || ( j <= 6 ) )
I know how to put it into De Morgans Law I just don't understand how to put it into a source code in C++
|
|
|
|
|
Please look at my code given below.
I am trying to download the one folder from one site using FTP
I have written the code for Download directory which calls itself recursivly and I am closing and opening the connetion eac time.
But the problem is it downloads only first two folders completly but it could not find the third folder or file though it is there.
FindNextFile function returns false after downloading second folder.
Please help me for this..
Here is the code for Download Directory
BOOL CFTPUpDwnldManager::DownloadDirectory(CString strSrcDirPth,
CString strTrgfDirPath)
{
BOOL bRetVal = FALSE;
theApp.WriteFTPlog("Src Directory:" + strSrcDirPth);
theApp.WriteFTPlog("Trg Directory:" + strTrgfDirPath);
if(strSrcDirPth.IsEmpty() || strTrgfDirPath.IsEmpty())
{
return bRetVal;
}
// assum that *.* is not apped in src and trg path
CString strSrcDirPth1 = strSrcDirPth;
int index = strSrcDirPth1.ReverseFind('//');
int indx= strSrcDirPth1.GetLength() - index;
CString strSrcDirPth2 = strSrcDirPth1.Right(indx);
CString RemoteDir=strSrcDirPth;
CString dirpath=strTrgfDirPath + strSrcDirPth2;
CreateDirectory(dirpath,NULL);
CString LocalDir = dirpath;
CFTPUpDwnldManager *pCFTPUpDMngr = (CFTPUpDwnldManager *)lParam;
if(NULL == pCFTPUpDMngr)
{
return bRetVal;
}
CFTPManager *pFTPManager = (CFTPManager *)lParam;
if(NULL == pFTPManager)
{
return bRetVal;
}
CNSInternetSession* pInternetSession = pFTPManager->GetInternetSessionPtr();
if(NULL == pInternetSession)
{
return bRetVal;
}
pCFTPUpDMngr->CloseFTPConnection();
if(-1 == pCFTPUpDMngr->GetFTPConnection())
{
return bRetVal;
}
CFtpFileFind fileFind(pFtpConnection,0);
CString strFindFilePath = RemoteDir + "/*.*";
BOOL bContinue = fileFind.FindFile(strFindFilePath) ;
DWORD dw = GetLastError();
if (!bContinue)
{
// the directory is empty; just close up and return.
fileFind.Close();
return bRetVal;
}
while (bContinue)
{
bContinue = fileFind.FindNextFile();
DWORD dw = GetLastError();
CString tempDirName = fileFind.GetFileName();
CString tempDirPath = fileFind.GetFilePath();
CString tempFileUrl= fileFind.GetFileURL();
if(fileFind.IsDots())
{
continue;
}
if (fileFind.IsDirectory())
{
CString NewSrcDir = RemoteDir + "/" + tempDirName;
//CString NewTrgDIr = LocalDir + "/" + tempDirName;
CString NewTrgDir = LocalDir;
DownloadDirectory( NewSrcDir ,NewTrgDir );
}
else
{
DownloadFile( RemoteDir + "/" + tempDirName ,LocalDir + "/" + tempDirName );
}
}
bRetVal = TRUE;
return bRetVal;
}
|
|
|
|
|
|
hi all.
view does not repaint properly when the main frame window is resized
thanks in advance.
|
|
|
|