|
I have an edit control working as a log, but when new text gets added to the control that makes the scrollbar active, it scrolls to the top so you can't see what has happened. Is it possible to set it to scroll to the bottom automatically, or is there a message you can send so it does it? I'm programming Win32 BTW.
Thanks all.
|
|
|
|
|
|
ifstream & operator >> (ifstream &ifs, const DownKind & d)
{
ifs >> d.m_strKind >> endl >> d.m_strPath >> endl >>
d.m_strSuffix >> d.m_id >> d.m_idParent >> d.m_lstSub.size()
>> endl;
return ifs;
}
ofstream & operator << (ofstream &ofs, const DownKind & d)
{
return ofs;
}
// class declare
#define DOWNKINDBASE DownKindBase
class DownKind : public DOWNKINDBASE {
public:
friend ifstream & operator >> (ifstream &ifs, const DownKind &d);
friend ofstream & operator << (ofstream &, const DownKind &);
DownKind() ;
DownKind(string, string, string, int idParent = -1);
virtual ~DownKind() { clear(); }
string getKindName();
void setKindName(string);
string getPath();
void setPath(string);
void setSuffix(string);
string getSuffix();
virtual void clone(DownKindBase *);
void load();
void save();
virtual void addChild(DownKindBase *);
DownKindBase *findByKind(string );
protected:
virtual void readFile(FILE *);
virtual void writeFile(FILE *);
virtual void clear();
virtual void setParentId(int);
virtual int getParentId();
private:
string m_strKind;
string m_strSuffix;
string m_strPath;
int m_idParent; // parent id
int m_id; // current id
list<downkindbase*> m_lstSub;
};
could u please tell me what's wrong with this code, don't laught at me.
|
|
|
|
|
|
and please either fix the email address in your account, or uncheck the setting saying you want to be sent an email copy of replies. It's annoying when they bounce.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
ttzzgg_80713 wrote:
don't laught at me.
I would hope that no-one would laugh at you, I've written far worse code than this, I promise you.
ttzzgg_80713 wrote:
ifs >> d.m_strKind >> endl >> d.m_strPath >> endl >>
d.m_strSuffix >> d.m_id >> d.m_idParent >> d.m_lstSub.size()
>> endl;
You should read my article on iostream inserters and extractors. There is a bit of stuff you should be doing and are not, but the main point here is that you keep using endl, which performs a flush as well as a newline. This is a big performance hit. Also, when I write stuff like this, I have no using statements, I always explcitly scope std:: for everything. The reason is, the code is designed to be included in other projects, and it's probable clients of this inserter will not look at the code, and will silently find stuff pulled into the global namespace. Yes, this is probably just for you ( or your teacher ), but it's good to establish good habits.
ttzzgg_80713 wrote:
private:
You need to make the operator a friend of this class, or provide get methods to get to the data. Again, my article on iostream inserters is the way to go.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
thanks for u reply, what a kindly person u are !.
i has already set operator function to the class's friend.
still has problem. and could u tell me where can u find u aritcle??.
thank u very much
|
|
|
|
|
Below is my queue, I'm having problems getting it to show values in the queue and the queue doesn't seem to like you adding other values to the queue after some have been deleted, can you help in this...?
Thanks Ian
#include<iostream.h><br />
class Queue<br />
{<br />
private:<br />
int data[10];
int length;<br />
int first;<br />
int last;<br />
public:<br />
Queue(int);<br />
void push(int);<br />
int pop();<br />
void show();<br />
<br />
};<br />
Queue::Queue(int len)<br />
{<br />
length=len;<br />
first=-1;<br />
last=-1;<br />
}<br />
<br />
int Queue::pop()<br />
{<br />
int deleted;<br />
if(first == -1) <br />
{<br />
return (0);<br />
}<br />
deleted=data[first]; <br />
if(first==last)<br />
{<br />
first=-1;<br />
last=-1;<br />
}<br />
else<br />
first++;<br />
return deleted;<br />
}<br />
<br />
<br />
int menu()<br />
{<br />
int choice = 0;<br />
cout<<"\n\n\t\t**MAIN MENU**";<br />
cout<<"\n\n\t1\tStudent number to join the queue";<br />
cout<<"\n\t2\tStudent seen (Remove from queue)";<br />
cout<<"\n\t3\tView the students in the queue";<br />
cout<<"\n\t4\tEXIT";<br />
cout<<"\n\n\tPlease enter your choice : ";<br />
cin>>choice;<br />
return choice;<br />
}<br />
<br />
void Queue::push(int out)<br />
{<br />
if(last == length - 1) <br />
{<br />
cout<<"\tSorry the queue is full, please wait";<br />
return;<br />
}<br />
if(first == -1)<br />
{<br />
first=0;<br />
}<br />
last=last+1;<br />
data[last]=out; <br />
return;<br />
}<br />
<br />
void Queue::show()<br />
{<br />
<br />
}<br />
<br />
void main()<br />
{<br />
<br />
int StudentID;<br />
int number;<br />
int option;<br />
cout<<"\n\n\tEnter the length of the Queue : ";<br />
cin>>number;<br />
while (number>10)<br />
{<br />
cout<<"\nMaximum length of queue is set to 10, try again: ";<br />
cin>>number;<br />
}<br />
Queue place(number);<br />
do<br />
{<br />
option = menu();<br />
switch(option)<br />
{<br />
case 1:<br />
<br />
cout<<"\n\t* * Valid student numbers between 1 and 500 only * *\n";<br />
cout<<"\nEnter the student number : ";<br />
cin>>StudentID;<br />
while (StudentID <1 || StudentID>500)<br />
{<br />
cout<<"Invalid entry try again";<br />
cin>>StudentID;<br />
}<br />
place.push(StudentID);<br />
cout<<"\n\tStudent number "<<StudentID<<" has been inserted into queue.";<br />
break;<br />
<br />
case 2:<br />
int StudentID;<br />
StudentID=place.pop();<br />
if(StudentID==0)<br />
{<br />
cout<<"\n\tSorry no students to see the queue is empty";<br />
}<br />
else<br />
{<br />
cout<<"\n\tStudent "<<StudentID<<" deleted from queue.";<br />
}<br />
break;<br />
case 3:<br />
break;<br />
case 4:<br />
{};<br />
break;<br />
default: cout<<"\nIncorrect entry, try again with 1,2,3 or 4.";<br />
}<br />
}<br />
while (option!=4);<br />
}
|
|
|
|
|