|
This one really looks great. I'm goint to try it as soon as I return to my development os. I suppose screen is a .net class. I haven't noticed it - too many classes, too much to learn Thank you!
|
|
|
|
|
Zinj wrote:
I suppose screen is a .net class.
Yes, I forgot to mention that, the full name is System.Windows.Forms.Screen
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
and I think I have used Rectangle for the declaration
|
|
|
|
|
Hello,
Does anybody know how can I convert color in HSB format to RGB ??
(from RGB ro HSB I can use Color class)
<br />
Color cl=Color.FromArgb(64,128,162);<br />
float h=cl.GetHue();<br />
float s=cl.GetSaturation();<br />
float b=cl.GetBrightness();<br />
But Color hasn't got any SetHue, SetSaturation or SetBrightness method
Thank you
|
|
|
|
|
Hi
Someone post a method a few months back in this forum, do a search for HSB, you should find it easily.
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Here is the link[^]
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I thought it was you
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Thank you
|
|
|
|
|
What is the best way to implement manual scrolling in a textbox?
The problem I'm having is getting the scroll bar position to "align" to the text. Particulary the last line/end of line....
I guess the whole issue is around what size I must chose for my scroll bar range. Should that be equal to my content size - visible size, or be equal to the numbers of lines - visble lines, all assuming content size is bigger than the visible size? If lines, how do I handle the horizontal scroll bar then?
Thanx
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
How would you create a text within a Console app, which would be a different color such as red?
--Stickman
|
|
|
|
|
Have a search in the GotDotNet.com 's userfiles area for ConsoleEx, cant remember if its VB.NET or C# , but it has quite alotta cool functions, something small did bother me, but I cant remeber what now...
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
|
i have created a form in c#
when i press ctrl+Break it destroy.
and an exception occure.
who to get rid of that?
i want when i press ctrl+break then it does not do any thing.
can any body give the solution of it?
r00d0034@yahoo.com
|
|
|
|
|
I believe that only happens when you run the program under a debugger; I tried out two different programs (without running it from within VS.NET) and neither of them stopped execution.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
please read that code and solve my problem.
Given after that code.
//////////////////////////////////////////////////////////
public class Win32Hook <br />
<br />
{ <br />
<br />
[DllImport("kernel32")] <br />
<br />
public static extern int GetCurrentThreadId(); <br />
<br />
<br />
<br />
[DllImport( "user32", CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)] <br />
<br />
public static extern int SetWindowsHookEx( HookType idHook, <br />
<br />
HOOKPROC lpfn, <br />
<br />
int hmod, <br />
<br />
int dwThreadId <br />
<br />
); <br />
<br />
<br />
<br />
public enum HookType <br />
<br />
{ <br />
<br />
WH_KEYBOARD = 2 <br />
<br />
} <br />
<br />
public delegate int HOOKPROC(int nCode, int wParam, int lParam); <br />
<br />
<br />
<br />
private HOOKPROC hookProc;
<br />
<br />
<br />
public void SetHook() <br />
<br />
{ <br />
<br />
<br />
hookProc = new HOOKPROC(this.MyKeyboardProc); <br />
<br />
<br />
<br />
SetWindowsHookEx(HookType.WH_KEYBOARD, hookProc, 0,<br />
GetCurrentThreadId()); <br />
<br />
<br />
<br />
} <br />
<br />
<br />
<br />
public int MyKeyboardProc(int nCode, int wParam, int lParam) <br />
<br />
{ <br />
<br />
<br />
return 0; <br />
<br />
} <br />
<br />
}<br />
<br />
<br />
To install the hook procedure <br />
<br />
Win32Hook hook = new Win32Hook(); <br />
<br />
hook.SetHook();
//////////////////////////////////////////////////////////
Above code is 100% correct but my problem here is that I want to execute it for each thread for that purpose I modify a line of code and that is
SetWindowsHookEx (HookType.WH_KEYBOARD, hookProc, IntPtr.Zero,0 );
But after changing that line of code it does not solve my problem because MyKeyboardProc function does not execute its code.
I don’t know why? Can any body give its solution?
r00d0034@yahoo.com
|
|
|
|
|
hi,
i'm using udp on sockets and wonder how to set a timeout on receiving? haven't found anything on that issue...
sometimes it happens, that there is no connection or packets get lost and i really need a configurable timeout here.
possible workaround would be to have the calling thread install a timer, and if the child-thread isn't done with his communication-things, he's aborted (-9 so to say ). but it would be nicer if there is a timer somewhere within the socket-internals...
any idea?
:wq
|
|
|
|
|
Rüpel wrote:
possible workaround would be to have the calling thread install a timer, and if the child-thread isn't done with his communication-things, he's aborted
If the thread is blocked in UdpClient.Receive() or UDP Socket.ReceiveFrom(), then calling Abort on the thread will not stop it until the blocked method returns. To stop it, after calling Thread.Abort, you have to send a datagram to yourself for the thread to unblock. Then it will be aborted.
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
...you have to send a datagram to yourself for the thread to unblock...
i've tried, but it doesn't seem to work.
what's wrong with this little console-application?
<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
Class1 foo = new Class1();<br />
foo.MainLoop();<br />
}<br />
<br />
public void MainLoop()<br />
{<br />
Thread listener = new Thread(new ThreadStart(Listen));<br />
listener.Start();<br />
<br />
UdpClient sender = new UdpClient();<br />
IPEndPoint self = new IPEndPoint(IPAddress.Loopback,7789);<br />
sender.Send(new byte [] {0x01},1,self);<br />
<br />
while (listener.IsAlive) ;<br />
}<br />
<br />
void Listen()<br />
{<br />
UdpClient ear = new UdpClient();<br />
IPEndPoint remote = new IPEndPoint(IPAddress.Any,0);<br />
ear.Receive(ref remote);<br />
Console.WriteLine("Got some Input from {0}",remote);<br />
}
:wq
|
|
|
|
|
just a little bumpage , in case someone thinks: "hey this is just a 'question-answer-thx'-thread and i don't have to look at it"
if that gets fixed, i'm ready to post my first article here on codeproject. so could anyone please give me an idea?
:wq
|
|
|
|
|
Try this:
(for a 10 seconds timeout)
ear.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.ReceiveTimeout, 10000);
"In an organization, each person rises to the level of his own incompetence." Peter's Principle
|
|
|
|
|
hey, this looks cool. will try it tomorrow
although i will try SocketOptionLevel.Udp instead of Tcp first
thx anyway.
:wq
|
|
|
|
|
at first, both SocketOptionLevel.Udp and SocketOptionLevel.Tcp raise an exception when being used with SocketOptionName.ReceiveTimeout . it seems you have to use SocketOptionLevel.Socket instead.
but that even doesn't help. the Receive() -function still blocks. i don't know what that ReceiveTimeout is for
:wq
|
|
|
|
|
now i did a 'hack' that works for me.
public class TimedUdpClient : UdpClient
{
private int timeout = 1000;
private Thread timeoutWatchdog;
public int Timeout
{
get { return timeout; }
set { timeout = value; }
}
public new byte[] Receive(ref IPEndPoint remote)
{
timeoutWatchdog = new Thread(new ThreadStart(StartWatchdog));
timeoutWatchdog.Start();
try
{
byte[] ret = base.Receive(ref remote);
return ret;
}
catch (SocketException)
{
return null;
}
}
private void StartWatchdog()
{
Thread.Sleep(timeout);
this.Send(new byte[] {0x00},1,"",8000);
}
}
my little test-program from two or three postings above didn't receive the packets since they have to be sent on the same socket (at least i believe that). when this byte from my watchdog is sent, there's an exception ("connection closed by remote" or something like that) raised somewhere inside UdpClient.Receive() . it would be nicer, if it would just receive the byte and one could distinguish by the sender, if that packet was sent by the watchdog (thus, on the same socket) or comes from outside. UDP is a connectionless protocol, so i'm not sure, how such a connection-closed-excpetion may occur, but actually it does
anyways. all i wanted, was stop Receive() from blocking and this way it works.
thx to everyone that helped. (also the ones that read, thought and had no idea)
:wq
|
|
|
|
|
|
How can I draw a control in disabled state using my custom colors for Background and foreground?
Thanks,
Vasile
|
|
|
|