Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: yaobifeng on April 07, 2008, 03:55:50 AM

Title: how to show a window's normal window in the fullscreen game?
Post by: yaobifeng on April 07, 2008, 03:55:50 AM
hi,
I want to use the windows's UI in the game,ex window,button,list box,checkbox and so on,I use delphi write a function in dll file:

h := GetForegroundWindow;
Form1:=TForm1.CreateParented(h);
form1.ShowModal;
setwindowpos(form1.Handle,hwnd_topmost,0,0,0,0, swp_nosize or swp_nomove);
form1.Free;


then call it in the script:
external "D:\Program Files\Borland\Delphi6\Projects\dll.dll" TestDll(int);
...
TestDll(55);
...


it works like:
(http://www.bster.cn/11.GIF)
(http://www.bster.cn/22.GIF)

here is the problem,sometime the showmodle window open and show back of the game surface,sometime it's open and show front of the game surface.
how can i open and show the window front of the game surface always?
Title: Re: how to show a window's normal window in the fullscreen game?
Post by: sychron on April 07, 2008, 07:04:24 AM
As far as I remember, delphi forms have a "StayOnTop" or "alwaysOnTop" somewhere, in the window style or as a special property. I don't know wether this works while directX is handling a full screen device, but it should work. Otherwise, try the bringToFront() method.

BUT ... Having normal windows.forms windows appear while a directx fullscreen window is launched is always tricky and may crash on some systems, or slow down the engine on others. It's never a good idea to steal the focus of a directX surface.

Try using WME windows instead. You could use a screenshot of your window to preserve the visual appearence, and remodel the window with wme controls.
Title: Re: how to show a window's normal window in the fullscreen game?
Post by: yaobifeng on April 07, 2008, 07:56:27 AM
As far as I remember, delphi forms have a "StayOnTop" or "alwaysOnTop" somewhere, in the window style or as a special property. I don't know wether this works while directX is handling a full screen device, but it should work. Otherwise, try the bringToFront() method.

BUT ... Having normal windows.forms windows appear while a directx fullscreen window is launched is always tricky and may crash on some systems, or slow down the engine on others. It's never a good idea to steal the focus of a directX surface.

Try using WME windows instead. You could use a screenshot of your window to preserve the visual appearence, and remodel the window with wme controls.
"StayOnTop" or bringToFront() even use Window's API setwindows all have not effect in the fullscreen mode,but work well in the window mode。I use normal windows forms because my game has many data input and output  forms,also many  forms have complex layout, it's terribly and impossible if i use WME's UI controls。I think use a normal windows form that contains a webbrowser control is a good idea。I display the normal windows form top of the game scenes,my clients use web pages input their data and view all kinds of  report,my game will connected to the web server retrieve data and redraw the scenes......
anybody can help me?
Title: Re: how to show a window's normal window in the fullscreen game?
Post by: Mnemonic on April 07, 2008, 01:40:17 PM
I'm afraid displaying native windows over the Direct3D window will never work 100% correctly, and you can run into a lot of problems there. I would definitely avoid this.
I believe the cleanest way of doing that is to integrate your native windows with the Direct3D device. If I remeber correctly, there's some example in DirectX SDK which demonstrates that. However, this only works in Direct3D 9, not in Direct3D 8. I don't know much about it, but it might work.
Title: Re: how to show a window's normal window in the fullscreen game?
Post by: sychron on April 07, 2008, 03:02:40 PM
hmm ... these examples also were in the dx7 sdk, as far as I remember.