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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <windows.h>
#include "WinClass.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.



EDIT: Sorry, i just noticed that i might have posted this in the wrong location. If anyone can move it or something, that would be great.
Last edited on
nvm, my fault, i didnt read the question well enough
Last edited on
Hi, if at the top you click "Edit Topic" you can move the topic yourself.

To call a base class or member object's constructor, you use this syntax:
1
2
3
4
5
MyClass::MyClass(my, params) : MyClassMember(its, params), MyBaseClass(its, params)
{
    my;
    code;
}
Topic archived. No new replies allowed.