|
Sam,
You might want to read "Test Run: Low-Level UI Test Automation," specifically the section "Manipulating the App and Checking App State." by James McCaffrey.
In that section, he has the following code:
public void ClickOn()
{
uint WM_LBUTTONDOWN = 0x0201;
uint WM_LBUTTONUP = 0x0202;
PostMessage( this.ptrToWindow, WM_LBUTTONDOWN, 0, 0 );
PostMessage( this.ptrToWindow, WM_LBUTTONUP, 0, 0 );
} where this.ptrToWindow is an IntPtr that stores the target window's handle.
He then explains about the two last parameters to the PostMessage call.
When processing the WM_LBUTTONDOWN and WM_LBUTTONUP messages, the wParam value indicates whether various key-state masks like MK_SHIFT are down. The lParam value represents the x and y coordinates of the cursor relative to the upper-left corner of the window. Here I pass 0,0 to WM_LBUTTONDOWN and WM_LBUTTONUP in order to simulate mouse clicks on the upper-left corner of the target window without any keys pressed. Hope that helps.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
hmm. is there a way i can just click at the point where the mouse is located (cursor.position)?
thanks for the reply,
sam kline
<a href="http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450">YES</a>
-- modified at 18:43 Sunday 27th November, 2005
|
|
|
|
|
Unfortunately, the only way that I know how to send those mouse-click messages is through the Win32 API methods SendMessage and PostMessage. I mean, to click where the mouse is, you could use the EnumWindows Win32 API call, find which window the mouse is under, do some quick math to get the position relative to the window's (0,0) coordinate, and then send the PostMessage/SendMessage to that relative coordinate.
In .NET, I just don't know any other way because of the security involved. Sorry. Hopefully someone else will give you a more satisfying answer. <grimace>
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
How to create manually DataSet with 3 columns and 3 rows and then make gridView from it?
I have such a code:
DataSet myDataSet = new DataSet();<br />
myDataSet.Tables.Add();<br />
myDataSet.Tables[0].Columns.Add();<br />
myDataSet.Tables[0].Columns.Add();<br />
myDataSet.Tables[0].Columns.Add();<br />
myDataSet.Tables[0].Rows.Add(true,"aaa", "bbb");<br />
myDataSet.Tables[0].Rows.Add(true, "aaa", "Bbb");<br />
dataGrid.DataSource = myDataSet;
Where is myDataSet is DataSet, and dataGrid is gridview with 3 columns, first is checkbox column and other two is text columns.
But this code dont work.
|
|
|
|
|
How about the following code?
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add();
myDataSet.Tables[ 0 ].Columns.Add();
myDataSet.Tables[ 0 ].Columns.Add();
myDataSet.Tables[ 0 ].Columns.Add();
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true,"aaa", "bbb" } );
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true, "aaa", "Bbb" } );
dataGrid.DataSource = myDataSet.Tables[ 0 ];
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
thank you. It helped.
But I still have one little problem. How to make the first column with checkboxes?
I've tried first to make gridView with three columns. and the first was checkboxes. But when I make:
DataSet myDataSet = new DataSet();<br />
myDataSet.Tables.Add();<br />
myDataSet.Tables[ 0 ].Columns.Add();<br />
myDataSet.Tables[ 0 ].Columns.Add();<br />
myDataSet.Tables[ 0 ].Columns.Add();<br />
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true,"aaa", "bbb" } );<br />
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true, "aaa", "Bbb" } );<br />
dataGrid.DataSource = myDataSet.Tables[ 0 ];
Thats adds 3 more columns to my gridView.
-- modified at 12:10 Sunday 27th November, 2005
And i want to make in gridView 3 columns total. And first checkboxes.
|
|
|
|
|
How about this?
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add();
myDataSet.Tables[ 0 ].Columns.Add( "My Bool", typeof( bool ) );
myDataSet.Tables[ 0 ].Columns.Add( "My String 1", typeof( string ) );
myDataSet.Tables[ 0 ].Columns.Add( "My String 2", typeof( string ) );
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true,"aaa", "bbb" } );
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true, "aaa", "Bbb" } );
dataGrid.DataSource = myDataSet.Tables[ 0 ];
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
super! thank you very much!
|
|
|
|
|
No problem, 'gator. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
how can i call a function, run code, etc. when the mouse moves? i looked at on mousemove, but it is only activated when the mouse is over the control.
thanks in advance,
sam kline
http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450
YES
|
|
|
|
|
I don't know if such thing is possible (I never neaded to do something like this). But you can check for mouse movement with the position of the curssor.
Either do a procedure that checks if the current mouse position differs from the previous (and act in consequence) and run it at a timer elaped interval, or try running it on a separate thread that may communicate with your main thread on mouse move (determined by the initial pocedure).
Momentaly I have no time avaliable in order to give you a code example...
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
|
i looked at that article, and used the class. it works perfectly. thanks for the link.
sam kline
http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450
YES
|
|
|
|
|
Sam,
Glad the suggestion worked out for you. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
If you target windows platforms only, it's very easy to use DirectInput.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have 1 form, 1 class and 1 table(from access).
I loaded the info from the table into the class and then added it all to an array list(on the form).
Now on the form i have a list box, with city names(which comes from the dataTable), nd in the dataTable i have some numbers next to each city name.
My question is how can i access these numbers that are stored in my arrayList to put into a formula(or to display when i select a city from the list).
If some can help me i would really appreciate it - this is really important.
|
|
|
|
|
The ListBox can hold any object in its list. You could do something like the following:
listBox.Items.Add( new City( cityName, cityNumber ) );
public struct City
{
public City( string name, int number )
{
this._name = name;
this._number = number;
}
public override string ToString()
{
return name;
}
public string CityName
{
get
{
return this._name;
}
}
public string CityNumber
{
get
{
return this._number;
}
}
} Then, later on, when someone has selected something in the list and you want to know what it is, you can use the following:
City c = ( City ) listBox.Items[ listBox.selectedIndex ]; You can then access the number stored in your City structure.
You can see an example of using this in my article Building the CVS Root File Changing Utility where I store a filename and CVS Root value in each item of the list so that I can later retrieve the information when someone clicks a button.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hey thanks alot that worked...i got a project due tomorrow.
T hanks alot for your help, really appreciate it.
|
|
|
|
|
I like the fact that I could help. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello,
I created a dataGrid based on a parameter query, on the same form of the dataGrid there is a comboBox with values. when I change the selection in the combo I want the DataGrid to change accordingly.
on SelectedIndexChange event for the combo, I send the value as a parameter to the dataAdapter, then fill the dataSet and refresh the dataGrid.
for some reason the grid is not refreshed.
this is my code:
private void re()
{
oleDbDataDetail.SelectCommand.Parameters.Add ("@vak",OleDbType.Integer ).Value=int.Parse(comboBox1.Text );
dataSetDetail.Clear();
oleDbDataDetail.Fill(dataSetDetails);
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{re();
dataGrid1.Refresh ();
}
any ideas?
Thank You!!!
|
|
|
|
|
If I am not mistaking your code will add a suplientary parameter (named "vak") every time a new item is selected in the combo box. But adding I don't think it will replace the old one, it jut will ad a new one. So when you are querrying the database, the result comes from the old (firs seted) parameter.
try using
oleDbDataDetail.SelectCommand.Parameters["@vak"] = int.Parse(comboBox1.Text );
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Hi,
Thanks.
I tried that, but I get a converting type error.
I tried without parsing the value to int, but it doesnt work.
any ideas on how to fix the problem?
thank u!
|
|
|
|
|
The basic ideea is to create your command, add a parameter to it (the parameter must corespond to the database's right value type) and change the parameter value (adding by reference) every time you querry.
If you've done this and still recive erors, in order to be helped post them ...
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Thank you.
I once added the parameter (on load form)
and then assigned a value to it.
Paramters["@vak"].value =.. ...
Thanx again!
|
|
|
|
|
i load a report in CrystalReportViewer.
i want to scroll down by pressing page down, but this event it's not handle by crystalReportViewer.
i used before Crystl32.OCX or Crystal control 9 , with these two control i could scroll down by pressing page down.
Need help ASAP
thx
|
|
|
|