|
When I hittest for a location where a button is, i get ButtonChrome or TextArea. Now I know why, but how do I find 'Button' through code. There is e.Source and e.OriginalSource through the eventargs but for my specific implementation those won't ever return Button as any one of them. Is there another way of finding the Parent of ButtonChrome/TextArea from the HitTestResult?
The reason why the eventargs won't ever have that value is because i'm working with custom input (multitouch screen to be exact). So it doesn't come through the framework. Except if you can propose a better way to start the input. At the moment it starts at the Canvas level. No higher.
thanks in advance.
donovan
rather have something you don't need, than need something you don't have
|
|
|
|
|
Hi Donovan,
cant you turn the touchscreen event into a regular mouse event (or sequence of mouse events) ?
I havent any experience with touchscreens, but I would expect you want to use it like a
mouse, so why not have it do a SendMessage(WM_...) to the active form. In that way
all the Windowing logic would work for you.
What is it the touchscreen vendor provides ? how does he justify a different API ?
|
|
|
|
|
there is no vendor.everything is custom created. the screen works like the ms surface computer.but my code at the moment works ok,i can touch and manipulate images because hittest returns a system.windows.controls.image. but a button returns buttonchrome so there is no way to solidly check the control type to be able to raise the correct event.
i cant check for buttonchrome because it can change depending on the UI styling.
this is all WPF.
rather have something you don't need, than need something you don't have
|
|
|
|
|
OK, about no vendor.
I am not familiar with WPF, ButtonChrome and such.
But my basic question remains: I assume your touchscreen generates some events when
touched/dragged/etc., can't you just turn these into the regular Windows commands
and inject them with SendMessage or something similar (or are these all gone in WPF ?) ?
In Win32 and everything before WPF (and maybe, not sure, also in WPF) events get sent
to a Window, and if necessary that window will forward the events to its controls,
so you typically never have to "dispatch" them yourself. Turning your touchscreen events
in mouse events should give you the same thing.
I suggest you have a look at the old mouse_event function, and the recent SendInput function.
That is the way I would investigate. If that makes things easier, you could do first
experiments on a regular PC, just turn some keyboard actions into mouse actions
with one of the functions I mentioned; then substitute the touchscreen for those
keyboard events.
Hope this helps.
|
|
|
|
|
Is there a property of the Text Box that tells you the line and column of the cursor? And also, is there an event that tells you when these properties have changed? I've looked for both, but I can't seem to find them. I'll look again, to make sure...
If I had a sig, it would probably go here.
|
|
|
|
|
There are two properties for selected text, something like SelectionStart and SelectionLength. The first one will give you the cursor position, but not line position in a multiline text box.
I don't think there's an event that's fired whenever any property is changed.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
There's the SelectionChanged event. This event is fired when the cursor is moved (because the cursor basically is a selection with SelectionLength==0 )
You'll have to calculate the line and column yourself from the given SelectionStart property.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks guys! Here's what I ended up doing...
<code>
char[] before = textBox.Substring(0, textBox.SelectionStart);
int lineBreaks;
int lastLineIndex;
for (int a = 0; a < before; a++) {
if (before[a] == '\n') {
lineBreaks++;
lastLineIndex = a + 1;
}
}
cursorPositionLabel.Text = "Ln " + lineBreaks.ToString()
cursorPositionLabel += " , Col " + (textBox.SelectionStart - lastLineIndex).ToString();
</code>
So much for preserving the tabs...
If I had a sig, it would probably go here.
|
|
|
|
|
please help me
I want to insert new rows into the DataGrid for WindowsCE4.2 Application using c#2003
-- modified at 6:06 Sunday 22nd July, 2007
|
|
|
|
|
Is there a way to stop the form from closing within its OnClosing event? I'm making a program that asks if you really want to close it when you press the "x". So I've got a dialog that pops up and conditional statements for whichever button is pressed in the dialog, but I'm not sure what to put in the conditional statements to make the form stop closing. Could anyone help me out with this?
If I had a sig, it would probably go here.
|
|
|
|
|
Yep:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult result = MessageBox.Show("Are you sure you wish to cancel?", "Cancel?", MessageBoxButtons.YesNo);
if (result == DialogResult.No)
{
e.Cancel = true;
}
}
"It was the day before today.... I remember it like it was yesterday."
-Moleman
|
|
|
|
|
yes, see martin's reply. Thats exactly why the Closing event exists, so you can prevent
a Closed event from happening.
|
|
|
|
|
Thanks guys!
If I had a sig, it would probably go here.
|
|
|
|
|
You're welcome.
max29297 wrote: If I had a sig, it would probably go here
You probably mean: I'm happy I dont need a sig anymore...
|
|
|
|
|
lol, yeah, right
If I had a sig, it would probably go here.
|
|
|
|
|
HELLO!!!
Is it possible to remove one item from listview without reloading, refreshing?
Thanks.
One nation - underground
|
|
|
|
|
This will remove the first selected item from the list view.
if (myListView.SelectedItems.Count > 0)
myListView.Items.Remove (myListView.SelectedItems[0]); /ravi
|
|
|
|
|
I think a javascript will help if you want it without reloading!
I was born dumb!!
Programming made me laugh !!!
--sid--
|
|
|
|
|
Ok here is the problem. I am developing a server in C and a client in C#. The server send streams of data to the client, and the client is responsible for decoding and interpreting these stream. So, if I send a simple "Hello world" from the server to the client, it works. If I send a byte representing an integer (I use memcpy) I can decode it in the client. But, the problems start when after some integers, I also put a string. If I put 2 bytes, each representing some number, I am still able to decode the string that follows using:
System.Text.Encoding.ASCII.GetString(buffer,2,length)
But if I say 3 bytes, and then the string, I don't get anything (yes, I said buffer,3,length to reflect the server changes), I get garbage.. Can anyone please help me? Thank you.
|
|
|
|
|
What kind of "garbage" do you get?
I think that we have to see some code in order to tell what's wrong with the code...
---
single minded; short sighted; long gone;
|
|
|
|
|
Okay then.
Here is the server
memcpy(msg,&type,1);
memcpy(msg+1,&nr,1);
memcpy(msg+2,&online,1);
memcpy(msg+3,&p,sizeof(p));
type is 2, nr is 4 online is 0 and p is "Hello world". And on the client I get some unrecognizable characters (those squares you sometimes get). BUT, when online is 1 the string stays in one piece.. What am I supposed to make of this?
|
|
|
|
|
if only you had shown the client code and the server code in one message...
and, if at all possible, the hex representation of these data bytes arriving at the client.
|
|
|
|
|
But I already showed more than enough. Since I am able to transmit messages between the server and the client THERE IS NO PROBLEM HERE. Anyway, the server uses fprintf and the client uses BeginReceive - EndReceive (IAsync bla bla).
The problem is the way I am handling the array of bytes coming from the server. I suspect EndReceive thinks that a 0 means \0 (as in end of string). So it stops there. I don't know why this happens..
|
|
|
|
|
nc3b wrote: But I already showed more than enough
Sorry for trying to help you.
Debug Rule #1: when the system does not perform as designed, at least one element is wrong,
and it could be anything; not a single assumption is beyond scrutiny.
|
|
|
|
|
nc3b wrote: But I already showed more than enough.
I haven't seen a single line of the code that recieves the message.
nc3b wrote: Since I am able to transmit messages between the server and the client THERE IS NO PROBLEM HERE.
Just because some code works in some cases doesn't automatically mean that it works in all cases.
nc3b wrote: I suspect EndReceive thinks that a 0 means \0 (as in end of string). So it stops there. I don't know why this happens..
I don't know why it happens either, as I don't know if you use BeginRecieve and EndRecieve correctly.
---
single minded; short sighted; long gone;
|
|
|
|