Thread: Control Classes

  1. #1
    Neandrake
    Guest

    Control Classes

    I'm making windows programs in Visual C++ and I'm only using the API. I had a couple questions about creating controls on the windows. I can make the controls, but I found it space consuming to use the code over and over again for each thing. Then I decided to make an include file with functions(it has been successful). But now someone has told me to use classes to make the controls. How can I make classes for controls used on a window? Should I make a base class for all controls, and then use inheritance to make a class for each control? I don't even know how to do that!!!! Help?!

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    go and read some tutorials on the web.

    www.cplusplus.com is a good place to start.... if you don't know about classes, pointers and polymorphism then you're going to struggle.. so read up and give it a go.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    control classes

    Why have you chose not use a windows programming library such as owl or MFC? These libraries are rich in control classes. There are edit controls, list controls, button controls and many others. The best part is that they have been tested and are commonly used.
    zMan

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Stick with the API. And C. Stick with C. It is what was meant to be

    --Garfield
    1978 Silver Anniversary Corvette

  5. #5
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    Well...you could probable try this...

    Code:
    class MyControl
    {
         public: 
                 HWND hwnd;
                 void Create(/*params*/)
                 {
                         hwnd = CreateWindow(/*params*/);
                 }
    }
    ....
    
    MyControl Edit1 = new MyControl();
    MyControl.Create(/*params*/);
    then if you needed the HWND for some reason you could always use MyControl.hwnd

    but then again I'm not sure if that's right...I've never used C++ before (just C) I'm getting all that from what I know about OO in C#

  6. #6
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Yes, but I can't see how that would make programming Windows easier. The parameters to the member function will still have to be extensive to specify for the "insides" of the member function. It will just be another class name to remember

    --Garfield
    1978 Silver Anniversary Corvette

  7. #7
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    The parameters to the member function will still have to be extensive to specify for the "insides" of the member function.
    C++ allows default arguments. Which can be useful for functions with lots of arguments that are nearly always the same every time you use the function.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  2. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 05:38 PM
  3. Questions on Classes
    By Weng in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2003, 06:49 AM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM