|
Do Windows store icons somewhere in the registry? Do you know the path?
I had to change the toolbar icon for our application, and it works. But when you start the app, for a split second the old icon flashes on the bottom. I can't figure out where it's coming from!!
I changed App.ico and the icon on the main form.
Any ideas?
Thanks,
Elena
|
|
|
|
|
"Windows" doesn't store icons anywhere. Applications store icons however they want to. If you just changed the App.ico and the main form's icon, this won't change the icon for your toolbar. Be default, Visual Studio .NET puts the ImageList for a toolbar into a ResX file (localized resources). That image is still in the ResX file and apparently you're programmatically changing the toolbar at runtime.
Edit the ImageList for your toolbar and remove that image, or replace it with App.ico. In this event, the icon data will be serialized to the ResX file, which gets compiled as a binary .resources file associated (i.e., name similarily) as the class it's "bound" to (in the designer, that is). If you want to see this, click "View Hidden Files" in the solution explorer when your project is selected. It will appear under your form or control if you drill-down (i.e., click the +) sign.
Note that .NET applications do not utilize the registry (they can, but this is not recommended). Also, Windows Explorer (the Windows shell) does cache file association icons in a system image list, but this has absolutely nothing to do with your problem in particular. This is just FYI.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm not sure if we are talking about the same thing. (Or I simply don't understand)
When I talk about toolbar I am talking about the standrard Windows toolbar at the bottom of the screen that shows you the apps you are running. It always has a little icon.
How can I change ImageList for this toolbar?
Elena
|
|
|
|
|
That's the task bar - not just any old toolbar. You should be more specific next time.
These images may be cached in the system image list, but I've never seen a problem such as yours. You can use something like TweakUI from the PowerToys installation for your respective Windows OS to clear this cache.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have just started using C#. I currently use VB6 with the Cheetah database system. There is a VB.Net wrapper available for the system, however there is no C# version yet. Can someone point mew in the right direction of linking to a windows 32bit dll from C#. The VB.Net wrapper can be found on http://www.planetsquires.com
Many Thanks
John Messingham
|
|
|
|
|
It doesn't have to be C#. All languages targetting the CLR (Common Language Runtime) compile to Intermediate Languages (IL), which is contained in modules embedded in an assembly. Just compile the VB.NET wrapper to an assembly, then reference that assembly in your C# project and use it. The source language matters very little.
The biggest differences between languages is what they support. VB.NET does not, for example, support unsafe contexts when C# does. There is slight differences in compiler optimizations as well. They still compile down to IL.
This is what makes the "language independence" of the .NET Framework possible (well, one of the things).
I suggest you read at least the overview and programming topics in the .NET Framework SDK[^] before just jumping into it. Understanding at least what comprises the .NET Framework is important. At least skimming through the class library documentation will give you some indication of the functionality exposed by the Framework Class Library (FCL).
Also, if you'd rather just include the wrapper code in your C# project (which, IMO, is a complete waste of time - see my previous solution, which is a more common approach), then translate it. Syntax is really the only thing that's different. A majority of the calls is to classes, interfaces, members, etc. of the FCL, which are common and available (at least, CLS-compliant ones) to every language that targets the CLR.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Many thanks for the advice.
|
|
|
|
|
I have a custom control that draws text and images. The images are drawn for each item from a single ImageList:
MyControl control = new MyControl();
control.ImageList = this.imageList1;
In the drawing code, I have something like this:
protected override OnPaint(PaintEventArgs pe)
{
pe.Graphics.DrawImage(this.ImageList.Images[0]);
...
}
This is butt-slow! The paint event seriously slows down the entire app everytime I draw. Running it through a profiler tells me accessing the image out of the image list is the culprit (?). And indeed it is; if I store a reference to the image to draw (instead of getting the image out of the image list), it's super fast:
private Image imageToDraw = null;
public MyControl()
{
imageToDraw = this.ImageList[0];
}
protected override OnPaint(PaintEventArgs pe)
{
pe.Graphics.DrawImage(this.imageToDraw);
...
}
Can anyone tell me why this is the case? The only difference between the two code snippets is that the first calls DrawImage(imageList.Images[0]) and the second snippet calls DrawImage(someImage). Is retrieving the image out of an image list really that slow?
#include "witty_sig.h"
|
|
|
|
|
If you're intersted in the internal workings of classes, use the IL disassembler (ildasm.exe) that ships with the .NET Framework SDK or use a decent decompiler if you don't know IL like .NET Reflector[^].
The ImageList class uses the Image list common control, so it encapsulates said control by sending Windows messages (using the macros, actually), which requires marshaling to/from unmanaged code.
A faster way, however, is to use ImageList.Draw . This uses the HDC of the Graphics for your painting operation - as well as the other parameters - to have the image list common control draw the image directly to the on- or off-screen bitmap (depending on whether or not you're using double-buffering), or to the Image you're trying to draw (obviously not the case here). This will definitely be faster than your first method and would provide the robustness you may be looking for (like if the images in the list change often and you just want to always draw the first one, or some other index), as opposed to coming up with some caching schema and implementing it using your latter approach.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes I heavily use ildasm here at work, nice little bugger.
Yup I am aware that marshalling is going on...I just didn't think it would really be *that* much slower. Pretty amazing. I'll give ImageList.Draw a try, see how fast that is relative to my other 2 options.
Thanks Heath for the lightning fast reply. Helpful as always.
#include "witty_sig.h"
|
|
|
|
|
I just ran some tests using ImageList.Draw - works brilliantly.
Thanks again!
#include "witty_sig.h"
|
|
|
|
|
Judah Himango wrote:
I just ran some tests using ImageList.Draw - works brilliantly.
I'll keep that in mind
|
|
|
|
|
I wish to jump from running the main form Form1 to run my Form2. I want my Form2 to dispose Form1 and continue to run as the main form. I have excperienced som difficulty in doing this as when Form1 is disposed it will close Form2 even if i have set the reference in Form1 to acces Form2 to be null. I believe its because Form1 is running the main thread, is it possible for me to create a similar thread in Form2 to overtake the main thread.
|
|
|
|
|
Form1 is what the message pump is using to keep the loop alive so that it translates and dispatches messages throughout your application (Windows Forms just encapsulates Windows messaging and common controls). Disposing your form (or even closing it) stops the message pump.
If you're desiging a wizard-like interface, you should consider having a single form that maintains state between forms as well as navigation between them. And instead of Form derivatives, you could actually use any container control such as a UserControl (easiest to design in VS.NET, if you like that sort of thing).
There are several articles here on CodeProject that discuss this.
If you want to create a new main window for your application, then you could try using Application.Run on your instance of Form2 then dispose Form1 . I'm not sure how this would affect your application, however, since a new STA thread would be created for the new main window. Give it a try, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm trying to send .asf (audio stream) using a Client and a webserver, both in C#. When I try to submit data I get this exception:
"The request failed with HTTP status 413: Request Entity Too Large."
The file I'm trying to send is about 3-5 Mb.
Client:
<br />
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);<br />
BinaryReader br = new BinaryReader(fs);<br />
byte[] fileRD = br.ReadBytes((int)fs.Length);<br />
fs.Close();<br />
br.Close();<br />
wrGravadorWS.GravadorPA wsGravadorPA = new wrGravadorWS.GravadorPA();<br />
ret = wsGravadorPA.Save(fileRD); <br />
Webservice:
<br />
[WebMethod]<br />
public string Save(byte[] gravacao) <br />
{<br />
......<br />
}<br />
The code works fine when working with small files.
I use IIS 5.0. On MSDN there's no information about IIS 5.0, just IIS 6.0. I have made MANY researchs about this and I couldn't find solution.
This is all I have:
413-Request Entity Is Too Large
For security reasons, you can limit the size of the entity-body of an HTTP request by modifying the MaxRequestEntityAllowed metabase property. When an entity-body of a client request exceeds the size that is specified in the MaxRequestEntityAllowed property, IIS returns a 413 error. If this error is logged for an individual request, an application on the Web server might have encountered an unexpected event and generated a request that is too large. If this error is logged for many requests, a malicious user might be attempting to compromise your Web server.
Where I cant make this change on iis 5? (the IIS 6 metabase is a xml file). On registry, it doesn't make any diference.
Thank you!!
Edgar
|
|
|
|
|
There are some windows scripts to change the metabase in IIS 5, but ASP.NET is most likely what's returning the error here since it maintains it's own execution environment and has a setting for maximum request sizes. Open your machine.config file for the version of ASP.NET your site is running in and change the maxRequestLength in the <httpRuntime> element.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I forgot to say that I tried this before. Without this change (I placed in web.config and machine.config) there is a security error. After this change (maxRequestLength at httpRuntime element) I receive a 413 error from IIS 5
Thank you!
Edgar
|
|
|
|
|
IIRc, the web.config cannot contain the <httpRuntime> element, which is probably why you got the security error. Since you didn't state what the exception type and message was, though, it's difficult to say for sure.
Your problem is a common problem, and the fix I recommended is the common solution, even on Microsoft's KB. If you still believe it's IIS, go to http://support.microsoft.com[^] and look for max request problems. The scripts to modify the metabase should be mentioned, as well as the params to specify.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you again for your help. I will try to use DIME instead. Changing machine.config didn't worked.
|
|
|
|
|
|
I am translating some code from VB to C# all was going swimmingly until I hit these lines :
Const SC_MP = &HF170&
Public Const M_ON = -1&
Public Const M_OFF = 2&
Const WM_SYSCOMMAND = &H112
Now I assume that these are int declarations but what format are they in and how can I translate them to standard hex/number representations
|
|
|
|
|
They're hexidecimal, or base 16 numbers (at least the first and last ones). In C# they'd look like this:
const int SC_MP = 0x0170;
public const int M_ON = -1;
public const int M_OFF = -2;
const WM_SYSCOMMAND = 0x0112;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hai there,
i got little bit information about Borland C# Builder. give me some detailed information about this. And Recomanded books or CDs
hai, enjoy coding
Sreejith SS Nair
|
|
|
|
|
sreejith ss nair wrote:
give me some detailed information about this.
Ever heard the word "please"? You often demand things from others on this site. There's not a languages I've heard of that doesn't have a word similar to "please".
If you want information about Borland's C# Builder, the logical place is their web site[^]. There's plenty of whitepapers to download.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How to compare two files,like "Microsoft Visual SourceSafe"!
Code by C#!
I am English is poor!
thank you!
|
|
|
|