|
If you use standard I/O, fseek() and ftell() can help. Check this out.
Best,
Jun
|
|
|
|
|
Jun Du wrote: If you use standard I/O, fseek() and ftell() can help.
Which is not part of STL.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks guys for your prompt replies...
cheers
|
|
|
|
|
hi everybody.
i am writing a list like control for a big app.
an it is done using oop.i have created a window which creates buttons.the buttons are created while watching it using spy.but they are not visible.PLEASE HELP ME!and tell me what i haven't done.here is some parts of code:
void ECMLMItem::Create(int i,CWnd *pParent,CRect rect,CRect RcList)
{
CWnd::Create(0,"ECMLMItem",WS_BORDER|WS_VISIBLE|WS_CLIPCHILDREN,rect,pParent,LISTITEM+counter,0);
counter++;
obj[i] = new ECMLMObjects();
obj[i]->create(i,this,rect,RcList);
}
void ECMLMItem::CreateObject(CWnd *pParent,int i)
{
if(i<10)
{
rect.left=RcList.left+12;
rect.top=RcList.top+20*i+1;
rect.right=RcList.right-12;
rect.bottom=rect.top+20;
ECMLMItem::Create(i,pParent,rect,RcList);
}
}
void ECMLMObjects::create(int i,CWnd *pParent,CRect rect,CRect RcList)
{
int w;
w=RcList.Width()-20;
rect.left=RcList.left+12;
rect.top=RcList.top+20*i+5;
rect.right=rect.left+w*3/15-2;
rect.bottom=rect.top+20;
btn[i].Create("",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,rect,pParent,Button+i);
rect.left=RcList.left+w*3/15+15;
rect.top=RcList.top+20*i+5;
rect.right=rect.left+w*4/15-4;
rect.bottom=rect.top+20;
edt[i].Create(WS_VISIBLE|WS_CHILD,rect,pParent,editbox+i);
rect.left=RcList.left+w*7/15+15;
rect.top=RcList.top+20*i+5;
rect.right=RcList.right-12;
rect.bottom=rect.top+20;
name[i].Create("Hello",WS_VISIBLE,rect,pParent,statictext+i);
}
Sepehr_vision@yahoo.com
|
|
|
|
|
sepehr_vision wrote: and tell me what i haven't done
People here probably only can tell what have been done wrong (if you are lucky). Post specific questions. More specific the question, easier for you to get an answer.
Best,
Jun
|
|
|
|
|
sepehr_vision wrote: ECMLMObjects::create(int i,CWnd *pParent,CRect rect,CRect RcList)
reading this long code oh no no
but if you are creating a child in above given line
then please add WS_CHILD style at
name[i].Create("Hello"/*name*/,WS_VISIBLE|WS_CHILD,rect,pParent,statictext+i);
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
hi,
when I put this
Cstring rvalue
switch (rvalue)
{
case "0": AfxMessageBox("Communication error");
break;
case "Z":AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
an error message is shown:
the expression associate to case is not a constant
how can i make it constant
|
|
|
|
|
That's not the way to work with string. You should do something like that:
if (rvalue == "0")
AfxMessageBox("Communication error");
else if (rvalue == "1")
AfxMessageBox("Sucess");
else
AfxMessageBox("rien");
Note that you can do something like rvalue == "1" only because CString overloaded the operator ==.
|
|
|
|
|
thanks a lot it is running !
|
|
|
|
|
zizzzz wrote: switch (rvalue)
u cannot specify a cstring variable in the switch condition. but u can do like this
switch(rvalue[0])// this will conside only the first character in the variable rvalue
{
case "0": AfxMessageBox("Communication error");
break;
case "Z":AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
}
nave
|
|
|
|
|
Naveen R wrote: switch(rvalue[0])// this will conside only the first character in the variable rvalue
{
case "0": AfxMessageBox("Communication error");
break;
case "Z":AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
}
I think you meant:
switch(rvalue[0])
{
case '0': AfxMessageBox("Communication error");
break;
case 'Z':AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
ya..
thanks for pointing...
nave
|
|
|
|
|
zizzzz wrote: Cstring rvalue
switch (rvalue)
{
You cannot create a switch statement using strings. You need to do if-else if-else for this.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Have you tried:
switch((LPCTSTR)rvalue)
{
}
or
switch(rvalue.GetBuffer(rvalue.GetLength()))
{
}
Best,
Jun
|
|
|
|
|
This will only compare the value of the pointer, not the contents of the string. Thus it won't work at all (even if this compiles fine).
|
|
|
|
|
Jun Du wrote: switch((LPCTSTR)rvalue)
{
//blablabla...
}
Bad!
Jun Du wrote: switch(rvalue.GetBuffer(rvalue.GetLength()))
{
//blablabla...
}
WORSE!!!!
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I seem to remember that I could get something similar to work. Probably I am completely wrong here. Everybody says we cannot directly use CString in switch. Thank Cedric and Zac for pointing this out.
Best,
Jun
|
|
|
|
|
can you verify with me this syntax
if (rvalue=="0")AfxMessageBox("Communication Error");
else if (rvalue=="A")AfxMessageBox("Checksum Error");
else if (rvalue=="H")AfxMessageBox("Data Length Error");
else m_baud.AddString(rvalue);
is it correct?
zzzzzzzz
|
|
|
|
|
|
It is correct, though I loathe that formatting
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Ahh come on, Zac. You know how the compiler hates messing with all of those superfluous spaces and carriage returns! They need to be removed for better performance.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm just waiting for someone to post code like this:
if (rvalue=="0")AfxMessageBox("Communication Error");else if (rvalue=="A")AfxMessageBox("Checksum Error");else if (rvalue=="H")AfxMessageBox("Data Length Error");else m_baud.AddString(rvalue);
And ask for help finding problems with it ...
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I wish you had waited instead of posting it yourself
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
zizzzz wrote: Cstring rvalue
switch (rvalue)
This won't work unless rvalue is an integral type or of a class type for which there is an unambiguous conversion to integral type.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
case uses ordinal values, try a single character from the string such as '0', 'Z' etc..
Elaine
|
|
|
|