• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Discovering WPF and custom windows in FSX

The Simconnect calling code works inside the Form (Inside FSX)
I'm successfully subscribe to event "SimStart",
but it crashes when the event should be called....
 
That error could be just about anything from a stack overflow error, a weird threading error or a mistmatched DLL error (ie, wrong version of .NET running, meaning a manifest somewhere is broken). Welcome to the wonderful world of interop, simconnect and flight simulation :)

I would first make sure the code works outside of FSX (use your DLL from a standalone EXE, write a simple wrapper) so that will tell you for sure where the problem is.


Etienne
 
Thanks for help!

I didn't try to call my DLL from outside.
Also, created form works very slow.

Actualy I decided to switch off from .NET to Win32 C++ due to performence issues.

When FSX starts my DLL I want to create a child window and assign it to "FS98MAIN", how possible it is and what problems could be?
I also saw in this thread that some of you guys have a big progress in that, can I see some code?

Pavel
 
Last edited:
Window never on top

I am aware that this thread is somehow outdated, but maybe somebody is still around . The given information is very much related to my issue right now.

When I create a child window in a FSX module (.dll), the window is created but always hidden in background. I have tried several styles (as of the information above) - but never managed to get the window in front. I can see it, but only when resizing the parent. The wndProcChild callback is correctly called, so it seems to be attached to the FSX message loop.

Any ideas?


Code:
	// 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")); 
	}
 
Try to play with WS_POPUPWINDOW | WS_VISIBLE flags,
try to search kind of TOPMOSTY flag, actually I don't really remember how it was handeled.
 
Yep, I continue with trial and error. However, if someone can show how he has done it, it's still appreciated. :stirthepo
Thanks for your feedback.

-- Edit --
SetWindowPos(FSXModule::_hModuleWindow, HWND_TOP, x, y, w, h, SWP_DRAWFRAME | SWP_SHOWWINDOW);
as well as HWND_TOPMOST does not change anything at all
 
Last edited:
Back
Top