Canvas.Background = Image Flash forever and beep

The global property is loaded in App.Open --> Prefs_Open(), a method called in Open).

If mPrefs.gCompany_Logo <> Nil Then Me.Backdrop = mPrefs.gCompany_Logo End If

Compiled on Mac, copied to Windows 10 1803 and I get a continuous flash with some beep(s). I was not even able to close that window, I had to reboot the laptop.

I usually set the Canvas Backdrop in the Window Editor (elsewhere in another window, I just added a new Canvas and do that without trouble).

What happens ?

Of course, I cleared Xojo Cache folder, checked that window code (and the App.Prefs_Open method) in case I wrote some weird code… I found nothing.
Doh !
I also trashed the previous code version and empty the Trash before build a new version of the exe (just in case). The only thing I do not do is to prey.

@Emile Schwarz : on what do you prey (ausbeuten, jagen) or do want to pray (beten) to Chtulu?

Try it again to see if the problem is reproducible or not. Why would you clear the cache when you have such a fun problem?

What is in the window .Activate event?

@Jeff: Invalidate, but I commented it.

Ichanged the code from Paint to Open and I understand why I used Paint originally… In a preference file, that image (a company logo) can be changed. Using the Paint Event to draw it is working fine on MacOS, but flash on WIndows. It appears at once (once I loaded it from disk / drop into the Target Canvas, etc.).

Before leaving home, I noticed the resize function stop working and some other weird behavior: the hard times are back.

The will to send the laptop thru the window too :frowning:

It could be that you have accidentally set a window to “Movable Modal”, this could cause the behaviour you’re explaining with flashing windows and beeps.

You arent doing that.
You are setting the backdrop.

Change the paint event to be

If mPrefs.gCompany_Logo <> Nil Then
g.drawpicture mPrefs.gCompany_Logo,0,0,mPrefs.gCompany_Logo.width,mPrefs.gCompany_Logo.height
, 0,0,mPrefs.gCompany_Logo.width,mPrefs.gCompany_Logo.height
end if

Set the canvas to erasebackground = false

Take the code out of .Open(), prefs.open, and Activate() as they are not needed

Hi Jeff,

thank you for the advice, but I am totally exhausted !

I may lead you in a wrong path.

a. On App.Open, I call a method who loads the “default” logo from disk (resized, read c)).
(that method init all preferences)

b. When I open the window who deals with the Logo, I can either drop an image on a Canvas or click in an Open PushButton to allow the selection of an image file (Logo)

c. That image is meant to be resized (or not *) and displayed in the Canvas Backdrop.

d. That image is used as a logo in allPreferences windows (and will be displayed in the application windows).

The eventual resize is done at drop or open time. When the user set a new window and click in Done PushButton, the resized image is saved to the preferences folder.

The resize image code apparently was wrong it was working fine at one point, then started to no more works. I do not noticed that because I used the same logo for the testings (the resized one, so no need to resize it back). I loved that red variant of the target logo (my color change to be sure I updated the code on all other windows, the non Preferences windows).

At this stage, I will let today run and be back by tomorrow to get a fresh eye on the troubles.

  • I have two RadioButtons to let the user deal with that: Resize it or As is.

You are setting the backdrop.
You are right: I typed too fast.

Set the canvas to erasebackground = false
It was set to ON. Will do.

@Julian: Thanks.
No. I didn’t do that.

I remember what I changed in the resize code block:

I do not used 0,0 (as X,Y, in .DrawPicture), I computed these values to get the image centerd in the canvas in case the logo is smaller than the Canvas.
This works fine according the two test images (one in Portrait, the same as Landscape)

I do not know how this can give troubles, but…

The current resize code: depending on the image to be resized, it is resized or not, and sometimes too resized (smaller than the intended values). I will get an eye in an older routine anc compare both: it may be the way I compute the ration (I saw 1 where it have to be something else; and I declared it as Double).

The answer (for the Flash) seems to be Set the canvas to erasebackground = false.

I changed the setting and compiled for Windows, fired VirtualBox/Windows XP and it do not Flashed like a fool (on the Hill). I was able to quit normally (no force quit like yesterday).

On Windows 10, I was able to close the window, but it took a finger pressing the Mouse, MouseCurson on the Close X button ! for some times…