|
Thank you earl!
regards,
George
|
|
|
|
|
Hi,
I have declared an integer type variable for an edit box.My requirement is I want the edit box to be left blank i.e there should be no "0" when it is displayed.How can this be done?
Thanks in advance
Sandhya
|
|
|
|
|
Before showing the Edit Control set its window text to null.
that is, if you are using dialog based application then in OnInitDialog() use the below statement;
GetDlgItem(EditCtrlID)->SetWindowText("");
or
if you have a control variable say m_editctrl then
m_editctrl.SetWindowText("");
Do your Duty and Don't expect the Result
|
|
|
|
|
SetDlgItemText (IDC_MYEDIT,"");
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
i forget the SetDlgItemText(..).
This will be more appropriate than SetWindowText():->
Do your Duty and Don't expect the Result
|
|
|
|
|
SetWindowText() is still good . dont worry .
|
|
|
|
|
Hi,
Please can u say How can we convert CString variable to char data type.
Thanks in advance,
tejaswini
|
|
|
|
|
<br />
char myCharVar[20];<br />
CString myStrVar;<br />
<br />
myStrVar = "This will be copied";<br />
myCharVar = myStrVar.GetBuffer(myStrVar.GetLength());<br />
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
if your application is not based on _UNICODE text then you can use CString.GetBuffer(). this will return the starting address of the string.
other wise store this CString value in stl string, and covert as mentioned
#include string //use angular brackets
using namespace std;
CString str;
string strTemp((LPCTSTR)str);
char szValue[..] = {0};
strcpy(szValue, strTemp.c_str());
Do your Duty and Don't expect the Result
-- modified at 5:55 Monday 17th July, 2006
|
|
|
|
|
Parthi_appu wrote: strcpy(szValue, strTemp.c_str());
This is hardly necessary. Use:
strcpy(szValue, str);
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I think you have some member function like operator LPCTSTR() which returns const char *.
modified : which is a member function of CString class.
Regards
Abhishake Lahare
-- modified at 5:52 Monday 17th July, 2006
|
|
|
|
|
LPCTSTR() will return const TCHAR*.
if the application is UNICODE based then TCHAR* will be WCHAR*
Do your Duty and Don't expect the Result
|
|
|
|
|
tejaswini.g wrote: CString variable to char data type.
First of All, Char or Char*......?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Or see here
<br />
char *test;<br />
CString String;<br />
<br />
String="This is a test";<br />
test = new char[String.GetLength() + 1];<br />
strcpy(test , String); <br />
<br />
whitesky
|
|
|
|
|
Hi Whitesky
In the sample also mention the delete statement, it'll be useful to new C++ programmers.
Do your Duty and Don't expect the Result
|
|
|
|
|
One of the major selling points of using CString is so that new and delete won't have to be used. Some folks still continue to use/suggest them, however.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i mentioned it for char*, not for CString..
and personally i have bad experience while using CString..
so i'm avoiding CString class nowdays
Do your Duty and Don't expect the Result
|
|
|
|
|
Parthi_appu wrote: i mentioned it for char*, not for CString..
But it was in response to a post that was using CString . I was merely pointing out that new and delete are not necessary in that context.
Parthi_appu wrote: and personally i have bad experience while using CString..
so i'm avoiding CString class nowdays
Such as? I've been using it for 13+ years and have had no complaints with it. If used incorrectly, it could very well misbehave.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
that post contains the code..
char *test;
...
test = new char[String.GetLength()+1];
....
see the post which i replied for...
CString class works badly in some times, say GetLength() returns 0 if it has some string and IsEmpty() return TRUE if it has some string..
and using CString class is not that much difficult to misuse it...
Do your Duty and Don't expect the Result
|
|
|
|
|
Parthi_appu wrote: GetLength() returns 0 if it has some string and IsEmpty() return TRUE if it has some string..
I've never seen CString::GetLength() return 0 or CString::IsEmpty() return TRUE if the object was indeed non-empty. I just don't see it happening.
Parthi_appu wrote: CString class is not that much difficult to misuse it...
Anything for which you are not familar can be misused. With the exposure that CString has received since its incepton, to say it doesn't work in such trivial scenarios is just silly thinking.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
so u accept that i was not ask to delete the CString object..
surely CString will give problem while it was used in global thread methods...
i faced the above mentioned problems...
and also MSDN suggest to use ReleaseBuffer() after the use of GetBuffer(), i faced some memory problem when i tried to release the buffer..
and don't reply that i have to use the methods properly.. if u never face the problem then fine but i faced this problem.. for this particular reason i replaced all the CString to string in my application... and the problem is intermitent so their will be no chance of error in the code...
Do your Duty and Don't expect the Result
|
|
|
|
|
Parthi_appu wrote: so u accept that i was not ask to delete the CString object..
How would I know whether or not you were asked to delete a CString object? I'm not a mind reader.
Parthi_appu wrote: surely CString will give problem while it was used in global thread methods...
CString does not advertise as being thread safe. To use it under that presumption is just asking for trouble.
Parthi_appu wrote: MSDN suggest to use ReleaseBuffer() after the use of GetBuffer(), i faced some memory problem when i tried to release the buffer..
Something else was surely awry (e.g., some other method used before ReleaseBuffer() was called).
Parthi_appu wrote: and don't reply that i have to use the methods properly..
Why would you think it is ok to use the class improperly?
Parthi_appu wrote: ...the problem is intermitent...
That alone should throw up all sorts of red flags.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi David,
i was in vacation...so i didn't reply to ur post..
You mentioned that CString selling point is, it doesn't need new or delete..
and still some folks are insisting to use delete....
for this post only i replied... you didn't see the previous post that has char*... ok lets leave that...
and i didn't know CString will give problems while using thread context... i have no memory of reading this in MSDN... so if you have any link related to this, please suggest me..
Do your Duty and Don't expect the Result
|
|
|
|
|
i need to run unzip command.
If there is any parameter for unzip, so that the specified folder( which doesnot existing ) for extracting the zip file is created while running the command???
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Hi,
Any body knows some thing about unzip command????????
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|