# RS: StringBox - control position on screen?

Is there a way I could control the position of StringBox dialog on the screen?
(similar way the PopUpMenu allows). I know there is no direct way in the method (could we add it as optional argument for future?) but I thought maybe the last position is stored somewhere in the registry or other place I could access and modify ?

thanks,

–jarek

OK, I found it in the registry here:

HKEY_CURRENT_USER\SOFTWARE\McNeel\Rhinoceros\5.0x64\Scheme: Default\DialogPositions\1c7a3523-9a8f-4cec-a8e0-310f580536a7_4028_StringBox

Now the question is:
Would the name of the RegKey “1c7a3523-9a8f-4cec-a8e0-310f580536a7_4028_StringBox” be always the unique and the same, on all systems? Or should I do some sort of a search for “StringBox” substing in all DialogPositions keys to make sure it works for many users or their computers?

The next step is to figure out how to read/change the values to make the box show up where I need it to. Any insight into the above would be appreciated, I have never messed with registry changes from RhinoScript before.

Thanks!

–jarek

it might be less work and more save to use Rhino.HtmlBox which allows to control positions when called. Alternatively, in python you can write something like this using WinForms which saves position and size.

c.

hi @clement,

thanks for the suggestions. I will look into HtmlBox, While more flexible it actually seems more complicated to me than registry fix, provided I can make it work on different computers (see above for the ‘key uniqueness’ question).
No python skills over here (yet) and I am fully aware from other users posts and @pascal’s encouragement that I am missing out

-j

i´ve found that same registry key over here but i am not sure if this will work reliable if multiple string boxes with different titles are used. RhinoScript (vb) seems to remeber only the last one opened like in below example:

Option Explicit

Call Main()
Sub Main()

Dim text1, text2, result1, result2

text1 = "Hello World"
text2 = "Hello Rhino"

result1 = Rhino.StringBox("Message1", text1, "Title1")
If Not IsNull(result1) Then Rhino.Print result1

result2 = Rhino.StringBox("Message2", text2, "Title2")
If Not IsNull(result2) Then Rhino.Print result2

End Sub


For the HtmlBox() i´ve used to write the html file to be read to the temp directory and call it from within a plugin or script without having to mess with the registry.

c.

For now all I am after is to show the sting box always at cursor. The crude test (just upper-left corner position coords.) works over here. Does it work on your end with the same key name of …_StringBox of the address is different?
I like the idea of writing HTML file on the fly, too. Thanks for your help!

-j

    Call Main()
Sub Main()

Dim k : k = "HKEY_CURRENT_USER\SOFTWARE\McNeel\Rhinoceros\5.0x64\Scheme: Default\DialogPositions\1c7a3523-9a8f-4cec-a8e0-310f580536a7_4028_StringBox"
Dim wshShell : 	Set wshShell = CreateObject("WScript.Shell")

Call Rhino.GetString("press RMB")

Dim p : p = Rhino.GetCursorPos()(1)
Call wshShell.RegWrite(k & "\top", Cstr(p(1)), "REG_SZ")
Call wshShell.RegWrite(k & "\left", Cstr(p(0)), "REG_SZ")

Call Rhino.StringBox()

End Sub


yes it seems to follow the mouse cursor position but only if i click somewhere on the left of my screen. If i RMB more on the right side of the screen, the dialog size does not fit and it centers the dialog. I guess you`ll need to control the size as well.

c.

Ok, great- good to know it works on your end - it means the address/key is the same.
Right now I am not setting right/bottom values in the test so clicking on the right side of the screen will produce negative size values and Rhino reset the dialog size/postion. Easy fix.

thanks!

-j