.NET

Reply
Valued Contributor
kevinsir
Posts: 78
Registered: ‎08-20-2012
Message 1 of 7 (351 Views)
Accepted Solution

Caculate the Point to the Screen?

351 Views, 6 Replies
04-03-2013 01:56 AM

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!

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

*Expert Elite*
Alfred.NESWADBA
Posts: 9,070
Registered: ‎06-29-2007
Message 2 of 7 (346 Views)

Re: Caculate the Point to the Screen?

04-03-2013 02:26 AM 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
-------------------------------------------------------------------------
Valued Contributor
kevinsir
Posts: 78
Registered: ‎08-20-2012
Message 3 of 7 (340 Views)

Re: Caculate the Point to the Screen?

04-03-2013 02:36 AM 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!

*Expert Elite*
Alfred.NESWADBA
Posts: 9,070
Registered: ‎06-29-2007
Message 4 of 7 (333 Views)

Re: Caculate the Point to the Screen?

04-03-2013 03:11 AM 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
-------------------------------------------------------------------------
Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 5 of 7 (316 Views)

Re: Caculate the Point to the Screen?

04-03-2013 10:47 AM in reply to: Alfred.NESWADBA

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


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
kevinsir
Posts: 78
Registered: ‎08-20-2012
Message 6 of 7 (275 Views)

Re: Caculate the Point to the Screen?

04-07-2013 01:14 AM in reply to: Alexander.Rivilis

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!

New Member
DominikHepp
Posts: 1
Registered: ‎05-08-2012
Message 7 of 7 (152 Views)

Re: Caculate the Point to the Screen?

01-20-2014 11:55 AM 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.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.