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.