.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Caculate the Point to the Screen?

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
kevinsir
944 Views, 6 Replies

Caculate the Point to the Screen?

Hi,everyone. I want to do something like that.

I draw something one the drawing fisrt,

then open one windows form。

The problem is the form location。I do not want the form cover the graphic what i was drawing before.

Is there anyone could give me some mind about that? Maybe, there is a way to Caculate the Point of the screen by Entity

Position!

6 REPLIES 6
Message 2 of 7
Alfred.NESWADBA
in reply to: kevinsir

Hi,

 

you can get your current mouse-coords (Windows) with that option:

Dim tScreenCoords As System.Drawing.Point = System.Windows.Forms.Control.MousePosition

And if you load your form you can define it's postion by:

Me.Location = tScreenCoords

or if you need any offset

Me.Location = New System.Drawing.Point(tScreenCoords.X + Offset.X, tScreenCoords.Y + Offset.Y)

(where "Me" stands for the form-object-instance)

 

Make sure to set the property .StartPosition of the form-object like that

Me.StartPosition = Windows.Forms.FormStartPosition.Manual

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 7
kevinsir
in reply to: Alfred.NESWADBA

Thanks for your reply! However, set the mouse position as the form location,maybe can solve it when the drawing is from left to right, but drawing from right to left  will be not right!

Message 4 of 7
Alfred.NESWADBA
in reply to: kevinsir

Hi,

 

then you might calculate the position of your text in modelspace (WCS) and use then >>>acedCoordFromWorldToPixel<<< to calculate the position for your form.

 

At >>>this blog<<< from Kean Walmsley you find a method for how to invoke the function from a dotNET application.

Scroll down or use search to find this statement:

[DllImport("acad.exe", EntryPoint="?acedCoordFromWorldToPixel@@YAHHQBNAAVCPoint@@@Z")]

 

Be careful, 32bit and 64bit are different for that declaration:

32bit:  EntryPoint:="?acedCoordFromWorldToPixel@@YAHHQBNAAVCPoint@@@Z"

64bit:  EntryPoint:="?acedCoordFromWorldToPixel@@YAHHQEBNAEAVCPoint@@@Z"

 

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 7

Without P/Invoke it will be possible also with Editor.PointToScreen and Editor.PointToWorld

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 6 of 7

Yeah,It is the answer! However, it is not the point to the Screen, It is the point to the mdi window  of  the Document, I use some transformations, then solve it. Thanks!

Message 7 of 7
DominikHepp
in reply to: kevinsir

Would you mind sharing your transformation code to go from mdi pixel to screen pixel? I have been trying to figure this out... Much appreciate the help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost