I want to share value initialize from Application object to child without pass any parameter. ex, i need to pass mHInstance to Window, Button, Label class. How to do this?
Application->Widget->Window. Application->Widget->Button. Application->Widget->Label.
Header
#include <Windows.h>
class Application
{
protected:
HINSTANCE mHInstance;
public:
Application(HINSTANCE);
};
class Widget: public Application
{
protected:
HWND mHWnd;
public:
void show();
};
class Window: public Widget
{
public:
Window();
};
Implementations
Application::Application(HINSTANCE hInstance)
{
mHInstance = hInstance;
};
// Window implementations
Window::Window()
{
WNDCLASSEX wc = {0};
// Access application member that already initialize
wc.hInstance = mHInstance;
RegisterClassExW(&wc);
};
Main
#include <Windows.h>
#include "../headers/gui.h"
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR lpCmdLine, int nCmdShow) {
Application app(hInstance);
Window* wnd = new Window;
wnd->show();
return app.exec();
}