Results 1 to 10 of 10

Thread: Adding Basic Controls

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    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.
    Don't Rate my posts.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765


    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?
    Don't Rate my posts.

  4. #4

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    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.
    Don't Rate my posts.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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":
    Code:
    cout << "Hello";
    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

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  7. #7

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Yeah... but...

    What can I do instead then?

    I've been screwing around with some maths functions, but thats about it...
    Don't Rate my posts.

  8. #8

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    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...
    Don't Rate my posts.

  9. #9

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    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
    Don't Rate my posts.

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width