Thread: Win32Control design concern

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    903

    Win32Control design concern

    Hello. I currently have an idea of a program I'd like to make for myself (and hell, maybe for everyone) and I want to make a wrapper around the Win32 API to make things a tad easier for the GUI (I don't want to make it dialog-based nor do I want to use any other API). I just want to know your opinion on what I have right now. I have no idea why but it just looks plain wrong to me... It looks way too simple yet I don't know what I am missing. Of course, this is only an abstract class and there are many others to come... Yet if I screw up on the base class, chances are that all other derived classes will be screwed up as well.

    Here's the header file for my Win32Control class. I won't post the implementation file unless asked because I feel it would be useless as my question lies more on the design than on the implementation of the methods.


    Edit:

    I have worked a bit on my project and modified it so that it will work better with controls I will create from scratch. I'm also posting an example of derived class from my base class Control.

    Code:
    //===============================================
    //
    // Author: Alexandre P. L.
    // Created: December 4th 07
    // File: control.h
    // Contact: <removed for privacy>
    //
    //===============================================
    
    
    #ifndef CONTROL_H_INCLUDED
    #define CONTROL_H_INCLUDED
    
    
    #include "control_utilities.h"
    #include <windows.h>
    #include <string>
    #include <vector>
    #include <algorithm>
    
    
    //===============================================
    //
    //                class Control
    //
    //                 DECLARATION
    //
    //===============================================
    
    
    class Control
    {
    public:
        Control();
        ~Control();
    
        virtual void Update() = 0;
    
        //
        // Static methods
        //
    
        static void UpdateControls();
        static void RemoveControl(Control* ctrl);
    
        //
        // Action methods
        //
    
        virtual void EnableControl(bool enable) = 0;
        virtual void ShowControl(bool show) = 0;
    
        //
        // "Set" methods
        //
    
        virtual void SetCaption(const std::string& txt) = 0;
        virtual void SetSize(u_int cx, u_int cy) = 0;
        virtual void SetPosition(u_int cx, u_int cy) = 0;
        virtual void SetPosition(const Position& obj_pos) = 0;
    
        //
        // "Is" methods
        //
    
        virtual bool IsControlEnabled() const = 0;
        virtual bool IsControlVisible() const = 0;
    
    protected:
        Position position;
        std::string caption;
    
    private:
        static std::vector<Control*> ctrl_list;
    };
    
    
    #endif // CONTROL_H_INCLUDED
    Code:
    //===============================================
    //
    // Author: Alexandre Prince-Levasseur
    // Created: December 4th 07
    // File: win32control.h
    // Contact: [email protected]
    //
    //===============================================
    
    
    #ifndef WIN32CONTROL_H_INCLUDED
    #define WIN32CONTROL_H_INCLUDED
    
    
    #include "control_utilities.h"
    #include <windows.h>
    #include <string>
    #include <vector>
    
    
    //===============================================
    //
    //              class Win32Control
    //
    //                 DECLARATION
    //
    //===============================================
    
    
    class Win32Control
    {
    public:
        virtual void Update() = 0;
    
        //
        // Action methods
        //
    
        void EnableControl(bool enable);
        void ShowControl(bool show);
    
        //
        // "Set" methods
        //
    
        void SetCaption(const std::string& txt);
        void SetSize(u_int cx, u_int cy);
        void SetPosition(u_int cx, u_int cy);
        void SetPosition(const Position& obj_pos);
    
        //
        // "Is" methods
        //
    
        bool IsControlEnabled() const;
        bool IsControlVisible() const;
    
    protected:
        std::string wnd_class;
    
    private:
        HWND ctrl_wnd;
    };
    
    
    #endif // WIN32CONTROL_H_INCLUDED
    I know it's quite a bit of code to post on a forum but I'd appreciate so much comments on the overall design and suggestions of improvements.
    Last edited by Desolation; 12-05-2007 at 11:46 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. any comments about a cache design?
    By George2 in forum C Programming
    Replies: 6
    Last Post: 09-14-2006, 12:53 PM
  2. Implementing Inheritence into your design
    By bobthebullet990 in forum C++ Programming
    Replies: 6
    Last Post: 08-05-2006, 04:40 PM
  3. Opinions on new site design
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 01-21-2005, 01:34 PM
  4. Cprog tutorial: Design Patterns
    By maes in forum C++ Programming
    Replies: 7
    Last Post: 10-11-2004, 01:41 AM