|
hmm dont really know much abt hardware..
i just connect a serial from com 1 to com 2 of the same computer. and use hyper terminal on com 2 to check the input
|
|
|
|
|
Yes, he needs a null modem cable, which is wired to deal with the problem you're describing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a WinForm that calls Func1() and Func2 in the Form1_Paint handler.
I also have a "Clear" button that sets a bool flag to false which then in
turn sets false the bool flag in the code that draws the two lines, BUT leaves my Form intact- that is the axes, labels etc...remain. Just the lines
are removed.
The line coordinates are based on TextBox values, converted to double and passed in to the DrawLine(.. funcs.
Q. Is there some way to only change/erase just one line at a time?
thanks......................
|
|
|
|
|
If you're drawing lots of lines, you could add them to an arraylist, and remove them when you delete them, or if you want to redraw them, put a flag on each to say if it should be drawn or not. There's no way to erase them per se, you simply do not draw them if you don't want them.
If you have two lines and you just want to choose which ones to draw, use an enum instead of a bool so you can store multiple states.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
call Invalidate(rect), in place of Refresh(void) or Invalidate(void).
the rect parameter with is the rectangular area your line covers
This will change the only line also reduce the waste repainting efforts taken by processors in redrawing whole window
Cheers
|
|
|
|
|
this may be a long winded a unefficient way to do it, but couldnt u get the co-ords of the line u want to erase and simply re-draw it, but in white (or ur background colour), effectly "erasing" the line visually.
another way is to maybe clear the whole area ur drawing on, then re-draw the line u want to keep.
i know both are basically quick fixes, not the best way to approach it, but they' work
|
|
|
|
|
Hi All,
I have the following problem:
After sending a Write command to a device, directly followed by a Read command it seems that the data on the device is not yet available.
It seems that the write/read part is too fast for the device to 'generate' the data.
<br />
port.Write("some request");<br />
<br />
char[] cData = new char[port.BytesToRead];<br />
port.Read(cData, 0, cData.Length);<br />
strTemp = new String(cData);<br />
The baudrate is 9600 and cannot be set any higher.
Also i would not like to add a pause like:
System.Threading.Thread.Sleep(1000);
It's unknown how large the buffer is, so it could well be beyond 1 second, but could be much less too.
Does anyone have a solution here ?
Thanx,
Jan
-- modified at 19:09 Thursday 8th September, 2005
|
|
|
|
|
You could have the client send something to the server(or machine sending information) telling that it is finished.
Are you using StreamReader/StreamWriter?
|
|
|
|
|
Hi ExpertComing,
I'm using System.IO.Ports.SerialPort from the 2.0 Framework.
Not using streamreader/writer.
thanx for the answer,
Jan
|
|
|
|
|
Just keep reading until you get the data. Stop reading when you have the amount of data you need. Discard all the zero's at the beginning that you don't need.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Thanx Willem,
The problem is that i don't know how much it is upfront.
Logic is like this:
a) send request
b) get requested data
c) use requested data in another routine
there is no real end-of-transfer charcter to look for.
Also, after the request the device will not do anything (data-wise) until a new request is sent to the device.
What would be best here?
Something like:
1) send request
2) read data in loop until it has null or timeout?
Did you or anyone else have the same problem to tackle?
Thanx,
Jan
|
|
|
|
|
I used a little more complex protocol on the device I was communicating with.
It's a little problematic when you don't get an end-of-transfer character or something like that.
You could try reading in a loop until you get null. That should work perfectly well in this situation.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Bedankt Willem,
i'm not requesting any source code but what specific subject should i google on for something similar like my 'problems'?
Tanx,
Jan.
|
|
|
|
|
I had this problem myself, I can demonstrate how you make a loop, however I don't know how the comport component of visual studio 2005 works.
byte? data;
while(data != null) {
}
WM.
What about weapons of mass-construction?
|
|
|
|
|
looping it is
Will need to test and see if there is any logic in termination of a stream or some kind of end-character.
Thanks.
|
|
|
|
|
I am trying to name a label using a string.
string labelname = "lbl" + skill;<br />
(Label)labelname.Text = skill;
That is the code, I get an error saying "'string does not conatian a definition for 'text'" The error makes sense, and I know why I am getting it, but how do I tell the system that string labelname is going to become Label labelname?
|
|
|
|
|
You can't. You can't turn one object into another. You need to *create* a label, then set it's Text property.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have the label created, I just want to use the string to tell which one I want to set the text for.
|
|
|
|
|
Then why are you trying to cast the string to be a label, instead of using the label itself ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Because I am programming dynamically. I have the skills(which is where the variable skill comes from) in a database. I read the skills out of the database, into a variable, create a label, and now I want to set a label to say the skill.
Ex.
string skill = "Attack";
//Create the label
// The label is called lblAttack
I want to make the label say
Attack:
How?
Thanks Christian
|
|
|
|
|
lblAttack.Text = skill;
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Lol!
I don't REALLY know that the label is going to be "Attack", the database may change. I have a foreach statement that goes into the database, and sets an array(the array is where I really store the skill). I need to be able to do this:
lbl(skill).Text = skill;
But in a way that is acceptable, I don't have to do it that way either, just some way that is dynamic.
|
|
|
|
|
ExpertComing wrote:
I don't REALLY know that the label is going to be "Attack", the database may change
Obviously, but I followed your example, and the fact that you tried to cast a string to a label left me thinking this was what you needed to know.
ExpertComing wrote:
lbl(skill).Text = skill;
You can't name your variables locally like that. You CAN set their ID and tag values in this way.
You need to create a new Label ( just look in the InitializeComponent part of an app with a label predefined to see all the stuff you need to set ), then you can set it's text, and it's id/tag properties.
Oh, is this Winforms, or ASP.NET ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ASP.NET, that is the problem.
|
|
|
|
|
OK - well, you need some sort of placeholder in your page, so you know where the labels will end up. The way to add a control to an ASP.NET page is to add it to the controls collection of the item that is to be it's direct parent.
If all you're doing is showing a bunch of labels, I'd be more included to use a repeater or datagrid, and bind it to your data source. Will that not work for you ?
Christian Graus - Microsoft MVP - C++
|
|
|
|