473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

detecting the change in desktop resolution - how?

Hello All,

I am trying to clean up some polish bugs with the Shanghai game I am
working on and I am currently stuck on trying to get the right event
for detecting when the user has changed the desktop resolution.

I have tried trapping the following events:

1) SDL_ACTIVEEVENT
2) SDL_VIDEOEXPOSE 3) SDL_VIDEORESIZE

These are the events that are passed through to pygame as
pygame.ACTIVEEVENT and so on...

#3 - SDL_VIDEORESIZE This is what I looked at first and I was wrong,
this is only for the WINDOW being resized... not the desktop resoltion

#2 - SDL_VIDEOEXPOSE After watching the events in a debugger when I
change the desktop resolution I find out that this IS the event that is
generated from changing the desktop resolution. Okay no problem right?
Time to call:

self.screen = self.pygame.display.set_mode( size )

and draw() again right?

Well sure, now my game repaints properly when the desktop resolution
changes. So What is the problem? Well now EVERY TIME another window
draws on top of my game's window a SDL_VIDEOEXPOSE event is triggered.
There does not appear to be any flags associated with this event. So I
am having trouble distinguishing from an overlapping window and
changing the desktop resolution.

So I tried this:

1) call pygame.display.Info() at the startup of my game and save off
this structure
2) call it again after getting a SDL_VIDEOEXPOSE event and comparing to
see if it has changed at all.

The problem with this is that apparantly the VidInfo structure DOES NOT
change when changing desktop resolution...

So then I tried using SDL_ACTIVEEVENT and simply leaving the display
black and unpainted after the user changes the resolution until the
user rolls the mouse over the game window and bringing it back to
focus.

This works. However, it gets annoying watching the screen repaint
everytime the window gains focus....

Do you guys have any leads for me to try? This HAS to be a problem
solved many times before...

Thank you,
-Erik

Jul 18 '05 #1
1 2832
Hi !

On windows, and PyWin, this script give the H/V current resolution :

import win32com.client
oWMI = win32com.client.Dispatch("WbemScripting.SWbemLocat or")
owbem = oWMI.ConnectServer(".","root\cimv2")
collec = owbem.ExecQuery("Select * from Win32_PrinterConfiguration")
print "Horizontal Resolution: ", collec[0].HorizontalResolution
print "Vertical Resolution: ", collec[0].VerticalResolution


@-salutations
--
Michel Claveau

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the...
5
by: Andy | last post by:
got the usual script: <script language="JavaScript" type="text/JavaScript"> var s_height = screen.Height var s_width = screen.Width var s_screen= screen.colorDepth if ( s_height == "480" &&...
4
by: pjac | last post by:
I need some help with some VB language that will change the screen resolution on a monitor when a MS-Access 2000 database is opened from 1024 x 768 to 800 x 600. Any help with this effort would be...
1
by: Dirk Reske | last post by:
Hello, is there a way, to change my resolution out of my programm? thx
2
by: Bill Nguyen | last post by:
Is there a way to send output from a .NET app to a selected monitor screen in a 3-monitor client desktop? Currently, my app sends output to 3 windows then I have to move/drag each of them to the...
15
by: =?Utf-8?B?TVNU?= | last post by:
To demonstrate my problem, I have a very simple VB Windows application. It has a text box that is used to display a counter, a button to reset the counter, and a timer that increments the counter...
8
by: Bjorn Sagbakken | last post by:
Can screen resolution be detected with server code (in Page_Load) ? I have tried this: public int Width = Convert.ToInt32(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width); public...
1
by: Grzegorz Klimsa | last post by:
Hi ! I have a problem wiht detecting resolution of client web browser I prepare several files of css style for different browsers and different resolutions, (such as : Style_1024x768.css ;...
6
by: Bob Altman | last post by:
Hi all, This is a long shot, but I figure it doesn't hurt to ask... I have some applications that work fine when I run them on my PC at work, but "fail to initialize (0x000005)" when I'm...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.