|
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.
|
|
|
|
|
Thanks everybody for the responses!!!!!!!
|
|
|
|
|
Hi all,
I'm trying to use a web service with authenticated access. The service returns a session token with every response and the token may change during the session. Operations on the service all follow a simple pattern: They take one argument representing the request, and return an object representing the response. Each operation has a specific req/response associated with it, but requests are derived from a common base class and responses from another. The base classes provide access to the headers, so they are sufficient to manage the session.
The business object I'm writing that uses the service will execute code in multiple threads. Rather than duplicate the thread-synchronization and token-maintenance code everywhere I invoke a service operation, I thought I'd use generics and delegates so the generic method would implement all the things that should always happen and call the delegate to do the specifics.
Since the service's methods all take a request derived from APIRequest and return a response derived from APIResponse, they conform to Func<APIRequest, APIResponse> . Some methods, for example logout, take a request object that contains no information except the request header that identifies the session. I would like to be able to use my generic method, called Invoke, like this:
<br />
public void Logout()<br />
{<br />
if (!HasSession) return;<br />
var r = Invoke(globalService.logout);<br />
...<br />
}<br />
<br />
void keepAlive()<br />
{<br />
TimeSpan margin = TimeSpan.FromSeconds(30);<br />
<br />
while (HasSession)<br />
{<br />
if (sessionLifeLeft > margin) Thread.Sleep(sessionLifeLeft - margin);<br />
Invoke(globalService.keepAlive);<br />
}<br />
}<br />
<br />
I declared the following generic methods to make this possible (the implementation details aren't really important for our purposes here, but I include it as-is since I don't understand why it doesn't work the way I want it to):
<br />
protected TResponse Invoke<TRequest, TResponse>(Func<TRequest, TResponse> method) <br />
where TRequest : APIRequest, new()<br />
where TResponse : APIResponse<br />
{<br />
return Invoke<TRequest, TResponse>(method, new TRequest());<br />
}<br />
<br />
<br />
protected TResponse Invoke<TRequest, TResponse>(Func<TRequest, TResponse> method, TRequest req) <br />
where TRequest: APIRequest <br />
where TResponse: APIResponse<br />
{<br />
APIResponse r;<br />
lock (this)<br />
{<br />
req.header = reqHeader;<br />
r = method(req);<br />
watch.Reset();<br />
reqHeader.sessionToken = r.header.sessionToken;<br />
}<br />
return (TResponse)r;<br />
}<br />
I don't understand why I need to cast the return value; the compiler says I can't implicitly convert APIResponse to TResponse. I understand one can't do so in general, but since "method" returns TResponse already I don't understand why such a conversion would result from my code. But with the cast it builds, but when I try to use it as described above the compiler claims the type parameters "cannot be inferred from usage", which I think is weird since there are only two type parameters and both are well-defined from "method", which takes TRequest and returns TResponse.
I have a hunch this has something to do with me thinking in terms of the *formal* parameters rather than the *actual* (run-time) parameters. Still, I'm wondering if there is any way to achieve the desired outcome: to enable invoking the service operations without having to write the type parameters explicitly. It just isn't very elegant and looks rather redundant to code
<br />
Invoke<LogoutReq, LogoutResp>(globalService.logout);<br />
Can anyone think of a way to make the type inference work out as I wish, from the Func<t, tresult=""> types?
|
|
|
|
|
You need to cast the return value because the compiler does not try to make any assumptions about what may or may not happen to r between the time you store the method return to the time you return it from your method. Since you only intend to put TResponse in, why not just change r to be of type TResponse instead of APIResponse.
As for the second part, how is globalService.logout declared?
|
|
|
|
|
Thank you, that's the sort of simple and rather logical explanation I dared not hope for!
The declaration is
<br />
public LoginResp login(LoginReq request)<br />
LoginResp : APIResponse
LoginReq : APIRequest
However, I've found some worse caveats to deal with. The API has been divided into several services, but one needs data from one service to make requests to the other service - as well as the same session token for both as far as I understand, which means one cannot reliably call both services concurrently. A lot of types defined by the WSDL exist in both services. But of course, when I just generate the proxies all these types end up with redundant definitions in different namespaces. Worse, to invoke an operation in service2 that needs input obtained from service1, I have to waste time and space at run-time as well as write rather boring code like this:
<br />
public Service2.SomeType ToService2Type(Service1.SomeType obj)<br />
{<br />
Service2.SomeType result = new Service2.SomeType();<br />
result.Property1 = obj.Property1;<br />
result.Property2 = obj.Property2;<br />
<br />
result.Property3 = ToService2Type(obj.Property3);<br />
...<br />
<br />
return result;<br />
}<br />
<br />
public Service2.SomeOtherType ToService2Type(Service1.SomeOtherType)<br />
{<br />
...<br />
}<br />
Writing the code is a bore, but I think it's even worse that I cannot avoid the run-time overhead. I guess if I go into the generated proxy code I can change attributes all over the place and use the same types with both services where in fact they match the soap messages, but doing so would be even more of a chore and what if I need to regenerate the proxies some day?
I could perhaps write a separate app that uses reflection to discover the types and generate the code for all those ToService2Type methods, but that of course doesn't remove the run-time overhead.
Not quite as nice as I hoped this API...
|
|
|
|
|
WSDL and all of that is way outside of my experience (and doesn't seem to be something you are really having questions about, just complaints), so I won't speak to that.
Doing a search for "generic delegate inference" showed other people that were having the same problem as you, along with some explanations I will rephrase here. I'm sure I've run into the problem before and just don't remember where. The problem seems to come down to the compiler having to infer too many things at once. The rest of this post is how I assume the general flow of compilation goes, but I am by no means an authority on the compiler.
When you say Invoke(globalService.logout) , the compiler first has to guess what type to make globalService.logout , before it can determine what types to use for Invoke . It will then look to the method signature of Invoke to try to determine what type of delegate to create from the method group globalService.logout . It will see that it is based on a generic parameter, so it can't make any assumptions there. In this case, there is only one possible overload of logout, but there could be more logout definitions, and then there would be no way to know which one you want. The compiler team probably decided it wasn't worth adding the special case for when you have only one overload. One reason against that feature would be that adding an overload to the method would suddenly break previously working code.
Since there are no other parameters, the compiler has no more information to help it determine what types to fill in for the generic declaration and gives up. If you were to change Invoke to be Invoke<TRequest, TRepsone>(Func<TRequest, TResponse> method, TRequest param) , the compiler would then figure it out from the second parameter. It can determine this because you are not allowed to overload methods solely by return type. Thus when it sees the second parameter is, for example, string , the first parameter becomes Func<string, TResponse> which is apparently just enough for it to do the rest of the work itself. As you might guess, giving Invoke a parameter of TResponse will not clear up the error (because you could still have multiple definitions that would match).
|
|
|
|
|
I've referenced a dll made in VB.Net and now I need to inherit from some of the classes in the dll. Below is an example of how I did that:
class Tag : DataProvider.Trend.Tag
{
}
Now if I do like this:
DataProvider.Trend.Tag myBaseTag = new DataProvider.Trend.Tag();
Tag myTag = myBaseTag as Tag;
this results in that 'myTag' gets the value null. Why is that? How can I assign the value of myBaseTag to myTag?
Thanks for help!
|
|
|
|
|
Tag myTag = new Tag();
DataProvider.Trend.Tag myBaseTag = myTag as DataProvider.Trend.Tag;
Because myTag inherite from DataProvider.Trend.Tag.
|
|
|
|
|
Thanks for the reply.
But the problem for me is that I call methods in the dll I mention and they return the type 'DataProvider.Trend.Tag' BUT I need to cast that to type 'Tag'. I don't want to cast 'Tag' to 'DataProvider.Trend.Tag' (the reason is that 'Tag' so that it is accepted by a Web Service).
Thanks again.
|
|
|
|
|