Eto dialog location not set

I know this is tiny thing but I don’t know where else to look for help.
I’m expecting the dialog window to show at the top left corner of my screen but it isn’t…

@Will_Wang, i think this is a bug. If i run this, i can see the form pops up at 0,0 for a nano second, then it is moved to the center. This does happen even when i do not set the Location.


Same issue in C#. I’m trying to create a dialog that works like a context menu – appearing over a control where the user clicks. So far the dialog pops up somewhere else, unaffected by attempts to set Location.

Any workaround for this?

I think windows forms has a group of “toolstrip” classes. Perhaps those are better fit for a right click menu.

presumably this Eto issue is and will not be fixed

I would like to push this issue, and/or ask if there is some way of which I am not aware, to both parent an eto dialog to Rhino, and yet direct where it is to be shown. Please see the following for details on what I have determined so far, regarding this.

import Eto
import Rhino

As far as I can see, it is not possible (at least in an acceptable way) to both
parent an Eto dialog to the Rhino window, and yet also direct that it be shown
at a specific location.

We can do it if we do not set the owner, but this is problematic because it will
allow the Eto dialog to become stuck behind the Rhino window:

    1. Call ShowModal, without setting dialog owner.
    2. Use the task bar to try and bring Rhino to the front.
    3. The dialog will become stuck behind the Rhino window.
    4. You must now use ALT+TAB to kill the Eto dialog.

Until you do, you will be unable to access Rhino (or the Python editor, in the
case you are running the script from there, but it works the same from e.g. c#).

d = Eto.Forms.Dialog()
d.Size = Eto.Drawing.Size(200,200)
d.Location = Eto.Drawing.Point(100,100)

# 1. Location will not work, if we set Owner:
#d.Owner = Rhino.UI.RhinoEtoApp.MainWindow

# 2. Setting Owner this way will do the same:

# 3. This hack works, but we see the dialog move from center to our location.
def onShown(s,e):
    d.Location = Eto.Drawing.Point(100,100)
d.Shown += onShown

@curtisw, can you help here?

Sometimes I do need a modeless Form to be shown tho.
I’ve also noticed that winform in Rhino is always titled “Form1”. The MyForm.Text="custom title" line gets ignored…

Thanks for bringing this up again and the details for a workaround. I looked into it and it is indeed a bug in Eto with dialogs on Windows. I have logged issue RH-55856 to get that fixed.

Hey Will, you should use the “Title” property as there is no Form.Text property in Eto. If it is indeed windows forms then that is a separate issue and you may be setting the text before calling the InitializeComponents() method in the constructor.


Yes I am. Does it have to do with this SuspendLayout() and ResumeLayout() pair of calls? It works now that I call InitializeComponents first thing in the constructor…

No it doesn’t have to do with the Suspend/Resume. It is because InitializeComponents() is being called after you are setting the title, which in turns sets the title to its value from the designer. Adding the call manually allows you to perform logic after everything is initialized.

Hope this helps.

sneaky method…it does have this line Text = "Form1" buried.
I copied the chunk from VS’s winform template. Does this ISupportInitialize and all the BeginUnit(), EndInit() matter? Seems that they are called on all the controls.

Without it the form can initialize much slower (e.g. it defers layout and size calculations, etc). That is, of course, if you even use the designer. If you are creating the entire layout via code then you don’t usually need it.

1 Like