Jump to content
Sign in to follow this  
Guest ziporama

Creating a child window inside FS9/FSX

Recommended Posts

Guest ziporama

I'm trying to create a child window from a module dll inside FS9 or FSX.I've reached the point where I create the window using the normal APIs, making the main FS window (FS98MAIN) the owner. I can get it to be visible when it is first created, but it either flickers or doesn't repaint correctly, especially the moment another window is activate (example, panel, outside view). The window is there, receives messages, but just doesn't want to draw itself. Writing a modal dialog is working - it's the modeless window I'm having a problem with (ie, focus can change).I'm trying to find out how FSNavigator or other similar tools do it as that's working very well. There's a trick somewhere, and any hints on how to do this in FS9 or FSX would be appreciated.Regards,Etienne

Share this post


Link to post
Share on other sites
Guest kwiddler

I had some luck in this department, but then abandoned the approach in favor of C++ gauges, because then I could utilize built-in FSX abilities for transparency and alpha-blending.My old code is a mess right now (due to experimentation), but basically I used DllMain() to grab HINSTANCE, "FS98MAIN" to identify main window as parent, and then the key part: style WS_POPUP instead of WS_CHILD. When I first used the latter style, I had the same kind of trouble you describe. Then when I used (inter alia) WS_POPUP, I ended up with a window very much like the Kneeboard.If you need more details, I will go uncover my best working version and list the code here. I don't remember if the approach worked in full-screen mode, but I think it did.Kim

Share this post


Link to post
Share on other sites
Guest ziporama

I've tried the WS_POPUP style and the result is unfortunately the same, except the parent link is NULL in spy++.The window is there, just not steady. I'm wondering if I have the wrong parent.I'd love to see an example of what styles you had to get the window to show properly.Cheers,Etienne

Share this post


Link to post
Share on other sites
Guest kwiddler

Here's a bunch of code from my window experiment. All it proved to me was that it was possible to draw what I wanted in a traditional rectangular area, with "correct" behavior with respect to other windows, eg. redraw when obscured, main FSX scene correctly drawn underneath, etc. The main disadvantage is that it did not allow me control for drawing "transaparently". It was then that I dived into the panels/gauges method for FSX "windows", which was only partially successful as well. I'm continually on the lookout for FSX drawing tricks, beyond the XML gauges.Well, it's a royal mess, but feel free to email me at kwiddler@gmail.com for further info and discussion.Kim#include static int dllinit = 0;static HINSTANCE hi = NULL;extern "C" BOOL WINAPI DllMain( HINSTANCE h, DWORD f, LPVOID ) {return f==DLL_PROCESS_ATTACH?0:hi=h,dllinit=1;}#define FSX_WIN L"FS98MAIN"void InitWin( HINSTANCE hi ){ hw = FindWindowEx( NULL, NULL, FSX_WIN, NULL ); if (!hw) printf("ERROR: couldn't find main FSX windown"); HBRUSH hb = CreateSolidBrush(0x0000FF); HCURSOR hc = LoadCursor(NULL,IDC_ARROW); WNDCLASSEX wc ={sizeof(WNDCLASSEX),0,MainWndProc,0L,0L,hi,NULL,hc,hb,NULL,L"advclass",NULL}; if (!RegisterClassEx(&wc)) printf("ERROR: can't register window classn"); ha = CreateWindow( L"advclass",L"advwin", WS_POPUPWINDOW|WS_CAPTION|WS_DISABLED, //WS_POPUP|WS_DISABLED, // WS_CHILD|WS_DISABLED, 50,50, 400,200, hw,0,hi,0); if (!ha) printf("ERROR: couldn't create windown"); //UpdateWindow( ha ); //ShowWindow( ha, SW_SHOW );}static LRESULT CALLBACK MainWndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){ PAINTSTRUCT ps; HDC hdc; static int n=0; const int buffsize = 64; const int bufflen = buffsize * sizeof (TCHAR); static TCHAR buff[64]; switch (uMsg) { // ... case WM_PAINT: // 0x000F // Paint the window's client area. hdc = BeginPaint(hwnd, &ps); StringCbPrintf( buff, bufflen, L"Hello %3d",n ); TextOut(hdc, 0, 0, buff, 9); EndPaint(hwnd, &ps); n++; return 0; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; }

Share this post


Link to post
Share on other sites
Guest ziporama

Thanks for the example. Following up on e-mail.Etienne

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...