Board index » delphi » Screen resolution change affects windows (negativelly)...

Screen resolution change affects windows (negativelly)...

- Question 1:
I am using a procedure that changes the 'screen mode' to any specified
resolution
(such as to 640x480). When I change the screen to this mode and then restore
it
back to the old mode (say 1024x768), then ALL windows that were open before
are (mis)aligned! I.e, they do not keep their old position. So if you
centered the
Explorer window before you started my little program, then the Explorer
window
will have a new position after you've shut my program down! And I wonder
Why?
If you've seen ANY other scree mode changing programs (e.g. Starcraft,
Quake)
then you'll also see that all windows will remain in their old spot after
you've closed
these two apps!

- Question 2:
I'm still using my little procedure, but now I wonder how to automatically
restore
the old screen mode after my program terminates. This includes abrupt
termination
(i.e. due to an unsuspected exception). Let me take Starcraft for example,
again.
When it terminates (even after I kill its process!), the screen mode gets
restored!
How is this possible?

I have suppled the source code to this infamous procedure at the bottom!
Thanks for the help and sorry for the length of this post!

=== CODE ===
Procedure TForm1.ChangeScreenMode(P: TPoint);
Var
  DeviceMode: TDeviceMode;
  Result: integer;
Begin
 with DeviceMode do begin
  dmSize := SizeOf(TDeviceMode);
  dmPelsWidth := P.X;  // The new screen width.
  dmPelsHeight := P.Y;  // The new screen height.
  dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
end;
// The below is the function I use...
// You can also set 0 instead of DS_UPDATEREGISTRY (but there are no
interesting differences,
// as far as I can see...)
Result := ChangeDisplaySettings(DeviceMode, DS_UPDATEREGISTRY);
If Result <> DISP_CHANGE_SUCCESSFUL then
  ShowMessage('Could not change screen mode.');
End;

=== END OF CODE ===

 

Re:Screen resolution change affects windows (negativelly)...


Im Artikel <rn0o9.1063$o4.42...@news010.worldonline.se>, "Supply and Demand"
<m...@worldonline.se> schreibt:

Quote
>I am using a procedure that changes the 'screen mode' to any specified
>resolution

Setting the screen mode setting is up to the user, not to applications.

If you have problems with your applications on different screen resolutions,
then you should cure these problems, and not the environment.

DoDi

Re:Screen resolution change affects windows (negativelly)...


I think you misunderstood me.

Games, like Starcraft, always run under 800x600 (or was it 640x480?) pixel
screen resolution,
regardless of which screen mode you had previously. This ensures that all
players of the game
see equally much of the map and thus have equal opportunities of winning. In
some games,
you can change the screen mode to a higher resolution, which allows you to
see a larger portion
of the game field. If you made a multiplayer game based on this, it would be
pretty unfair for those
that cannot set a higher resolution than other players. Also, changing the
screen mode is (I know
it is) only a trivial matter and it is possible to change the mode and reset
to the old mode easily...
But I don't know how...

I want to change the screen mode, for my game, into 640x480 and back into
the old screen
mode when the game terminates, without disturbing previous form positions
and sizes.
This meens that I do Not want to change the mode Permanently, only
temporarily. How is this
done? My code, which I provided, changes the mode permanently (obviously
also writes that
information into the registry). I don't want that.

I hope I made myself a little bit more clear about what I meant with what I
wrote before.
But, thanks for the comment, though! :)

Re:Screen resolution change affects windows (negativelly)...


I think you'll find, based on the requirement of needing DirectX
installed to run Starcraft, that Starcraft utilizes DirectX to
draw on the screen rather than doing it through the regular Windows
GUI calls.  When using DirectX, you draw using the functions
exported and DirectX handles all the messy details of changing
the screen resolution and restoring it, etc.  
I'm not sure if the "Tomes...." graphic edition would cover it,
but either "Delphi Unleashed" or "Delphi Developers Guide" (both
for version 4) talked about it for a couple of chapters.
(Unfortunately, they change the implementation in version 5
enough that you had to apply some workarounds for the examples
in the book, so I didn;t spend much time last year playing around
it.....

    Later,
      Frank

Quote
Supply and Demand wrote:

> I think you misunderstood me.

> Games, like Starcraft, always run under 800x600 (or was it 640x480?) pixel
> screen resolution,
> regardless of which screen mode you had previously. This ensures that all
> players of the game
> see equally much of the map and thus have equal opportunities of winning. In
> some games,
> you can change the screen mode to a higher resolution, which allows you to
> see a larger portion
> of the game field. If you made a multiplayer game based on this, it would be
> pretty unfair for those
> that cannot set a higher resolution than other players. Also, changing the
> screen mode is (I know
> it is) only a trivial matter and it is possible to change the mode and reset
> to the old mode easily...

Other Threads