|
When you create an MSI package using Visual Studio .NET and include assemblies in your package, VS.NET automatically adds a launch condition which you could delete by selecting the project and clicking the appropriate toolbar icon in the Solution Explorer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have created a project with several forms and a main menu form. On the forms, I have placed six different user controls. Then I converted the project to MDI. The main menu form has IsMDIContainer is set to true. On the child forms, the MdiParent has a reference to the parent form. When i run the program, the textcolor of the text in labels and buttons is the same as the backgound color (or the text appears to be missing). When i remove the reference to the parent form and run the program, the color of the foreground and backgound return to the colors set in the properties. What can i do to prevent this problem?
Thanks in advance
bob
|
|
|
|
|
Unless you're explicitly setting the BackColor and ForeColor properties to something other than the default, these controls use ambient properties of the parent. It would seem, then, that somewhere in one of the parent controls you're setting BackColor and ForeColor to the same Color value. Is this correct?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
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
|
|
|
|