State of a window

Class library usage, coding and language questions.
[email protected]
Posts: 2
Joined: Fri Nov 24, 2006 2:48 pm
Location: Italy - Ivrea
Contact:

State of a window

Post by [email protected] » Fri Nov 24, 2006 3:06 pm

Hi,
I've found a problem working with a window belonging an application of mine written in C++.NET; so I'm using RanorexNet.dll
I got the element of the window this way:

Code: Select all

pSubWindow = pForm->Element->FindChild( Ranorex::Role::Client, "XXX" );
pButtonEl = pSubWindow->FindChild( Ranorex::Role::PushButton, "Save" );
Then i use it:
First time I enter this piece of code everything works ok and the pSubWindow->State is set to Focusable. Then I hide this window, show it and I got pSubWindow->State set to Invisible and the pSubWindow->GetChildCount is set to zero, the pButtonEl results undefined.
What's wrong? Please help

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

Post by admin » Sun Nov 26, 2006 5:54 pm

I couldn't reproduce this issue with some sample applications, it's possible, that your window will be destroyed and new created.
If so, then it gets a new handle and you can't use the old object references, you must find the form and the element again after the show operation.
This can happen with some .NET Framework 2.0 controls.

Please try it and inform me about the results.

Jenö Herget
Ranorex Team

[email protected]
Posts: 2
Joined: Fri Nov 24, 2006 2:48 pm
Location: Italy - Ivrea
Contact:

State of a window

Post by [email protected] » Mon Nov 27, 2006 9:41 am

Hi Jenö,
here I post some code hoping it could help:

Code: Select all

		pToolStripEl = pControl->Element->FindChild( Ranorex::Role::ToolBar, "toolStrip1" );
		nIndex = 0;
		pButtonEl = nullptr;
		while ( pElement = pTableElement->FindChild( Ranorex::Role::RowHeader, String::Format( "Row {0}", nIndex ) ) )
		{
			// Click the row
			Mouse::ClickElement( pElement );
			// Click on the modify button
			Mouse::ClickElement( pToolStripEl->GetChild( 1 ) );
			{
				Application::Sleep( 1000 );
				pSubWindow = pForm->Element->FindChild( Ranorex::Role::Client, "Articles" );
				//pSubWindow = pForm->Element->FindChild( Ranorex::Role::Window, "Articles" );
				Trace( "Window state: {0}", pSubWindow->State );
			} while ( pSubWindow == nullptr && nTries-- );
			// Click on save
			pButtonEl = pSubWindow->FindChild( Ranorex::Role::PushButton, "Save" );
			Mouse::ClickElement( pButtonEl );
			nIndex++;
		}
Even if the window is destroyed, it's catched again. But the state is wrong.
I'm working with .NET 2.0.50727
Thanks for your hints, wish your well,
Roberto

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

Post by admin » Tue Nov 28, 2006 8:11 am

The problem is, that i don't know what your application exactly do. Can you send us please a simple application and your managed C++ test code.

We will debug it and send you the results.

Jenö Herget
Ranorex Team