PDA

View Full Version : Problems with behaviour of the form



Firlefanz
09-01-2006, 09:05 AM
Hi!

just to mention: the Omega forums are down again, I already tried to reach Bobby. I asked lifepower @Turbo.Gamedev.net to send people with questions here or to my forum.

So a question myself, not sure if it is really about Omega, I think all other headers will have the same problems.

Hard for me to tell this in english, I am not sure about some words.

The windows Task-Bar (?) on the bottom (where the Start button and tasks are shown) can be set to 'Always visible' and 'automatic in background' (translated by me, I have a german windows and am not sure how it says in english windows). When both is set and my application starts fullscreen, I see my application but every few frames the task-bar shines through, looks awfull and sometimes I don't have mouse in my application (I guess it does not have focus).

Some other problem:
I played fullscreen, then I stopped and was minimized because some background program (in this case mail software) told me something. How do I prevent it from being stopped from the background tasks?

Thanks a lot,
firle

Robert Kosek
09-01-2006, 01:45 PM
I'd suggest using either Application or your form's "BringtoFront" method in the on create event.

You've got the "Always on top" option checked, and so it was just being obedient, much to the irritation of DX and you. ;)

Firlefanz
09-01-2006, 01:48 PM
Hi Robert,

thanks for the info.



I'd suggest using either Application or your form's "BringtoFront" method in the on create event.

Do you mean in the Form itself at the end of formload or in the project file after creating the form?

Firle

Robert Kosek
09-01-2006, 02:08 PM
In the form's OnCreate event, or where ever you do the initialization for your project.

Firlefanz
09-01-2006, 02:14 PM
Thanks, I'll try it. :D

Firle

Robert Kosek
09-01-2006, 02:22 PM
No problem. Been awhile since I had an app that wouldn't focus, had one or two, but if you get an error try moving the call to the OnShow event.

czar
09-01-2006, 05:30 PM
I tried various methods but they weren't 100%. For example, people who set up the task bar as auto hide and always on top it would still come into view when the mouse was at the bottom edge of teh screen.

In the end I just used win api to remove the taskbar and put it back on close of the app.

Only hassle is that the taskbar is gone if your app crashes.

Firlefanz
09-01-2006, 05:44 PM
Hi Czar,

can you give me a piece of code how you let it dissappear?

Did you do something else like Stayontop or Bringtofront?

Thanks,
Firlefanz

Clootie
09-01-2006, 09:04 PM
Code snippet from MS DXUT framework, showing how to correctly switch to fullscreen mode (without some code for saving current window state):
// Going to fullscreen mode
// Hide the window to avoid animation of blank windows
ShowWindow(DXUTGetHWNDDeviceFullScreen, SW_HIDE);

// Set FS window style
SetWindowLong(DXUTGetHWNDDeviceFullScreen, GWL_STYLE, Integer(WS_POPUP or WS_SYSMENU));

// If using the same window for windowed and fullscreen mode, save and remove menu
if (DXUTGetHWNDDeviceFullScreen = DXUTGetHWNDDeviceWindowed) then
begin
hMenu := GetMenu(DXUTGetHWNDDeviceFullScreen);
GetDXUTState.SetMenu(hMenu);
SetMenu(DXUTGetHWNDDeviceFullScreen, 0);
end;

ZeroMemory(@wpFullscreen, SizeOf(TWindowPlacement));
wpFullscreen.length := SizeOf(TWindowPlacement);
GetWindowPlacement(DXUTGetHWNDDeviceFullScreen, @wpFullscreen);
if ((wpFullscreen.flags and WPF_RESTORETOMAXIMIZED) <> 0) then
begin
// Restore the window to normal if the window was maximized then minimized. This causes the
// WPF_RESTORETOMAXIMIZED flag to be set which will cause SW_RESTORE to restore the
// window from minimized to maxmized which isn't what we want
with wpFullscreen do flags := flags and not WPF_RESTORETOMAXIMIZED;
wpFullscreen.showCmd := SW_RESTORE;
SetWindowPlacement(DXUTGetHWNDDeviceFullScreen, @wpFullscreen);
end;

The main line for you is:
SetWindowLong(DXUTGetHWNDDeviceFullScreen, GWL_STYLE, Integer(WS_POPUP or WS_SYSMENU));

Firlefanz
10-01-2006, 05:41 AM
Hi Clootie,

thanks a lot, I'll try that also.

If I use this, should I also use BringtoFront and fsStayontop or should I cancel those?

Thanks,
Firle

Clootie
10-01-2006, 08:07 AM
It shouldn't be necessary.
Actually in mine code it's vice versa: then returning back to windowed mode I use (but it's mainly bacause for fullscreen mode I use created by myself window - not VCL form):
function TMainForm.XXXXXXX: HResult;
begin
...
SetFocus;
Application.BringToFront;
...
end;

Firlefanz
10-01-2006, 09:39 AM
I am not sure if I understand it. I'll try it and if I don't succeed maybe we can create a little sample with a black screen or something...

And this works with forms? Have to try it, thanks....

firle

Firlefanz
11-01-2006, 06:14 PM
Hi Clootie,

I don't know DXUTGetHWNDDeviceFullScreen.

I don't want to switch from Fullscreen to Windowed or back, I can do this in my configuration but not in Runtime, this is ok for me.

I just want to know what to do when starting Fullscreen to get rid of the taskbar problem. I have just a normal form:

Application.CreateForm(TCommandoform, Commandoform);

So could you please tell me how to do this for a normal form or
if it was the right statement above, how to set DXUTGetHWNDDeviceFullScreen?

I am using OmegaDX9 based on your DX9 headers Dec Update.

Thanks,
Firle

Clootie
11-01-2006, 08:10 PM
I've never got VCL forms to be 100% compatible with holding DirectX fullscreen renderer (this includes correct handling of loss of fullscreen mode due to user presing Ctrl-Alt-Del or Alt-Tab or backgound dialog popping-up, or ....). So I use special pure WinAPI window for this purpose.

But if you insist: you can try to call
SetWindowLong(YouFullScreenForm.Handle, GWL_STYLE, Integer(WS_POPUP or WS_SYSMENU));
before switching to fullscreen (DX runtime will set window size to fullscreen by itself). And don't forget to change it back when switching to windowed mode.

Isn't Omega already has support for fullscreen applications?

Firlefanz
12-01-2006, 07:16 AM
Hi Clootie,

thanks a lot for the info. :D

I'll try that. Omega has fullscreen support of curse I only get Problems if the user has his win-taskbar set to auto hide and always on top just like Czar said, I guess everybody using Omega with a form has the same problem. If it does not work out, I'll ask Czar how he is doing it (removing the taskbar or whatever). But I'll try first, thanks!

Next project I'll try without a form like you said, but for this project I would have to change too much stuff.

Firle

czar
16-01-2006, 01:24 AM
What I do is

(sorry is a bit messy but I am sure you can work it out from here). I do not set the alwaysontop. I leave it as is.



//On Reactivate or on show whatever you like
var hTaskBar &#58; THandle;

hTaskbar &#58;= FindWindow&#40; 'Shell_TrayWnd', Nil &#41;;

ShowWindow&#40;hTaskBar, SW_HIDE&#41;;

//On deactivate

procedure TMainForm.Deactivate&#40;Sender&#58; TObject&#41;;
var hTaskBar &#58; THandle;
begin
hTaskbar &#58;= FindWindow&#40; 'Shell_TrayWnd', Nil &#41;;
ShowWindow&#40;hTaskBar, SW_NORMAL&#41;;
end;

// On create I set up the following
procedure Deactivate&#40;Sender&#58; TObject&#41;;
procedure Reactivate&#40;Sender&#58; TObject&#41;;

Application.OnDeactivate &#58;= Deactivate;
Application.Onactivate &#58;= Reactivate;

Firlefanz
16-01-2006, 05:27 AM
Hi Czar,

I build in Clooties suggestion but did not test it yet.

I must test this on at least 2 PCs. :wink:

If it does not work out, I will use yours also, thanks a lot for the code! :D

Firle