|
-
March 22nd, 2012, 06:35 AM
#1
Class Constructor Parameters
Hi, im currently trying to design a level editor for a school project. Im using WinAPI code, and i'm havin trouble with the classes creating the base window. The constructor of the class thats creating the window needs a parameter, but sadly i don't exactly know what parameter to put in there. I probably need a reference to the class or an instance of the class that the creator class is inhereting from.
The header for the classes creating the window:
WinClass.h
Code:
#ifndef WINCLASS_H_INCLUDED
#define WINCLASS_H_INCLUDED
#include "WinProcedure.h"
#include <string>
class WinClassPara
{
public:
WinClassPara (HINSTANCE hInstance): hInst (hInstance){}
HINSTANCE GethInst () const { return hInst; }
char const * GetwcName () const {return wcName.c_str();}
protected:
HINSTANCE hInst;
std::string wcName;
};
class WinClassMain: public WinClassPara
{
public:
WinClassMain (HINSTANCE hInstance, WNDPROC WndProc);
void RegisterWin();
void DeclareWinProp();
protected:
WNDCLASSEX wc;
};
class WinCreator: public WinClassMain
{
public:
WinCreator(); //Here is the issue.
operator HWND () {return _hwnd;}
void CreateWin();
void ShowWin(int nShowWin = SW_SHOWNORMAL);
protected:
WinClassMain & wc;
HWND _hwnd;
DWORD ExStyle;
char const * WinName;
DWORD Style;
int xPos;
int yPos;
int cHeight;
int cWidth;
HWND WinOwn;
HMENU Menu;
void * Data;
};
#endif // WINCLASS_H_INCLUDED
The source code file:
WinClass.cpp
Code:
#include <windows.h>
#include "WinClass.h"
#include "Resources.h"
WinClassMain::WinClassMain(HINSTANCE hInstance, WNDPROC WndProc): WinClassPara (hInstance)
{
wc.lpfnWndProc = WndProc;
DeclareWinProp();
}
void WinClassMain::DeclareWinProp()
{
wc.lpszClassName = GetwcName();
wc.hInstance = GethInst ();
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.cbSize = sizeof(wc);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
}
void WinClassMain::RegisterWin()
{
RegisterClassEx(&wc);
}
// And also here, where i need the parameters again.
WinCreator::WinCreator ():_hwnd (0), wc (), ExStyle (0), WinName (0), Style (WS_OVERLAPPED), xPos (CW_USEDEFAULT), yPos (0), cHeight (CW_USEDEFAULT), cWidth (0), WinOwn (0), Menu (0), Data (0)
{
}
void WinCreator::CreateWin()
{
CreateWindowEx(ExStyle, GetwcName(), WinName, Style, xPos, yPos, cHeight, cWidth, WinOwn, Menu, GethInst (), Data);
}
void WinCreator::ShowWin(int nShowWin)
{
::ShowWindow (_hwnd, nShowWin);
::UpdateWindow (_hwnd);
}
The error recieved without any parameters (or with parameters that ive tested for that matter) is this: error: no matching function for call to 'WinClassMain::WinClassMain()'
I hope you can help me with this, i'm rather new at C++/winapi programming.
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
|