Find Mouse Position in Drop Event?

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
Posts: 7
Joined: Tue Mar 01 2011

Find Mouse Position in Drop Event?

Post by pdfuser » Fri Apr 01 2011

I'm using the PDF Creator viewer control on a WinForm and would like to have a user be able drag a control onto the viewer, and create a sticky note at the location where they dropped the control. How can I determine the position of the mouse pointer so that I can place the sticky note there?

I've had no luck converting the pixels passed in the DragDrop event to twips. And, when I try and get the document position using Document.CurrentPage.Coordinates, I get some really large numbers like 102210409 for X and 30172944 for Y when dropping to the center of the document.

Any help would be appreciated.

Posts: 1
Joined: Mon Apr 11 2011

Re: Find Mouse Position in Drop Event?

Post by roger.k » Mon Apr 11 2011

The PDF Creator control has several events that are fired in response to mouse events. These events can be handled in the host application. Some of the handlers will have parameters that include the position of the mouse on the PDF page in TWIPS.

For a detailed description of these events and their parameters please see the online documentation.

To determine the position of the mouse pointer you can use the following method which uses the MouseDownEvent.

Code: Select all

	private int m_pdf_FireMouseDown(object sender, IacEventArgs e)
		if (m_bAddNote) //flag that is set by the host application to indicate that a note is to be added on the next MouseDownEvent
			string givenName = "noteName1";
			m_pdf.Document.CurrentPage.CreateObject(IacObjectType.acObjectTypeStickyNote, givenName);

			IacObject note = m_pdf.Document.ObjectByName(givenName);

			int noteWidth = 1500; //choose your default width
			int noteHeight = 2000;//choose your default height

			//set note's coordinate attributes
			note.AttributeByName("Left").Value = e.x;
			note.AttributeByName("Top").Value = e.y;
			note.AttributeByName("Right").Value = e.x + noteWidth;
			note.AttributeByName("Bottom").Value = e.y + noteHeight;

			note.AttributeByName("Note Left").Value = e.x;
			note.AttributeByName("Note Top").Value = e.y;
			note.AttributeByName("Note Right").Value = e.x + noteWidth;
			note.AttributeByName("Note Bottom").Value = e.y + noteHeight;

			note.AttributeByName("Icon Left").Value = e.x - (int)note.AttributeByName("Icon Right").Value;
			note.AttributeByName("Icon Top").Value = e.y - (int)note.AttributeByName("Icon Bottom").Value;
			note.AttributeByName("Icon Right").Value = e.x + (int)note.AttributeByName("Icon Right").Value;
			note.AttributeByName("Icon Bottom").Value = e.y + (int)note.AttributeByName("Icon Bottom").Value;

			//set remaining note's attributes as you 
			note.AttributeByName("Author").Value = "<Author/Title>";


			m_bAddNote = false;
		return 0; //do not run internal default behavior for this handler
This is where the documentation on the remaining events can be found: ... #index.htm

Hope this helps

Post Reply