I am trying to declare a static class within a parent class and initialize it, but I seem to be getting all sorts of errors.
/* MainWindow.h */
class MainWindow
{
private:
static DWORD WINAPI threadproc(void* param);
static MainWindow *hWin;
};
/* MainWindow.cpp */
#include "MainWindow.h"
void MainWindow::on_pushButton_clicked()
{
HANDLE hThread = CreateThread(NULL, NULL, threadproc, (void*) this, NULL, NULL);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
DWORD WINAPI MainWindow::threadproc(void* param)
{
hWin = (MainWindow*) param;
//Be able to access stuff like hWin->run();
return 0;
}
I have tried using MainWindow::hWin = (MainWindow*) param; and MainWindow::hWin = new MainWindow((MainWindow*) param)); and many others, but none seem to work. What is the proper way to do this? Are there any resources anybody would recommend on this subject, I have been tangling with class problems for a few days now and am very frustrated.