// one time init
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = FSXModule::wndProcChildWindow; // static method
wcex.cbClsExtra = 0;
wcex.cbWndExtra = sizeof(long);
wcex.hInstance = FSXModule::_hInstance;
wcex.hIcon = LoadIcon(FSXModule::_hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
if (!RegisterClassEx(&wcex)) {
FSXModule::displayErrorMessageBox(_T("RegisterClassEx"));
}
// The parameters to CreateWindow explained:
// szWindowClass: the name of the application
// szTitle: the text that appears in the title bar
// WS_OVERLAPPEDWINDOW: the type of window to create
// CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
// 500, 100: initial size (width, length)
// hInstance: the first parameter from WinMain
HINSTANCE test = (HINSTANCE) GetWindowLong (FSXModule::_hFSXWindow, GWL_HINSTANCE); // see below, consistent?
HWND child;
child = CreateWindow(
// WS_EX_TOOLWINDOW,
szWindowClass,
_T("In FSX Win test"),
// WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER, // window invisible in background
// WS_CHILD | WS_VISIBLE, // window invisible in background
// WS_POPUPWINDOW | WS_VISIBLE, // window invisible in background
WS_OVERLAPPEDWINDOW, // window invisible in background
0,0, // CW_USEDEFAULT, CW_USEDEFAULT,
500, 100,
FSXModule::_hFSXWindow, // parent
NULL,
// (HMENU) 1, // child id!
FSXModule::_hInstance, // (HINSTANCE) GetWindowLong (FSXModule::_hFSXWindow, GWL_HINSTANCE),
NULL
);
// could we create the window?
FSXModule::_hModuleWindow = child;
if (FSXModule::_hModuleWindow) {
// the order here seems to be crucial
WNDPROC oldChildWndProc = (WNDPROC)SetWindowLong(FSXModule::_hFSXWindow, GWL_WNDPROC, (LONG)FSXModule::wndProcChildWindow);
SetParent(FSXModule::_hModuleWindow, FSXModule::_hFSXWindow);
} else {
FSXModule::displayErrorMessageBox(_T("CreateWindow"));
}