[Closed] DotNet Form Location?
Hi
Is there any way to set form position before he is open?
I can change it after, but the jumping effect is not to good
try(form.close())catch()
(
local form = dotnetobject "System.Windows.Forms.Form"
form.width = 200
form.height = 200
form.Show()
form.location = dotnetObject "System.Drawing.Point" 200 100
)
If I put this line form.location = dotnetObject “System.Drawing.Point” 200 100 inside of code then happens nothing.
I ran into this as well and just lived with it, would like to know if there is a way to handle that.
try(form.close())catch()
(
fn onload sender args=
(
sender.location = dotnetObject "System.Drawing.Point" 745 345
sender.width=500
sender.height=500
)
local form = dotnetobject "System.Windows.Forms.Form"
form.width=200
form.height=200
dotnet.addeventhandler form "load" onload
form.Show()
)
Hi Pete
Cool!!! Its working with this way (Is there a small delay ,but is mutch less). Thanks Man
try(form.close())catch()
form = dotnetobject "System.Windows.Forms.Form"
form.width = 200
form.height = 200
form.StartPosition = form.StartPosition.Manual
form.Location = dotnetObject "System.Drawing.Point" 200 100
form.Show()
Thats It! form.StartPosition = form.StartPosition.Manual
It was there?
Im searched all properties but I miss it oh man
Thank you very much Denis.
Sorry to bring this old topic up, but I have a question pertaining to this somewhat.
I am trying to get the position/size of a dotNetObject:System.Windows.Forms.Form
But I’m sure alot of you know, it’s not super straight forward… at least for me :hmm:
I basically want to get the Pos/Size of the Form, and then store that in a global, so I can apply it back to the form when it gets created again so it will be in the same spot with the same size if need be.
I have an EventHandler that, on close, could get/save the info.
I would use a regular max rollout/form, but I need to get transparency…
Thanks!
M
form.bounds will get you both. It returns a “system.drawing.rectangle” and be applied back the same way.
Cool. I looked at bounds before, but didn’t actually get back numbers, so I wasn’t sure what was going on.
Although… can I seperate out only the pos or size and not all of it?
I am wanting to make something where on a button press, it takes the pos and adds diff values to X and Y, then the same for the Width/Height.
I am doing this, because I want to get the area inside the Form, excluding the border. So I am taking the size of the form, taking off 20 from the width, and 40 from the height, then adding back to the X,Y pos to re-center it.
Ok, I answered my own question, heh.
For anyone else having issues with this, this is how u extract the y,x pos and width / height
test = <formname>.bounds
–Typing these into the listener, or assigning to a variable will give u the the info.
test.width --( form width)
test.height -- ( form height)
test.location.x --( form pos X)
test.location.y --( form pos Y)
yay