Screen resolution?
Bill Baxter
wbaxter at gmail.com
Tue Jul 10 12:21:45 PDT 2007
On 7/11/07, Carsten A. Arnholm <arnholm at offline.no> wrote:
>
>
> wx at 61131.com wrote:
> > Moin Carsten,
> >
> > wxSystemSettings::GetMetric()
> >
> > Friedrich Haase
>
> Thank you Friedrich!
>
> Looks like there are multiple ways this can be done then:
>
> - ::wxGetClientDisplayRect()
> - wxSystemSettings::GetMetric(wxSYS_SCREEN_X/Y)
> - wxDisplay::GetGeometry()
But I think wxDisplay is the only one that knows about multiple monitors.
This is what I wrote for my app (wxPython):
frameRect =3D cfg.Read("Frame.rect", "")
if frameRect:
# stored as string of "x,y,w,h"
frameRect =3D wx.Rect(*map(int,frameRect.split(',')))
found =3D False
for i in range(wx.Display.GetCount()):
disp =3D wx.Display(i)
drect =3D disp.GetClientArea()
if frameRect.Intersects(drect):
found =3D True
break
if found:
self.SetRect(frameRect)
It looks for the first monitor that the window overlaps with and uses that.
I suppose I could have gone on to search for a window with the maximal
overlap...
Anyway, I think this is something people often want to do. Something along
these lines would be a good candidate for a wiki cookbook snippet.
An improvement to this might be to use wxConfig to store the wxDisplay rect
you're expecting and bail on the remembered window placement if the display
has gotten smaller. However, I'd like to avoid the algorithm second
guessing the user. If the user wants to explicitly put the window half-way
off the screen, it should be remembered that way.
Another aspect is remembering the maximized state. I haven't tried this in
wx yet, but generally it's a little tricky because you don't really want to
record the maximized rectangle as the rectangle. You want whatever size it
had _before_ maximizing. So I believe you need to save that somewhere just
before the window gets maximized, unless wx already does this for you.
--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070711/d3e=
78b32/attachment.htm
More information about the wx-users
mailing list