|
Thanks for answer
About limitations - clients want application to run on Ms Sql Srv - actually i am porting it from access based solution to Ms Sql based;
language - C++/MFC i the language i am best at, but it would take much longer time to build applications (over 40 forms, and when using MFC its too long for me). VB - old one - i am afraid, the at one moment it will have limitations that i am not able to cope with ( i preffer solid ground languages, not interpreted ones) - VB.NET - is good, but i am feeling much better at C#
ehh, nevermind, nevertheless, thanks for answer
|
|
|
|
|
Konrad Rotuski wrote:
(over 40 forms,
That sounds like a sizable app. Personally, I use C# and make the minimum requirement Win98. That way you have a scalable application for the future that is fairly easy to maintain (depending of course on how you create it). Depending on your forms, VS.NET C# does have a Data Form wizard that might be able to help with some of the work.
Rocky Moore <><
|
|
|
|
|
In vb.net, if I define a function as such:
Public Sub Foo(a as string)
...
End Sub
I could call it like this, if I am not bothered of the parameter I pass in:
Foo(New String())
Is there anyequivalent technique in C#?
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
|
:slaps head: duh!
But what if the parameters are objects?
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Well, if you want to pass an invalid object(I belive it's what Nothing is in VB), Foo(null);
If you want to pass a valid object, but don't care what it is like, Foo(new Whatever());, just like in VB (Assuming it has a 0-param constructor. If it doesn't, you'll have to fill in some parameters or just use null)
|
|
|
|
|
Notorious SMC wrote:
I could call it like this, if I am not bothered of the parameter I pass in:
Foo(New String())
Is there anyequivalent technique in C#?
You can also Overload the member such as:
public void Foo(string a)<br />
{<br />
}<br />
<br />
public void Foo()<br />
{<br />
Foo("");<br />
}
This can keep control in your class and show outside your class that is it safe to pass no parameters.
Rocky Moore <><
|
|
|
|
|
I would like my app to be notified of Click events from anywhere on the screen. I have tried a TransparencyKey=back ground colour form but the Clicks go straight through. I tried a 0% opaque window, but the hardware does not support it. Any ideas how I can do this in C# without resorting to Interopping with a bit of C code or polling Control.MouseButtons?
Update - I had tried using Opacity=2 for 2 percent, whereas I should have used 0.02! However, the challenge still stands because a completely not-opaque window lets all the mouse event through.
|
|
|
|
|
Not sure in C# but with the WINAPI you call SetWindowsHookEx with WH_MOUSE. You may be able to interop that with C#. Don't know if its been done or if its possible. But that information should get you started on Google.
|
|
|
|
|
Hi All!!
a Class Library project contains
namespace MyCustomMethods{<br />
public class Vlidations{<br />
}<br />
}
a Cusotm Control Library uses some methods from the above project
namespace MyCustomControls{<br />
public class SSTextBox : TextBox{<br />
}<br />
}
problem is that when i create control at run time, it works fine but when i drag it on form from toolbox it just shows wait cursor and nothing happens
sorry for my bad English.
|
|
|
|
|
Hi There !
I am trying to build a server - client application, using tcp/ip and sockets.
I would like that the server will be able to listen to some clients, and if a new client "shows up", the server notice the new client and will add it to other clients.
Can someone show me an example for something like this ?
Thanks.
|
|
|
|
|
Your server socket must use the Accept method to handle incoming client requests. Actually you should use BeginAccept uses the thread pool) for server apps for performance.
In accepting these requests a handler handles the request and it is in this handler that you can add all incoming requests to wherever you want.
|
|
|
|
|
My server socket already uses Accept method.
The thing is that I eant to avoid this situation:
IPEndPoint a_EndPoint = new IPEndPoint(ipAddress, a_port);
IPEndPoint b_EndPoint = new IPEndPoint(ipAddress, b_port);
...
// Create a TCP/IP socket.
Socket a_listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
Socket b_listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
// Bind the socket to the local endpoint and listen for incoming connections.
try
{
a_listener.Bind(a_EndPoint);
a_listener.Listen(num_of_clients);
// The maximum length of the queue of pending connections
b_listener.Bind(b_EndPoint);
b_listener.Listen(num_of_clients);
// The maximum length of the queue of pending connections
...
while (true)
{
// Set the event to nonsignaled state.
all_done.Reset();
// Start an asynchronous socket to listen for connections.
Console.WriteLine("Waiting for a connection...");
a_listener.BeginAccept( new AsyncCallback(accept_callback_a), a_listener );
b_listener.BeginAccept( new AsyncCallback(accept_callback_b), b_listener );
...
// Wait until a connection is made before continuing.
all_done.WaitOne();
You see, I have to create a new object for socket, and to create each one its own function and its own delegat...
How can I avoid this ?
Thanks.
|
|
|
|
|
I'm noy quite sure what you mean exactly? Are you saying that an accept is required for every client? If so, and if I'm understanding exactly your situation, this is not correct.
You only need one server socket and it will be "accepting" ALL client requests. Again, all clients will be making a request to the one server listening socket. Now when the server "accepts" the a request you can process that one request as you see fit while at the same time the server may be "accepting" other requests.
All these things happen concurrently. That is why we call the server an asynchronous socket.
|
|
|
|
|
Hi and thanks for you help !
I know that I can recieve the information through one socket.
But, I need my server to distinguish between the various clients. I want to know who send a message to the server.
In adition, I want to be able to send a message to a specific client - not to all of them together !
|
|
|
|
|
Hi,
In adition, I want to be able to send a message to a specific client - not to all of them together !
When you "accept" a request, you then get the socket, whereby this socket responds solely to the requesting client and no other.
But, I need my server to distinguish between the various clients. I want to know who send a message to the server.
The client will have to pass some identification from itself to the server within the buffer that it sends. The server can then identify the client.
Cheers
|
|
|
|
|
Hi again !
YOu wrote: "When you "accept" a request, you then get the socket, whereby this socket responds solely to the requesting client and no other."
But, I want to send data to some of my clients:
1. I don't want to reply - I want to send something to a certain client without the need to recieve something from him right now.
2. I want to be able to send the message to some client - for example, to send data to clietn_ID: 1, 3, 5.
How can I do this ?
|
|
|
|
|
I'd like to be able to determine if the keyboard has "Num Lock" enabled or disabled from C#, as well as to set this state programmatically from C#.
I've found some info on how to do this in Win32 in C using "GetKeyboardState" and "keybd_event", but I'm not sure how to call this from C# or if there is a more direct approach in C#.
|
|
|
|
|
Here is some code, uses Win32 interop
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
public enum SpecialKey
{
CapsLock = 0x14,
NumLock = 0x90,
ScrollLock = 0x91
}
public class SpecialKeyState
{
[DllImport("User32.dll")]
private static extern short GetKeyState(int nVirtKey);
public static bool GetSpecialKeyState( SpecialKey k )
{
int s;
s = GetKeyState((int)k);
s &= 0x01;
if (s == 1)
return true;
else
return false;
}
}
I didn't test this code exactly. It is ripped from a component I made from some other code on the internet. I modified it to let you test any of the speical keys (my version allows you to set a member and then test that key on an interval).
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thanks Nathan! That does the trick for getting the num lock state.
I'm trying to figure out how to set the num lock now. I found a Win32 example that does this using keybd_event:
keybd_event(VK_NUMLOCK,
0x45,
KEYEVENTF_EXTENDEDKEY | 0,
0);
The signature of this method is:
VOID keybd_event(
BYTE bVk, // virtual-key code
BYTE bScan, // hardware scan code
DWORD dwFlags, // function options
ULONG_PTR dwExtraInfo // additional keystroke data
);
I wasn't exactly sure what types to use for the last two parameters in the extern statement, so I tried "long" and crossed my fingers:
[DllImport("User32.dll")]
private static extern void keybd_event(byte bVk,
byte bScan,
long dwflags,
long dwExtraInfo);
This actually works the first time I call it, but it gets really flaky after that. I figure that I'm not using the right types for the last two parameters, so I'm stomping on memory somehow. Any clue what types I should use?
Thanks again.
|
|
|
|
|
I also tried unsafe code with a long pointer, but this doesn't work any better than just using longs:
[DllImport("User32.dll")]
private unsafe static extern void keybd_event(byte bVk,
byte bScan,
uint dwflags,
ulong* dwExtraInfo);
|
|
|
|
|
Try using IntPtr instead of the long for the ULONG_PTR.
I really don't know, perhaps one the people with more experience in Interop will be able to tell us.
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I have a picturebox in my application and I have alist of images too.When user choose each image it display in that picture box.My problem is when size of image bigger than size of picture box,part of image does not shown in picturebox.The question is how can I manage this size when the image bigger than picturebox and show all of it in that picture box?Any suggestion or idea?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
You can do a couple different things with the SizeMode property of the PictureBox.
If you set it to PictureBoxSizeMode.StretchImage then the image will change it's size to match the picturebox. Not my favorite way of doing it, but if you must be able to view all of the image at one time then this can work (to make it look better you may have to resize the picture box a little so that the aspect ratio of the image is retained).
My favorite method is to place the picture box in a panel, set the SizeMode to PictureBoxSizeMode.AutoSize which will change the size of the picture box to match the image. Now set the panel's AutoScroll property to true. Now you will get scrollbars which can be used to view the hidden parts of the image, and the image will display at normal size.
Without knowing your exact requirements that is all I can offer, but it covers the two scenarios I can think of.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Thanks James.Both of them are what I need.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|