|
Setting Form.WindowState to FormWindowState.Maximized doesn't work?
( too lazy to try right now )
best regards,
David 'DNH' Nohej
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
|
oh, I see. Strange behaviour! anyway, I was playing with it... I don't whow what exactly are you doing, bt I made this work:
<br />
private void timer1_Tick(object sender, System.EventArgs e)<br />
{<br />
if(m_popUpForm.IsDisposed)<br />
{ <br />
m_popUpForm = new Form();<br />
} <br />
m_popUpForm.WindowState=FormWindowState.Maximized;<br />
m_popUpForm.Show();<br />
}<br />
where m_popUpForm is protected member and it's basic Form class.
It pops up maximized nicely every tick event... even when "parent" form is minimalized!
Is it behavour tou want? I can send you whole app if you want.
I have to admit it's not the best way how to debug bt it works and time is valuable, so forgive me so unprofessional approach
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
ah. Now i found the Problem.
I had the set the WindowState, Show the Form and Activate it.
[Form.WindowState=FormWindowState.Normal;
Form.Show();
Form.Activate();]
The Problem occurs when you generate a hidden
Winform on startup
Subform blah = new Subform();
blah.Hide();
and then try to show it when the main Form is minimized
private void button1_Click(object sender, System.EventArgs e) {
this.WindowState = FormWindowState.Minimized;
blah.WindowState = FormWindowState.Normal;
blah.Show();
blah.Activate();
}
It won't show up without bla.Activate();
|
|
|
|
|
Is it MDI app?
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
What's that?
I just created a new WinForm
|
|
|
|
|
MDI stands for Multiple Document Interface. It's old school way how to organise UI... if interested, check out IsMDIContainer property of Form in MSDN
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
I've an server/client application, for sending single commands to specific clients connected to the server.
The server has an array object with the clients and their informations.
For more detailed informations I have to send a complicated string like "inetStats:PC1!online:PC2!offline"
and then I'm using String.Split(':') btw.: String.Split('!'). (I know it's veeery unprofessional!)
So, I just read about remote objects and MarshalByRefObject and I think it's a rather better way:
With a remote object I could make an array with the inetStates accessible for all connected clients.
I tested it by implementing the code, and it still works fine.
But is that a good idea, making a TCP channel for remote objects next to my Socket connection?
I'd like to replace the socket connection(working with delegates) with the TCP channel method.
But I don't know how to send commands to specific single clients, like in my socket connection?!
I'm looking forward to any suggestions.
(Sry for my bad english )
|
|
|
|
|
I'm not sure exactly what you are asking, however
each client is likely to be on a different IP address, so they can all share the same port number. The remoting call can tell the different between clients.
Does that make sense?
Gary
|
|
|
|
|
What's exactly "The remoting call"? How does the remoting call can tell me the differents between the clients?
Thx for (trying to) helping me.
Knack
|
|
|
|
|
Here's how I would do it.
The Server, waiting for a client to connect (similar to what you do now with the sockets). When the client connects you can determine (or pass) the IP address of the client. When the "server" wants to talk back to the client, it makes a remoting call to the <ip address="" of="" the="" client="">/Object so it can talk to a single client.
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
yes, that's the way I want to do it.
But how would you let the server listen for any clients, like that?
-------------------------- server code snippet-------------------------------------------------
m_socListener = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint ipLocal = new IPEndPoint (IPAddress.Any, port);
m_socListener.Bind (new IPEndPoint (aryLocalAddr[0], port));
m_socListener.Listen (maxClients);
m_socListener.BeginAccept (new AsyncCallback (OnClientConnect), m_socListener);
-------------------------- server code snippet-------------------------------------------------
|
|
|
|
|
(my client connection part
-------------------------- client code snippet-------------------------------------------------
m_socClient = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress ip = IPAddress.Parse (remoteIP);
IPEndPoint ipEnd = new IPEndPoint (ip.Address, port);
m_socClient.Connect (ipEnd);
-------------------------- client code snippet-------------------------------------------------
And I have to use a tcp channel for marshaling objects, right?!
right after listening on socket the server opens a tcp channel for remote objects:
|
|
|
|
|
With remoting the server doesn't have to listen or block.
I usually have the server waiting on a keypress (or as a NT service).
When the client 'connects' by creating the remoting object .Net takes care of the TCP part. The object is created in the server and a proxy is created for the client, the client uses the object as if it were created locally.
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
http://www.csharphelp.com/archives/archive187.html
http://www.c-sharpcorner.com/Network/RemotingInNETM.asp
http://www.codeproject.com/csharp/DotNetRemotingBasicTutor.asp
Maybe these will help
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
(my client connection part
-------------------------- client code snippet-------------------------------------------------
m_socClient = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress ip = IPAddress.Parse (remoteIP);
IPEndPoint ipEnd = new IPEndPoint (ip.Address, port);
m_socClient.Connect (ipEnd);
-------------------------- client code snippet-------------------------------------------------
And I have to use a tcp channel for marshaling objects, right?!
right after listening on socket the server opens a tcp channel for remote objects:
|
|
|
|
|
-----------------------------server code snippet2--------------------------
m_TcpChan = new TcpChannel(9999);
ChannelServices.RegisterChannel(m_TcpChan);
sets = new Interface.settings();
obj = RemotingServices.Marshal(sets,"settings");
-----------------------------server code snippet2--------------------------
client connects with:
sets = (Interface.Server.IServer)Activator.GetObject(typeof(Interface.Server.IServer),"tcp://localhost:9999/settings");
With the socket connection i'm able to send single string commands, and the client can pass his IP for identifiy it later.
Do I need an extra tcp channel for my purposes?
Knack
|
|
|
|
|
I think you can use the same/existing channel.
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
I tried just to marshal my object without creating a tcp channel, merely with my existing socket connection, it doesn't work ...
|
|
|
|
|
Gary Thom wrote:
When the client 'connects' by creating the remoting object .Net takes care of the TCP part. The object is created in the server and a proxy is created for the client, the client uses the object as if it were created locally.
If I understood correct: I have to create a tcp channel next to my socket connection.
That still works fine...
I added a remote method to the hosted remote class of the server, so when I call myRemoteClass.Method()(on the client)
the method on the server is executed, but I want to do it in both directions, i.e. the server can call methods on the clients, too.
So I tried to marshal a class on the client(while a class is marshaled on the server) with the existing tcp channel, but it doesn't work, how to do it?
|
|
|
|
|
I'm not sure what to tell you.
Check out the websites I posted before, and try with a simple client and server to start with.
I will try to see if I can find any information that can help you.
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
Hi,
I am trying to pass multiple sections of one big byte[] into a function that takes byte[] as a parameter.
This is what I am trying to do:
method( bigBuffer[ bufferIndex ], bufferSize )
where method is declared as
void method( byte[], int )
The code above results in a compilation error because a byte cannot be converted into a byte[]. Is there a way to do this without forcing me to break the bigBuffer down into smaller byte[] byte by byte?
Thanks!
|
|
|
|
|
SebbaP wrote:
I am trying to pass multiple sections of one big byte[] into a function that takes byte[] as a parameter.
First change the signature of the method you want to call in something like this...
void Foo(byte[] byteArray, int offset, int length)
...where offset is the starting index and length the number of bytes to process. You can then call it like this:
Foo(bigBuffer, offset, length);
If you can't (or don't want to) change the function that is going to process the sections of your array you might use the static method Array.Copy [^]. However (as the name implies) it copies (a part) of the array and therefore is slower and the callee will not be able to manipulate the original data.
Best regards
Dennis
|
|
|
|
|
Thank you Dennis!
I cannot (or rather, would not like to) change the method signature, and as you mentioned, copying each element is slow. But that is what I have settled for (I would end up copying each element in the partitioned byte[] anyway inside Foo), until I - or someone else for that matter - comes up with a quicker solution.
Anyone?
Thanks!
|
|
|
|
|
SebbaP wrote:
I cannot (or rather, would not like to) change the method signature, and as you mentioned, copying each element is slow. But that is what I have settled for (I would end up copying each element in the partitioned byte[] anyway inside Foo), until I - or someone else for that matter - comes up with a quicker solution.
Copying is slower but that does not necessarily mean that it's too slow for you. Although I'd still suggest that you should consider refactoring the method you want to call, you should give Array.Copy() a try. Somehow I doubt that it copies each element. I would rather expect a simple memcopy which should not get you into trouble unless you want to copy a few gigabytes per second. If you take a look at how Array.Copy() works you'll find out that it is implemented directly in the CLR. The method is overloaded however it always results in a call of the following method:
[MethodImpl(MethodImplOptions.InternalCall),
ReliabilityContract(Consistency.MayCorruptInstance, CER.MayFail)]
internal static extern void Copy(Array sourceArray, int sourceIndex,
Array destinationArray, int destinationIndex,
int length, bool reliable);
Best regards
Dennis
|
|
|
|