|
no. If i simple remove the line of code for the child form to refence the parent, then the color of the text returns to the correct colors. Also, if i actually set the backcolor property to something other than the default color, then the user control retains the new color.
bob
|
|
|
|
|
hi,
how i can resize and reposition a window?from my app
|
|
|
|
|
If you're in a method of your form:
this.Location = new Point(10, 10);
this.Size = new Size(100, 100);
|
|
|
|
|
I take it your talking about repositioning another app's window?
You must use the Win32 API's to reposition and resize the window. There is no .NET Framework classes that will do this for you. Looking GetWindowPlacement and SetWindowPlacement on MSDN.
RageInTheMachine9532
|
|
|
|
|
Hi!
I wonder if it is possible to animate the minimized application in the taskbar or at least blink. I'm working on an application that is required while active to stay minimized in the taskbar and to display some animation/blinking. I know how to do this in the systray but not in the taskbar. Any clues?
10x
|
|
|
|
|
You can P/Invoke the FlashWindow native API:
[DllImport("user32.dll")]
private static extern bool FlashWindow(IntPtr hWnd, bool bInvert); To call it the de facto 3 times, you can do something like this:
for (int i=0; i<3; i++)
{
FlashWindow(this.Handle, true);
Thread.Sleep(500);
FlashWindow(this.Handle, true);
Thread.Sleep(500);
} See the API documentation for FlashWindow in the Platform SDK for more details.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks a lot! This worked fine. But how about drawing in the taskbar while minimized? E.g. scrolling some text, or displaying a progress bar, etc.
|
|
|
|
|
Simple question really, does anybody know of a code driven way to get the installation path of the .NET framework without going to the registry?
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Assembly assem = Assembly.GetAssembly(typeof(System.Int32));
MessageBox.Show(assem.Location);
Charlie
if(!curlies){ return; }
|
|
|
|
|
RuntimeEnvironment.GetRuntimeDirectory();
Thank You
Bo Hunter
|
|
|
|
|
I generally don't like the Visual Studio style docking bars. I can't see any use for them in usual applications. What I would rather like to see is docking toolbars (seen first in Office 97/2000, I think) that change into floating toolbars if you drag them off the edge of screen. However, I haven't found a control like this yet (freeware I mean, there is a perfect commercial one - Xtreme Command Bars from CodeJock). Can you help me ?
|
|
|
|
|
I'm currently working on a VS.NET 2003 add-in that must intercept all the calls of "Debug.Run" command, the usual "F5". I added a delegate to BeforeExecute event like this:
Command cc=applicationObject.Commands.Item("Debug.Start", 0);
CommandEvents cev=applicationObject.Events.get_CommandEvents(cc.Guid, cc.ID);
cev.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(OnBeforeExecuteHandler);
where OnBeforeExecuteHandler is a protected handler in my Connect class.
The handler is never called The add-in seems to be available, i even debugged the code above step by step and it still refuses to fire that damn event
Any idea why? Could it be something wrong with my VS ?
rechi
|
|
|
|
|
I have a dll that I need to call that expects to have *byte as a paramiter. I can do this using unsafe {} code. But the thing of it is, after I create the object FileCRC crc = new FileCRC(); and then execute an operation it dosn't clean up.
Do I somehow have to dispose of the pointer, or when it goes out of scope is it garbadge collected? The form won't close as normal unless I kill the process.
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Instead of passing byte* as the parameter, declare your parameter using either ref or out for value types (like a Byte ). This is the most common method.
For instance, if the C functions is declared like so:
void SomeFunc(byte* b); ...declare your method like so:
[DllImport("...")]
private static extern void SomeFunc(ref byte b);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks, i'll give it a try...
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Hi,
I have a VC++ COM Component that has to return array of long and array of strings to the C#. I Figure the way to do it is using SafeArrays for each of the arrays. I wanted a sample application that could return the arrays through the VC++ and then access the same arrays from the C#.
Pls I shall appreciate if some one could give a working sample.
Thanx.
Sheela
|
|
|
|
|
So long as the array doesn't contain BOTH longs and strings, you could simply use UnmanagedType.LPArray (and associated properties) in the MarshalAsAttribute that you would use on your params. If you do need a SafeArray to return from your VC++ component, then you should take a look at Array Manipulation API Functions[^] which help you create SafeArrays in VC++. You declare your parameter in VC++ as SAFEARRAY and in C# using UnmanagedType.SafeArray and an object[] array.
The documentation for SafeArrays should give you plenty of examples and since this is VC++, I don't really want to type dozens of lines for something so trivial in higher-level languages (this isn't necessary a gripe against C/C++ - which I still enjoy and appreciate - just a fact). If your function was declared like so:
void SomeFunc(SAFEARRAY arr); ...then you could declare your C# method like so:
[DllImport("the name of your DLL")]
private static extern void SomeFunc(
[MarshalAs(UnmanagedType.SafeArray)] object[] arr); There are some other things you can do as well, but you should see the documentation for the MarshalAsAttribute class and the UnmanagedType enum in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello!
I want to write a C# spider which uses multiple threads that make synchronous HttpWebRequests to different sites. The big problem is that after a while (and it's a random period of time ) the app. stops, more precisely all the Responses are TIMEOUT. The only solution seems to restart the application...some spider huh?
Other symptoms: I keep receiving a System.NullReferenceException in System.dll that I cannot catch, probably thrown by a thread from the Thread Pool (my guess);
- KeepAlive is set to false; Proxy is set by me;
- in machine.config maxconnections=100;
If I use only one thread and make one Request-Response (closing it of course) at a time it seems to work...but the one at a time approach is not what I want for my spider.
If you know something about this please help...thx!!!
|
|
|
|
|
Instead of using Thread , you should try using a ThreadPool . This limits the number of threads that run and provides additional benefits. After the application spawns so many threads, it may appear to hang because the threads clog the system and keep the app very busy.
Also, many servers limit the number of connections per client. This is commonly configured at two connections. While all those requests are waiting, they will eventually timeout because only a couple will be able to get responses.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thx for your response!
I'm thinking about the ThreadPool alternative.
If I run the app with 4 threads, I get the same result…after a while all the Responses are TIMEOUT and it’s not meter on witch server it's try to connect. I think the # of threads it’s not a problem, I think is something else…and what about the System.NullReferenceException in System.dll that I cannot catch?
|
|
|
|
|
There could be a couple things happening. As I mentioned before, most servers limit the number of connections per client. This could cause a timeout because it won't respond to waiting requests.
Another problem is that you might not be locking your resources and are running into a dead-lock. If you have multiple threads accessing a resource, you should lock each thread so they don't access it concurrently (unless the object itself - like a synchronized Hashtable (see Hashtable.Synchronized ) - is already thread-safe. You can do this easily in C# with the lock keyword. Typically, you can pass typeof(SomeClass) to lock against with multiple threads.
As far as the NullReferenceException thrown from a thread, you can handle the Application.ThreadException event or possibly the AppDomain.UnhandleException event.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thx again for your answer!
I’ve consider the server limitation and my threads are one request - one server design to avoid this.
About the deadlock because of an object that threads share I’ve checked and it’s not that because are threads who are finishing their job and others are created (in a limit of course). The only problem is that all receive TIMEOUT.
I’ll give you an example…
I put the spider to get me the html content of the main page for 500 sites, 5 threads maxim at a time. TIMEOUT it’s set to 20 sec. For the first 100 sites it’s work ok, in generally, only a few timeout occurred, but after that it’s bad… this timeout’s keep appearing and after 350 all the responses are timeout…
I reverse the list and it’s the same. Some times, but very rarely, I receive some response till the spider finish the 500 list, but sporadic.
I don’t now what else to do…i've tried all
|
|
|
|
|
You can't expect 500 threads to all run concurrently - the processor doesn't even allow this. You are familiar with time slices and the CPU, aren't you? Processes only get so much time. With that many threads, there's no way the CPU could service them all in a reasonable amount of time. That's why many web servers are multi-processor systems. You need to maintain better control of your threads.
If you look at the System.Threading namespace, you'll see several classes that can specify a timeout or wait indefinitely, but you should still avoid creating 500 threads. Consider designing your application so that you wait for threads to finish and then start another one. See the Threading[^] section in the .NET Framework SDK for information and examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know, I'm not that crazy to put 500 threads at a time...
I only keep 5 of them at time, when one finish the callback function it’s “--“ the counter so another can be created an start a new request.
So you see why I think that the threads are not the issue here, it's something with the way framework manage the HttpWebRequests …
|
|
|
|
|
If i create a library, and comment all public and protected members.
With the XML comments in C#.
Then the comments nicely pop up when im coding in other classes, or projects within the same solution that holds the project with the commented class.
But, when I now take the DLL, and reference not by project (not adding the project to my new solution), but by file reference, like how you would any third-party dll, the comments don't show up.
How do I tell the compiler to compile the xml comments into the dll. Or what do I have to do?
Thanks,
Kris.
|
|
|
|