[Windows Mobile Software Development] Graymi:
Hi all,

First a little background into what I'm attempting...

On my PC, I have a self created program which swaps the desktop image to one selected at random from a predetermined directory. There's lots of nifty features, such as image resizing to fit desktop, support for different images on different monitors in a multi monitor setup. etc.

But enough about that, as it's not really windows mobile related. What is related is the fact i'm trying to implement something similar on my Xperia X1.

Obviously I want it so I can have different images for the today screen when it's in landscape and portrait mode - like the built in themes do. I have to admit i'm fairly miffed that this feature isn't supported nativly in a nice easy non-theme related way. it's nigh-on impossible to find an image that looks good in both aspects.

Anyway, I did have something working. A small program which creates a stwater_480_800.bmp and stwater_800_480.bmp by selecting a random image from one of two predetermined directories, and then plonking said images in the windows directory. (Replacing the two bmp images put there by the theme i was using) No resizing of images or anything fancy, just a straight file copy.

This line of code:

SendMessage(HWND_BROADCAST, WM_WININICHANGE, 242, 0)

forces the today screen to update to the lovely new images after the files have been replaced.

All was well until I installed gtrab's excellent pure windows mobile 6.5 update (http://xdaforums.com/showthread.php?t=588882). And although the app still works for the main part, i.e. it picks an image, and changes the background for the today screen, i have encountered a bug.

The image behind the updated start menu doesn't get refreshed - it stays as whatever the image was when the phone was last reset (Think it's specifically a hard reset? i.e. holding power button down the rebooting with sony ericsson logo etc).

Here's the code i'm currently using (Apologies for lack of comments, despite being employed as a vb.net programmer, i'm self taught and not commenting is a bad habit i've never gotten out of.)

Public Shared Sub SwitchBG()

Randomize()

Dim curdir As New IO.DirectoryInfo(SharedVars.LandscapeDir)
Dim imagefiles As IO.FileInfo() = curdir.GetFiles("*.bmp")
If imagefiles.Length > 0 Then
IO.File.Delete("Windows\stwater_800_480.bmp")
IO.File.Copy(imagefiles(Math.Floor(Rnd() * imagefiles.Length)).FullName, "Windows\stwater_800_480.bmp")
Else
MessageBox.Show("No Landscape Images!", "BGSwitcherPPC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If

curdir = New IO.DirectoryInfo(SharedVars.PortraitDir)
imagefiles = curdir.GetFiles("*.bmp")
If imagefiles.Length > 0 Then
IO.File.Delete("Windows\stwater_480_800.bmp")
IO.File.Copy(imagefiles(Math.Floor(Rnd() * imagefiles.Length)).FullName, "Windows\stwater_480_800.bmp")
Else
MessageBox.Show("No Portrait Images!", "BGSwitcherPPC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If

SendMessage(HWND_BROADCAST, WM_WININICHANGE, 242, 0)

End Sub

I'd love to know what I have to do to force the start menu image to refresh. I've googled for a while with no joys.

Incidentally, I did discover that i can use .jpgs for the background (makes sense really). Not sure if that will have any bearing, but i'll be changing the code to accept both bmp, jpgs, and probably gifs. Can't see that it will affect my specific problem, but thought it would be worth mentioning.

Once i've got this sorted, i'll be ready to tackle the next stage, which is implementing some form of schedule so i can wake up to a new today screen image every day.

Thanks in advance to anyone with any pointers.

Matt.