Exposing internal elements

Class library usage, coding and language questions.
david_dawkins
Posts: 6
Joined: Sat Mar 17, 2007 6:50 pm

Exposing internal elements

Post by david_dawkins » Sat Mar 17, 2007 7:19 pm

As the application developer, is there any way for me to expose the locations of items that we're drawing internally to the application? For example, we render meshes inside a Control, and we'd like to be able to click on them.

The only thing I can think of is to have some hidden control whose Text is the name and screen location of all the items we're drawing, and then to parse that text inside the Ranorex app. Is there a better way?

Thanks!
DavidD

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Sat Mar 17, 2007 7:58 pm

david_dawkins wrote:and we'd like to be able to click on them
If you know the location of the item (relative to the upper-left corner of the control) then you can use the ClickControl function:

Code: Select all

Mouse.ClickControl(Control, ButtonType, Location)
Jenö
Ranorex Team

david_dawkins
Posts: 6
Joined: Sat Mar 17, 2007 6:50 pm

Post by david_dawkins » Sat Mar 17, 2007 8:17 pm

Thanks for your reply, but the point is that I don't know the location of the item. I need to query the application and have it tell me that the location is.

So, can you recommend a way for the application to expose this information so that we can read it from Ranorex?

I'm considering adding a SOAP interface to the app so that I can make the query, but I'd like your advice first.

FYI, the application is a 3D model editor, and the items I'd like to click on are items from the 3D world. When a model is loaded, the location of a particular object in the world will have an unpredictable location in terms of screen coords.

Thanks again.
DavidD

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Sun Mar 18, 2007 3:46 pm

david_dawkins wrote:So, can you recommend a way for the application to expose this information so that we can read it from Ranorex?

My first suggestion:

You create dynamically an unvisible control object for every 3D model item and set the properties in the application:
(Code in your model editor application)

Code: Select all

System.Windows.Forms.Control modelControl = new System.Windows.Forms.Control();
modelControl.Name = "modelControl";
modelControl.Text = "modelControl";
modelControl.Location = new Point(180, 200);
modelControl.Size = new Size(50, 60);
modelControl.CreateControl();
modelControl.Visible = false;
this.Controls.Add(modelControl);
You search the 3D model items in your test application with the function form.FindControlName and read the properties with Ranorex:
(Code in your test application)

Code: Select all

Control modelControl = form.FindControlName("modelControl");
if (modelControl != null)
{
    Mouse.ClickControl(modelControl);
    Console.WriteLine("  Handle={0} Location={1} Text={2}", 
            modelControl.Handle, modelControl.Location, modelControl.Text);
}
Jenö
Ranorex Team