wxWinCE reports incorrect screensize...

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
acsMike
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Feb 11, 2005 9:05 am
Location: Stockholm, Sweden

wxWinCE reports incorrect screensize...

Post by acsMike »

I'm playing around with my HTC Touch HD with a screensize of 480x800 pixels. It has Windows mobile 6.1. The SDK from Microsoft provide a close approximation of the device at the same screen resolution.

Using wxWidgets 2.8.9 and wxWince I'm doing a trivial Hello World with the sole purpose of printing the screen resolution on the window.

The problem is, that for a screen of that size, the reported resolution (reported by Windows itself) is just half of the actual truth, i.e 240x400 !

Creating the same program in native Win32, reports the correct resolution.

Further more, in wxWince, when splashing a bitmap to the screen, everything gets "blown up" a factor 2.

Oh, please help me, I woudn't want to go over to Win32, when I got wxWidgets.

PS. When running the program under a device/emulator with a small screen, it gets reported correctly.
Last edited by acsMike on Sat Jan 10, 2009 8:25 am, edited 1 time in total.
/Michael Ljunggren, developer
Peavey Electronics

Windows: 2.6.3, 2.8.9 (VS2005) ** Mac: 2.6.3 (XCode 3) ** WinCE: 2.8.9 (VS2005), ** GTK: 2.8.9 (Kdevelop)
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

What code do you use to fetch screen dimensions?
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
acsMike
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Feb 11, 2005 9:05 am
Location: Stockholm, Sweden

Post by acsMike »

radcapricorn wrote:What code do you use to fetch screen dimensions?
All of them, so to speak ;-)

In wxWidgets I use wxSystemSettings::GetMetric(wxSYS_SCREEN_X) which is mapped to the Win32 call ::GetSystemMetrics.

But even trying the Win32 call ::GetDeviceCaps yields an incorrect answer.

I also tried the Win32 call ::GetClientRect(::GetDesktopWindow, &Rect); Same thing.

Now you might think that "maybe the screen actually has that size..." but no. It is a 480x800. The thing is that making the same calls from a native Win32 program yields the correct results! I suspect that wxWidgets do something to Windows that makes it in turn report the numbers incorrectly.

Also, the same thing happens with the real device and on the emulator.
/Michael Ljunggren, developer
Peavey Electronics

Windows: 2.6.3, 2.8.9 (VS2005) ** Mac: 2.6.3 (XCode 3) ** WinCE: 2.8.9 (VS2005), ** GTK: 2.8.9 (Kdevelop)
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

And what about wxDisplaySize()?
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

Follow-up:

I'm not really sure about problem origin right now, need to get home and look into it in more detail, but this just came up in mind:

Are you using correct preprocessor directives for your platform? I mean, __POCKETPC__, __SMARTPHONE__, __HANDHELDPC__, so on?..
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
acsMike
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Feb 11, 2005 9:05 am
Location: Stockholm, Sweden

Post by acsMike »

radcapricorn wrote:Follow-up:

I'm not really sure about problem origin right now, need to get home and look into it in more detail, but this just came up in mind:

Are you using correct preprocessor directives for your platform? I mean, __POCKETPC__, __SMARTPHONE__, __HANDHELDPC__, so on?..
I'm using the standard wxWidgets samples. I'm guessing...(?) there is nothing in setup.h I need to set manually?
/Michael Ljunggren, developer
Peavey Electronics

Windows: 2.6.3, 2.8.9 (VS2005) ** Mac: 2.6.3 (XCode 3) ** WinCE: 2.8.9 (VS2005), ** GTK: 2.8.9 (Kdevelop)
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

It's not related to wxWidgets, it's compiler/SDK feature. Well, if you're using Visual Studio with appropriate SDK selected, it defines those for you. But I suggest you doublecheck your build command line to see what gets defined and if it's really appropriate for the platform you build for. Especially that concerns build command line when you build wxWinCE itself, because it should be built for the same platform (PocketPC, Smartphone or Handheld) you intend to build applications for. Otherwise you may get some strange looks/issues when you compile and run your software.
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
acsMike
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Feb 11, 2005 9:05 am
Location: Stockholm, Sweden

Post by acsMike »

radcapricorn wrote:And what about wxDisplaySize()?
I missed that one, but wxGetDisplaySize and wxDisplaySize both return the incorrect size. :?
/Michael Ljunggren, developer
Peavey Electronics

Windows: 2.6.3, 2.8.9 (VS2005) ** Mac: 2.6.3 (XCode 3) ** WinCE: 2.8.9 (VS2005), ** GTK: 2.8.9 (Kdevelop)
acsMike
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Feb 11, 2005 9:05 am
Location: Stockholm, Sweden

Post by acsMike »

radcapricorn wrote:It's not related to wxWidgets, it's compiler/SDK feature. Well, if you're using Visual Studio with appropriate SDK selected, it defines those for you. But I suggest you doublecheck your build command line to see what gets defined and if it's really appropriate for the platform you build for. Especially that concerns build command line when you build wxWinCE itself, because it should be built for the same platform (PocketPC, Smartphone or Handheld) you intend to build applications for. Otherwise you may get some strange looks/issues when you compile and run your software.
After double checking, it appear that all defines are proper = __WXPOCKETPC__ which I'm targeting.

Thanks for all your help. I really appreciate you taking the time. Have you had an opportunity to develop for an 800x480 device?
/Michael Ljunggren, developer
Peavey Electronics

Windows: 2.6.3, 2.8.9 (VS2005) ** Mac: 2.6.3 (XCode 3) ** WinCE: 2.8.9 (VS2005), ** GTK: 2.8.9 (Kdevelop)
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

Well, there wasn't really targeted development for those devices, but I used to play some of my apps on those and they seemed to run OK. Actually, all my WinCE projects are currently hobby ones (and not all of them are built with wxWinCE).

...Well, I guess then that your defines are all right (though I meant not wx defines but platform ones, but anyway the former gets declared after the latter, so it seems it's OK with them). I'll try and wipe some dust from my old code and see if this kind of problem shows up or not, but I regret that'd be only by the weekend.
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
acsMike
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Feb 11, 2005 9:05 am
Location: Stockholm, Sweden

Post by acsMike »

I'd like to point out, that knowing the screen size is not as important as blitting bitmaps correctly on screen. Every access to the screen maps one (software) pixel to 2x2 (hardware) pixels on screen, so everything gets large and blocky.

I'm baffled by the behavior and I have only encountered this when running on large screens. Smaller screens runs fine. It's almost like there's a line somewhere in wx which says

Code: Select all

if (pocketpc && screen == huge)
{
  // Unrealistic, correct
  scaleupeverying(2);
}
/Michael Ljunggren, developer
Peavey Electronics

Windows: 2.6.3, 2.8.9 (VS2005) ** Mac: 2.6.3 (XCode 3) ** WinCE: 2.8.9 (VS2005), ** GTK: 2.8.9 (Kdevelop)
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

Well, seems like the problems are tightly coupled, so the solution would almost certainly be in finding why you get incorrect device caps.
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

You know, I've just found one of my old wxWinCE test apps here and made a quick test that displays a message box with values got from wxDisplaySize()... It reports correct size for QVGA (240x320), VGA (480x640) and Square VGA (480x480) emulators and also on 480x800 device (some Toshiba, don't know the model exactly, it's my friend's device). I haven't tried images because I don't have wx's image handling libs built here.

My wxWinCE is built from 2.8.9 release tree.
Maybe there's something with how you build wxWinCE?
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
acsMike
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Feb 11, 2005 9:05 am
Location: Stockholm, Sweden

Post by acsMike »

radcapricorn wrote:You know, I've just found one of my old wxWinCE test apps here and made a quick test that displays a message box with values got from wxDisplaySize()... It reports correct size for QVGA (240x320), VGA (480x640) and Square VGA (480x480) emulators and also on 480x800 device (some Toshiba, don't know the model exactly, it's my friend's device). I haven't tried images because I don't have wx's image handling libs built here.

My wxWinCE is built from 2.8.9 release tree.
Maybe there's something with how you build wxWinCE?
I found it! It was apparently a link argument. Instead of supplying the Additional Options:

Code: Select all

/ALIGN:4096 /subsystem:windowsce /MACHINE:ARM
in the Visual 2005 link page, you have to supply

Code: Select all

/ALIGN:4096 /subsystem:windowsce,5.01 /MACHINE:ARM
I'm guessing it allows for more modern screens. I do hope I can run the programs on older versions too, but that is easy enough to test.

Thanks for your help radcapricorn.
/Michael Ljunggren, developer
Peavey Electronics

Windows: 2.6.3, 2.8.9 (VS2005) ** Mac: 2.6.3 (XCode 3) ** WinCE: 2.8.9 (VS2005), ** GTK: 2.8.9 (Kdevelop)
radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn »

Always welcome ;-)

I had one question. Was this trouble (and its solution) relevent to wxWidgets 2.6.3 or you've encountered it in other versions too?
win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;
Post Reply