Creating WebDialog as Pallette in center without starting in upper left

I know how to center a WebDialog as Pallette, using WebPage.Height, WebPage.Width, WebDialog.Height and WebDialog.Width. No problem there. But I’d like the dialog to not first appear at Top 0, Left 0, and then move to the center. This doesn’t happen when running it in the IDE, but it does when running it deployed.

I have tried using this is the WebDialog1.Shown event:

WebDialog1.Visible = False WebDialog1.Top = (WebPage1.Height - WebDialog1.Height)/2 WebDialog1.Left = (WebPage1.Width - WebDialog1.Width)/2 WebDialog1.Visible = True

But that doesn’t help. The dialog still appears in the upper left corner and then moves to the center. Anyone dealt with this?

Hi,

WebDialogs are funky.
Show event comes too late for this. What I do is change palette position after creating, but before showing.
I tried using a constructor but there are other issues.
You may try something like:

Dim WebDialog1 As new yourPalette WebDialog1 = (WebPage1.Height - wd.Height)/2 WebDialog1 = (WebPage1.Width - wd.Width)/2 WebDialog1.Show

[quote=412448:@Olivier Colard]Hi,

WebDialogs are funky.
Show event comes too late for this. What I do is change palette position after creating, but before showing.
I tried using a constructor but there are other issues.
You may try something like:

Dim WebDialog1 As new yourPalette WebDialog1 = (WebPage1.Height - wd.Height)/2 WebDialog1 = (WebPage1.Width - wd.Width)/2 WebDialog1.Show[/quote]
That was my first attempt at a workaround, but it left the dialog in upper left and never moved it to the center.

Ralph, your code is almost there. I would try keeping the Webdialog1.visible = True line inside of the show event code, and moving all others as suggested by Olivier.

I think that it should do it. If it does not, then in the show event I would start a timer and I would move the visible = true line in the timer action event.

Louis,

I assume you meant to move all but the Webdialog1.visible = True line to the dialog’s Constructor, and leave Webdialog1.visible = True in the dialog’s Shown event. I added the Constructor this way:

[code]// // Calling the overridden superclass constructor.
// // Note that this may need modifications if there are multiple constructor choices.
// // Possible constructor calls:
// // Constructor() – From WebDialog
// // Constructor() – From WebControl
// // Constructor() – From WebObject
// Super.Constructor

Me.Top = (WebPage1.Height - Me.Height)/2
Me.Left = (WebPage1.Width - Me.Width)/2[/code]

This works. But I had to comment out the default lines I get when first telling the IDE I want a Constructor for this dialog. I have a couple questions about doing it this way.

  1. Isn’t this manipulating the UI before the Shown event, much like attempting that in the Open event? And I know that latter is not a good idea.

  2. I didn’t completely understand the stuff I commented out, and if I didn’t comment out the Super.Constructor line, the dialog is malformed when called.

  3. I imagine it would be more pure if I put a webPage parameter (As WebPage) in that Constructor and then used this:

Me.Top = (webPage.Height - Me.Height)/2 Me.Left = (webPage.Width - Me.Width)/2

and then call like this:

Dim d As New MyDialog(WebPage1)

I don’t even need a Shown event for the above to work. I’m just concerned about questions 1 and 2 above.

No, you assume incorrectly. I was answering to the point that you see your webdialog moving on the screen. It is very simple, actually. I am assuming that you designed a webdialog in the IDE. Therefore, you would use the webdialog in this manner, somewhere in a method of the page or container, or an event, whichever:

Dim WebDialog1 As new yourSourceObject ' the webdialog created in the IDE WebDialog1.Visible = False WebDialog1.Top = (WebPage1.Height - WebDialog1.Height)/2 WebDialog1.Left [code] = (WebPage1.Width - WebDialog1.Width)/2
WebDialog1.Show
[/code]

In the webdialog shown event:

Me.Visible = True

You can have any constructor that you wish (you can uncomment your constructor code. make sure however that it does not set the webdialog visible property to true) . It is not manipulating the UI. The New keyword runs the constructor. The object exists already from that point, it is just not shown. Webdialog1.Show causes the execution of the shown event, where I suggest that you set the visible property to true.

This way, all the preparation work happened while the dialog was invisible. You only make it visivle when it is good and ready to be shown.

I sure thought I that I tried what you suggested before ever starting this conversation, because it seemed logical to do, but apparently I had not. It works perfectly, Louis. Thanks for your patience on this.

Once in a blue moon, I get it right. A lucky shot. :wink:

Seriously, I am just happy that I could help and that it works well for you.

I wouldn’t do that. Doing so will certainly mean that the WebDialog doesn’t get set up all the way because it’s not calling its own Constructor.

I’m no longer using a Constructor for this anyway. I’m just making the WebDialog invisible (and repositioning it) in the Action event of the WebButton that calls it, and then making it visible in its Shown event.