|
for redirecting it is possible if it doesn't use direct IP accsess
C:\WINDOWS\system32\drivers\etc
inside there is a file named host (Without extension).
You can redirect a specific DNS name to specific IP
If you type www.google.com it will automatlcly go to 209.85.129.147, because it is on DNS server.
If you put in host file
127.0.0.1 www.google.com
and then you save that file.
After that all links that try to use www.google.com will look only on your machine. (127.0.0.1 is localhost)
For monitoring look at Packet Monitor C#[^]
|
|
|
|
|
Thanks! I will try this
Motivation is the key to software development.
|
|
|
|
|
How can I do it? I have a custom borderless form that I want to not overlap the taskbar when maximized, and I was told that it is possibly to prevent that through the use of WM_GETMINMAXINFO + WndProc. Is it really possible, and if so, how?
Thanks.
|
|
|
|
|
Are you coding in C#?
As i see your question, it shoud belong into c/c++/mfc board
|
|
|
|
|
Yes, I'm very much coding in C#.
|
|
|
|
|
I would do this whay:
this.FormBorderStyle = FormBorderStyle.Sizable;
this.WindowState = FormWindowState.Maximized;
this.MaximumSize = this.Size;
this.FormBorderStyle = FormBorderStyle.None;
This whay it can be seen with a border with less than a second. If you want to avoid and get the screen size, you need to use PInvoke of SystemParametersInfo with Constant SPI_GETWORKERAREA
and you could get the size of worker area. Also there can be problems when you have AutoHide enabled for taskbar. If you have then i suggest using PInvoke to constantly monitor changes when it apears or dissapears
|
|
|
|
|
> PInvoke to constantly monitor changes when it apears or dissapears
Please elabroate on that one.
|
|
|
|
|
|
Sorry, but those didn't really help me.
Any ideas on WM_GETMINMAXINFO?
|
|
|
|
|
protected override void WndProc(ref Message m)<br />
{<br />
if (m.Msg == 36)
{<br />
}<br />
base.WndProc(ref m);<br />
}
this is from sdk:
The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.
A window receives this message through its WindowProc function.
You can also look into events as ResizeBegin and Move. Althou when i have overriden WndProc, my Form didn't open
Why it didn't help. I have tested and my taskbar wasn't hidden.
|
|
|
|
|
Hmm, I probably did it wrong then. Can you show me your code?
|
|
|
|
|
this.FormBorderStyle = FormBorderStyle.Sizable;
this.WindowState = FormWindowState.Maximized;
this.MaximumSize = this.Size;
this.FormBorderStyle = FormBorderStyle.None;
I used this code in on load event. When i set the form Maximum size, even if you maximize it won't go beyond MaximumSize property
|
|
|
|
|
Thanks, that worked. Love you
|
|
|
|
|
I do have code which is reading the data from an excel sheet properly. but have a weird issue.
If the excel sheet has a column containing long numbers data eg. 89.00000001 and if that column is not resized to its max, that cell is displaying "#####" if you open the excel sheet. So my application code is also reading it as "#####" instead of the correct data. If i resize that column to display the data properly and save, then my application code is reading the data correctly.
I can have my users to have the input excel sheet have all the columns maximized, but was wondering if there any way to have it done programmatically.
Do let me know.
My code snippet is :
// get data in cell
for (int i = 2; i <= iValue; i++)
{
dr = ds.Tables["dtExcel"].NewRow();
for (int j = 1; j <= jValue; j++)
{
oRng = (Microsoft.Office.Interop.Excel.Range)oSheet.Cells[i, j];
string strValue = oRng.Text.ToString();
dr[j-1] = strValue;
}
ds.Tables["dtExcel"].Rows.Add(dr);
}
return ds;
Thanks
Prasanna
|
|
|
|
|
PrasannaKulkarni wrote: 89.00000001 and if that column is not resized to its max, that cell is displaying "#####" if you open the excel sheet. So my application code is also reading it as "#####" instead of the correct data.
This isn't really possible unless you've doing something very wrong. If you get the Value of the cell, you get the value. The "######" you see is strictly limited to the display of the value, not the value itself.
As I look at your code, I see you're getting the Text property of the cell, not it's Value.
|
|
|
|
|
appreciate your so quick response.
Me excel document has everything from text values to numeric values. Whats the right way to read the data?
Prasanna
|
|
|
|
|
Read both and analyze what you've got. You should already expect certain types over values in certain ranges of cells. If you expect a certain cell to have a numeric value, you should only be looking at the Value property of that cell. You still need to validate what you get from it though.
|
|
|
|
|
Please could somebody help... My brains gone dead
I'm trying to pass the following to a wcf service
public IList<tbItem> GetItemsWhereIn (IList<tbClass> iclass)
{
iServiceClient svc = new iServiceClient();
IList<tbItem> list = svc.FindItems(iclass);
return list;
}
The problem is passing parameter iclass to svc.FindItems
error Cannot convert from system...IList<tbClass> to tbClass[]
The wcf service is setup as
public interface iService{
[OperationContract]
List<tbItem> FindItems(IList<tbClass> iclass);}
And the linq query as
public List<tbItem> FindItems(IList<tbClass> iclass)
{
...linq code working correctly
}
If you could point the way I would be very greatful
|
|
|
|
|
I think you need to tell the Client Service Reference to generate the Client proxy using genertic Lists rather than arrays (Lists<T>, IList<T> and other collection types are normally sent up and down the wire as T[] unless you tell the service reference to generate the proxy with something else:
- Right click your service reference
- Select Configure Service Reference
- In the Collection Type drop down select System.Collections.Generic.List
Note that you can't set the Value to IList<T> as Services don't play well with Interfaces / OO in general.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
Thanks for answer, this did the trick
I just needed to then change this line
IList<tbItem> list = svc.FindItems(iclass.ToList());
|
|
|
|
|
I have a List<MyClass> I use this list to populate a combo box so that the user can select an item from the list, and I can easily grab which one they selected:
onSelectedIndexChanged(...)
{
this.currentItem = this.comboBox.SelectedItem as MyClass;
}
The strange thing is, when you first select an item from the list, the box doesn't display any text. If you select the same item again, it does.
The box will only display the correct text if you select the same item twice in a row, and everything works as normal when I don't set this.currentItem
Upon further testing it seems to happen when I access properties on the instance of MyClass right after selecting it. If I comment out a bunch of code the combo box works fine, although it's only reading a few values nothing is actually being changed, not that I see how it could make any difference.
Does anybody have any idea what's going on?
EDIT: I know what it was, purely my fault. When an item was selected a numeric up down control was set with a value from that item, this triggered the ValueChanged event, which reset the value back to the item, and triggered Sort on my list, which clears out and refills the combo box with the items in the new order. Bit of a pain in the arse really, I must pay more attention in future
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
modified on Friday, October 2, 2009 10:15 AM
|
|
|
|
|
Hi.
I got a server and a client application. Server sends bytes to client in TCP. But the problem is that it's "too fast" I mean in a way. For be more specific. I have objects of a class (in a List) in the server side, I format that to xml string, and then format the string to bytes and send this byte array.
//Client:
NetworkStream = new NetworkStream(SocketClient);
while (ListOfObjectToSendOut.Count > 0)
{
NetworkStream.Write(BytesToSend, 0, BytesToSend.Length);
NetworkStream.Flush();
Thread.Sleep(100);
}
//Server:
TcpClient myClient = new TcpClient("localhost", 8000);
NetworkStream NetworkStream = myClient.GetStream();
byte[] bytes = new byte[3000];
while (true)
{
int IncomingByteLength = NetworkStream.Read(incomingBytes, 0, 3000);
}
You can ask, what's my problem?. Let's say that the Object I want to send is 150 bytes long. And I want to send out 5 Object. My problem that i need to happen this in an order like this:
Write 150 byte
Read 150 byte (and than "unformat" it)
Write 150 byte
Read 150 byte (and than "unformat" it)
and so on.
With this way I could unfomate the 150 byte in the Client side.
BUT!!! In a real world it will write out 150 byte and 150 byte again and so on and THAN the Client will Read 450 or 600 or 750 bytes. It is imponderable. And I CAN NOT unformat 300 or 450 ... to my Object. So the Flush doesn't flush it (I read in msdn that it is ok, cause flush wont do anything with the networkstream)So the problem is that the Server sends out 150 bytes and send out the next 150 bytes so fast that the Client will read those together (for example 300 bytes), which is not good.
I need to READ THIS "PACKAGES" SEPARATE in the client side.
- I can solve this to write a Thread.Sleep(100) but i dont want to do that, It would be to slow!
- I can solve this proble using UDP, but i dont want to use UDP.
- I could solve this porblem with a a solution like:
Take a sign byte after every 150 byte, and seperate in the client side by that sign. And then format the bytes back. But I dont want to do that.
- I tried Socket.NoDelay doesn't help
- I tired close and dispose and than make it again the networkStream in EVERY loop. It doesnt help.
Now all you programmers, here is a big deal, Who is the Best Programmer? What can I do? (I hope you can understand my problem )
Thanks!
|
|
|
|
|
Dataflow control and message separation are important aspects of all serial communication. There are a couple of solutions:
1.
keep the consumer in charge, i.e. let the consumer ask for specific data, only then the producer delivers said data, and finally the consumer reads and processes it.
Pro: is simple
Con: slow-down due to back-and-forth conversation
2.
choose a data format that allows for message separation at the receiver side; e.g. insert a unique character (not always easy or even possible, may require an escape mechanism, etc); or use a "protocol" that predicts the useful length of the message (length+content, as in Pascal strings). So now the producer can produce many messages, they all are separable.
Pro: one-way communication, no slow-down
Con: somewhat more complex as the consumer may read too much data, needs to process what amounts to one message, and then somehow recirculate whatever extra data he already got. Kind of a push back, as in LALR parsers. Easiest way is by copying the remaining data to the beginning of the receiving buffer; there are schemes without copying, a round-robin buffer would be one of them.
You may want or need a real dataflow control on top of (2), as it does not solve the consumer overrun by producer situation.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Something which you might find useful is serializing all of your objects to the Stream and deserializing them in order. If you don't want to do that, then perhaps you could repeatedly read the data into a buffer of 150 bytes; as a heads-up, this implies that the data length is known by both sides.
|
|
|
|
|
Luc is leading you in the right direction. In my job we do lots of serial and TCP/IP connection between PC's and various devices. We use both methods he suggests but more often than not the protocols we develop have some start character and stop character to delineate the message. The characters that are meant for this purpose are hex 0x02<stx>(send transmission) and hex 0x03<etx>(end transmission). These characters work well as neither are printable characters so it is unlikely that you would be sending them in a normal message. If you really want to get picky and guarantee that the data you receive is the same as the data you sent you should be using some form of error checking such as cyclic redundancy check. If you want to do error checking I would recommend using the send/acknowledge system so that your client can let the server know if it got good data and if not it can send a negative acknowledgement to let the server know it needs to resend the data.
If you always know how many bytes you are expecting you can always just read that many bytes out of your receive buffer and process them, then go back and read more bytes etc... this might be a simpler solution if you don't want to build some sort of protocol, just be sure that your buffer size is large enough that it won't overflow.
|
|
|
|