Controls positioning

I have a viewer with a canvas that is locked on 4 sides; changing the window changes the format. The canvas has a scaling method. No problem. But when the user maximizes the window I want 2 canvases to show up next to each other. I’ve tried to make the 2nd canvas invisible, when the maximize event fires it becomes visible and positions itself next to the 1st canvas but I cannot get it right. It won’t show up correct; overlaps and size problems.

This is original

This is what I want after the window is maximized

How to deal with this? Any suggestion is welcome.

Use a page panel with containers and switch between them?

I just tried this on OSX and it appears that “self.width” in the Maximize event is the width before maximizing, not after. That seems unintuitive. Could you put your code in the resized event instead, which would then have the correct window width? You could check to see if width>height or something like that to determine if you should show 2 versus 1 canvas, or set up a variable that gets set in the Maximize event…

Good thinking… I’ll try that.

I tried with

viewerCanvas2.visible = not viewerCanvas.visible viewerCanvas2.left = viewerCanvas1.width+1 viewerCanvas2.width = viewerCanvas1.width

But strange events occurred.

I assume you also did:

viewerCanvas1.width = self.width/2

You might also need to unlock the right side of viewerCanvas1. Are both canvases directly on the window, or are they in a container control or other object?

Take a look at this project. It contains simple squares in a pagepanel. Try to to resize the window with page1 active. Very strange behavior.

This looks like an issue…

In your resize events you are referring to rectangle 1 and 2 as the content of pagepanel 1 instead of rectangle 2 and 3

After the corrections of Chris, there is no problem with the positioning on my Windows 8.1 system, but after resizing Rectangle3 loses it’s fillcolor. Even if i insert a refresh after the resizing the fillcolor is still gone.

After removing all the code out of the resized event everything works fine, strange, very strange effect.

Besides the corrections of Chris you should also remove the " if PagePanel1.Value = 1 then" condition because the resize can also happen when the PagePanel1.Value = 0 and then you also want the picture in both views being adjusted to the new size.
Further you used in resize and resized events integer division (\) and floating division (/), this can cause rounding differeneces, because you are dealing with integer values IMO you should use “”.

HTH,
Andre

Slight mishap with the forum just then, I posted a reply, it suddenly came up again as a double-post, so I deleted the 2nd one and now both have gone ! - so a repost…

I think Andrew’s issue is probably not correcting all the rectangle references, ie:

Rectangle3.Left = Rectangle1.Width +3

should be…

Rectangle3.Left = Rectangle2.Width +3

Yeah Chris, I overlooked that one, i thought the code was the same in resize and resized but was slightly different.
Good catch!

Good catch indeed! Ok. I fixed that. But still…link text

[quote=74535:@Andre Kuiper]After removing all the code out of the resized event everything works fine, strange, very strange effect.

Besides the corrections of Chris you should also remove the " if PagePanel1.Value = 1 then" condition because the resize can also happen when the PagePanel1.Value = 0 and then you also want the picture in both views being adjusted to the new size.
Further you used in resize and resized events integer division (\) and floating division (/), this can cause rounding differeneces, because you are dealing with integer values IMO you should use “”.

HTH,
Andre[/quote]

Hi André,

I followed your directions and it looks like it is ok!

Thanks!