|
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
|
|
|
|
|
|
Hi,
I am trying to implement global hooks(as a DLL) to capture the Mouse and Windows related events happening on the desktop. I created a window and then set global hooks with the help of the following
SetWindowsHookEx( WH_CALLWNDPROC, (HOOKPROC) CallWndProc, hInst, 0);
SetWindowsHookEx( WH_GETMESSAGE, (HOOKPROC) GetMessageProc, hInst, 0);
I could Only get the Events associated with the window i created, but not the events associated with other Windows on the Desktop.
Am i missing something?
Please help me in fixing this.
Thanks,
Vissu.
|
|
|
|
|
Vissu89 wrote: SetWindowsHookEx( WH_CALLWNDPROC, (HOOKPROC) CallWndProc, hInst, 0);
can u show me how u took the hInst in the above call?
nave
|
|
|
|
|
The hInstance HANDLE from DLLMAIN is stored in hinst, which is used in setting system hook
BOOL WINAPI DllMain (HANDLE hInstance, ULONG ul_reason_for_call, LPVOID lpReserved)
{
// Save the instance handle
hInst = (HINSTANCE)hInstance;
}
Thanks,
Vissu
|
|
|
|
|
hi all,
I would like to set the width of an edit box according to the no of char allowed chars.
means-> user can only enter 5 char in the edit box. So i would like to set the width of an edit box which exactly holds 5 chars(no blank space).
So how can i draw edit box which holds exactly a specified no of chars?
can anyone help in this probs?
Thanks in advance.
Regards,
Ram
|
|
|
|
|
Try
BOOL MoveWindow( int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE )
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
You can use SetWindowPos(..),
if the editbox can have random string lengths then you have to calculate the size depending on the text selected.
if its going to be constant length then decide the size in design time itself.
An edit box can have more value than its width, if you want to restrict the string length to some constant value then setting the width won't work out
Do your Duty and Don't expect the Result
|
|
|
|
|
Ram Murali wrote: So i would like to set the width of an edit box which exactly holds 5
to calculate the rectangle required for a string to fit,use DrawText funtion with the DT_CALCRECT flag. this function will return the rectangle required by the string(Before calling this funtion don't forget to select the current edit box font to the DC). After u got the rectangle call the MoveWindow function to size the edit box.
nave
|
|
|
|
|
Hi,
I am working with edit boxes.I have declared a member variable for it with data type as "CString" .Is there any event which rises at the time when the edit box looses the focuses(for eg stating that the range is not between 100 and -100) or alternatively
I need some means to set the range for that edit box for which I have declared a variable of type "CString" . I will enter only numbers and not character type data.I will convert the entered data into integers later on.For the entered data I need to find whether it is in the range or not.
Thanks in advance
Taruni
|
|
|
|
|
|
I thing it is better to add control variable for Edit box
Instead of using CString as datatype, use CEdit.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
You can set Min value and Max value for your control(editbox)
whitesky
|
|
|
|