|
-
Oct 6th, 2002, 05:21 AM
#1
Thread Starter
PowerPoster
Adding Basic Controls
Sorry, but I'm a newby to C++, and I'm still trying to get a grip on the language.
I'm using Dev-C++.
I already have the code for creating a Window (Form), but now I need code to create the following.
Menu Items
RichTextbox or a plain old TextBox.
Command Buttons.
-
Oct 6th, 2002, 09:43 AM
#2
Monday Morning Lunatic
Learn the language. Then learn Windows programming.
Trust me
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 6th, 2002, 10:15 PM
#3
Thread Starter
PowerPoster

But I just want to make a basic text editor, and learn how everything works from there. 
What can I do instead then?
Make console programs?
-
Oct 6th, 2002, 11:28 PM
#4
Thread Starter
PowerPoster
While I'm here, what does cout mean? I know it lets your print text in a console app... also, do I have to end it with endl; ??
Thanks in Advance.
-
Oct 7th, 2002, 06:08 AM
#5
Monday Morning Lunatic
cout is a stream (look up iostreams in a C++ reference), attached to the "standard output" (normally prints to the terminal, but can be redirected to a file).
The << operator is overloaded to mean "insert this into the stream":puts "Hello" into the stream. However, that probably won't do much because of buffering, so we have endl, which first puts a newline, then flushes the output buffer to ensure it gets displayed. You should usually just use '\n' unless it *has* to be displayed right then, because it can be inefficient.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 7th, 2002, 09:13 AM
#6
The reason you shouldn't make a text editor and learn from there is that learning both C++ and the windows API at the same time will most likely be too much for you, unless you are an extremly fast learner.
cout is actually an instance of the class template basic_ostream<char, char_traits<char> >
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 7th, 2002, 10:16 PM
#7
Thread Starter
PowerPoster
Yeah... but... 
What can I do instead then?
I've been screwing around with some maths functions, but thats about it...
-
Oct 8th, 2002, 12:08 AM
#8
Thread Starter
PowerPoster
Whats wrong with this??
Code:
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
// Demonstrates declaration of a class and
// definition of an object of the class,
// for cout
class Programmer // declare the class object
{
public: // members which follow are public
int itsAge;
int SkillLevel;
void Joke();
};
void Programmer::Joke()
{
cout << "Joke.\n";
}
void main()
{
Programmer Pc_Madness;
Pc_Madness.itsAge = 16;
Pc_Madness.SkillLevel = 1;
// assign to the member variable
cout << "Pc_Madness is " ;
cout << Pc_Madness.itsAge << " years old.\n";
cout << "Pc_Madness's skill level is " ;
Pc_Madness.Joke();
cout << "asdasdasd" ;
getchar ();
return 0;
}
I'm having trouble getting the Pc_Madness.Joke bit to work...
-
Oct 8th, 2002, 12:21 AM
#9
Thread Starter
PowerPoster
Code:
#include <iostream.h>
#include <stdio.h>
class Programmer
{
public:
int itsAge;
int SkillLevel;
void Joke();
};
void Programmer::Joke()
{
cout << "Only Joking :).\n";
}
void main()
{
Programmer Pc_Madness;
Pc_Madness.itsAge = 16;
Pc_Madness.SkillLevel = 10;
cout << "Pc_Madness is " ;
cout << Pc_Madness.itsAge << " years old.\n" ;
cout << "Pc_Madness's skill level is " ;
cout << Pc_Madness.SkillLevel << " / 10 " << endl;
Pc_Madness.Joke();
getchar ();
return 0;
}

Cool
-
Oct 8th, 2002, 05:57 AM
#10
You are using the old style headers. For ANSI compatibility and in order to ensure youa apps will compile on future compilers use the new style headers that don't have a .h:
#include <iostream>
#include <cstdio>
using namespace std;
The C++ headers have the same name without the .h ending (iostream.h -> iostream). The C headers have the name prefixed with c and without the .h (stdio.h -> cstdio).
Not all C headers are wrapped this way. In case there is no wrapper you must still use the old style. (e.g. conio.h).
Headers that don't belong to the standard library never have wrappers (e.g. windows.h), except someone writes one (parksie once wrote a windows header, don't know if he finished it).
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|