|
Use like this,
atoi((const char*)(str.GetBuffer()));
Regards,
Paresh.
|
|
|
|
|
But why we must be use of this code while we have a simple way to use with a line?
|
|
|
|
|
And I forogot a thing when you use of this function you must be use ReleaseBuffer(),so your code will be like this:
CString strVal;
EditBoxVar.GetWindowText(strVal);
atoi((const char*)(str.GetBuffer()));
strVal.ReleaseBuffer();
While you can use of
a=GetDlgItemInt(IDC_EDIT1);
But anyway I give you 4 vote for your time that you spend for read this reply and answered to Mohanraj D.
|
|
|
|
|
Hamid. wrote: atoi((const char*)(str.GetBuffer()));
for const TCHAR, you dont need CString::GetBuffer it supports LPCTSTR typecast.
and i don't prefer c-style cast of (const char*) because if it UNICODE build, (const char*) will still typecast wide char to char.
|
|
|
|
|
Paresh Chitte wrote: str.GetBuffer()
Never use GetBuffer without knowing exactly what it does. Please check the documentation of this function and you'll see that it is wrong.
Furthermore, the CString class has an LPTSTR operator so, calling GetBuffer is totally useless.
|
|
|
|
|
Sorry Mark and CPallini, No GetBuffer() here.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
OP provided code [^] is actually a old gold days' sample of exotic GetBuffer usage, a real gem for me and Mark. Thank you for highlighting.
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
|
|
|
|
|
Paresh Chitte wrote: atoi((const char*)(str.GetBuffer()));
Are you kidding?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Mohanraj D wrote: editbox.GetWindowTextW(str);
editbox.GetWindowText(str);
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
guys,
i get some porblem. i degine a graph region and i have drawn some grids with the following codes.
BOOL CUserInterfaceDlg::PlotGrid(void)
{
int i;
GraphRegion->SelectObject(Brush);
GraphRegion->SelectObject(PenGrid);
GraphRegion->FillRect(&GraphRect,&Brush);
for (i=1;i<(GraphRect.Width()/2);i++)
{
GraphRegion->MoveTo(i*((double)GraphRect.Width()/30),0);
GraphRegion->LineTo(i*((double)GraphRect.Width()/30),GraphRect.Height());
}
for (i = 1;i<(GraphRect.Height()/2);i++)
{
GraphRegion->MoveTo(0,GraphRect.Height()-i*((double)GraphRect.Height()/30));
GraphRegion->LineTo(GraphRect.Width(),GraphRect.Height()-i*((double)GraphRect.Height()/30));
}
return 0;
}
then i tried to draw another line on the grid by the following codes:
BOOL CUserInterfaceDlg::PlotRunWay(void)
{
UpdateData(TRUE);
GraphRegion->SelectObject(PenRunWay);
RXArray[0]=m_AirXPisition;
RYArray[0]=m_AirYPosition;
RPoints[0].x=RXArray[0];
RPoints[0].y=RYArray[0];
RPoints[1].x=RPoints[0].x+30000;
RPoints[1].y=RPoints[0].y+200;
GraphRegion->MoveTo(RPoints[0]);
GraphRegion->LineTo(RPoints[1]);
return 0;
}
but this is not working. it just drawing the grid lines. can anyone tell me why it happening.
thanking you all,
shohel
|
|
|
|
|
shohel899 wrote:
BOOL CUserInterfaceDlg::PlotRunWay(void)
{
UpdateData(TRUE);
GraphRegion->SelectObject(PenRunWay);
RXArray[0]=m_AirXPisition ;
RYArray[0]=m_AirYPosition;
....
....
Is that typo only here? Or in your programm too? (It looks like you copy-pasted the code snippet so check it in your app)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
how i can compare between tow programs (symantc)?
if there is any code(reuseable) help me ..
please
|
|
|
|
|
Please give your messages an appropriate title. This is the second time you have used "please help me." Read the forum guidelines for further information.
|
|
|
|
|
|
two simple program
i want compare between these two programs (in syntx and semantic)
in syntx ok easy
but in symantic , i don't know what can i do?
is there standard codes in this topic can help me?
thank you very much
|
|
|
|
|
Please see point no. 2 and 3 in this[^] post.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
sofia_111 wrote: how i can compare between tow programs (symantc)?
Reminds me of the signature:
There are 10 kinds of people in the world: those that understand binary, and those that don't.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi ,
pls suggest me "THE BEST " book for mastering
i)c
ii)c++
thanks
|
|
|
|
|
|
Sorry,
I am sure I should stated how I declared my variables (just a quick finger)
char *my_ptr;
char *my_ptr1;
CONTEXT c;
I tried defining the variables both locally whitin the function and globally outside of the function with the same result
thankx again
|
|
|
|
|
ForNow wrote: I am sure I should stated how I declared my variables (just a quick finger)
do you know the modify option for your previous message.
|
|
|
|
|
I just looked at the previous message don't see any way to modify/edit it once it has been sent
|
|
|
|
|
Hi,
Dont know why but the Visual C compiler is not generating any code for the following
using Visual Studio 2008 Pro
c.ContextFlags = (CONTEXT_FULL | CONTEXT_CONTROL); <-- no code
GetThreadContext(hThread,&c);
my_ptr = c.SegFs; // Fs pointst to TEB <-- No code
my_ptr = my_ptr + 0x2c; // point to ThreadArray sotrage
(DWORD)my_ptr1 = *my_ptr; // point to first slot <-- No code
I move the code to some other soruce/DLL and did generate code for the statements in question
I tempted to go into _asm mode
thankx
|
|
|
|
|
ForNow wrote: is not generating any code for the following
just curious how do you verified. For Release mode I Assume.
ForNow wrote: (DWORD)my_ptr1 = *my_ptr; // point to first slot <-- No code
Unreference variable my_ptr1, no use generating code. And just curious how do you able to compiled that statement.
ForNow wrote: c.ContextFlags = (CONTEXT_FULL | CONTEXT_CONTROL); <-- no code
constant data, try assigning variable data.
ForNow wrote: my_ptr = c.SegFs; // Fs pointst to TEB <-- No code
my_ptr = my_ptr + 0x2c; // point to ThreadArray sotrage
(DWORD)my_ptr1 = *my_ptr; // point to first slot <-- No code
compiler optimises to use (address of c + SegFs member offset + 0x2c). I think it is safe to use this without asm.
modified on Monday, May 19, 2008 3:50 AM
|
|
|
|
|
Thankx
thats it just ran Debug mode and it worked
|
|
|
|