|
StephaneRodriguez wrote:
The Modifiers property applies to an existing control, and on a one-by-one basis
In most cases you can select multiple controls and set the Modifiers property for all of them.
So far the only time I've found that you can't is when the control you are selecting comes from the base class. That makes sense because the forms designer uses the compiled assembly to do its work, so it obviously can't modify the visibility of the variable in the assembly.
StephaneRodriguez wrote:
can't figure out by the way why there is no Modifiers property at the Form level, this would have been a nice place for all controls added later).
This would be a nice addition for those that would like to expose all controls easily.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thanks for all your comments and especially your perspective on OOP. I know there can be valid reasons to limit access but it seemed overkill to write a get/set and set the value to anything the user wants to anyway! I shall try to judiciously use public members.
don
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
I cannot figure out if there are any methods to get the windows resolution in .NET at run time?
Acutally I have a window that resizes according to the data and I want it to center itself on the screen.
Any idea how to do it with pure .NET?
Thank you
|
|
|
|
|
Try this in your constructor:
this.StartPosition = FormStartPosition.CenterScreen;
Last week I stated that this woman was the ugliest woman I had ever seen. I have since been visited by her sister and now wish to withdraw that statement.
-Mark Twain
|
|
|
|
|
If setting the StartPosition property doesn't work, you can get the screen resolution by using the Screen class.
Screen screenRect = Screen.GetWorkingArea(this);
this.Location = new Point(
(( screenRect.Width - this.Width ) / 2) + screenRect.Left,
(( screenRect.Height - this.Height ) / 2) + screenRect.Top
); The reason I add screenRect.Left and screenRect.Top is because in a multi-monitor situation the top-left corner of the screen might not be (0, 0).
Untested code, but that *should* work
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
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
|
|
|
|