|
What you've been told will not work if your form is ever obscured by another form.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
if you create an instance of a class that offers a public Dispose() method, you MUST
call that method when you're done. This also applies to Control.CreateGraphics()
and Graphics.FromImage() and the like !!!
|
|
|
|
|
This won't work properly. If the form is invalidated, the panel will be erased, unless this is called from a paint event, in which case, it should just use the existing graphics object.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You should handle the paint event of the panel, and draw the bitmap onto the panel there. CreateGraphics will not redraw the image if your form is obscured by another form, as no paint event will occur.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
I made one app and put on form grid view . I write the informations to the gridview but when i restart app ther are gone .Question is : How to save a access databse in c# and all records!!??
Thx
nemanja
|
|
|
|
|
Hi.
Can anyone give me a general gude (or a link to some resources) on the subject of different image formats?
But let me explain more specifically: I have a control that shows a lot of text items whose size & format depend on the content itself. This means that every time the control is repainted, a lot of text rendering occurs. To go around this problem I use a very simple idea - render the text to an image an draw the image until the text changes.
The only problem with this idea is the consumption of a lot of RAM.
What can I do to reduce the amount of memory I use? GDI+ offeres only the abstract Image class (Bitmap & Metafile as its descendents) for Drawing Images on the screen.
Is there a way to reduce the colors or perhaps use some sort of compression when I save the Images in the in-memory buffer?
Thank you.
|
|
|
|
|
You really can't do anything. A bitmap in memory must be a bitmap, which means it's huge. You could keep it in memory as a jpeg in a stream, and re build the bitmap from that, I do that to cache a lot of images, but I believe it will be too slow to do this to keep an image that is being drawn on every paint event.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
what you ask can be found in the doc under "PixelFormat Enumeration".
but I am afraid you're idea is not very sound; replacing text by an image to speed
things up is not the way to go. Instead make your text drawing faster. Text drawing
normally is VERY fast, unless you're doing something wrong. If you need help on this,
just show some of your code.
|
|
|
|
|
Hi,
To reduce the memory consumption :
1- Use the jpeg format
2- Specify the compression level
3- Always dispose graphics objects, pens, images,.. and set them to null
Here some code to specify the compression level :
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
private void SaveJPGWithCompressionSetting( Image image, string szFileName, long lCompression )
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, lCompression );
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
image.Save( szFileName, ici, eps );
}
|
|
|
|
|
I have a program it contains 7 dll files and 1 exe files.
but i see dll files can be used by other developer by adding referance. How could i restrict this? Or could i add files to Exe ?
|
|
|
|
|
Hi,
if all your source code uses the same language (say C#) you can organize it all in one project, resulting in one exe file, zero dll files.
The main reason for dll files is to support reuse (either Controls that can be added
to Visual's toolbox, or general classes e.g. for numeric algorithms, graphic library,
encryption, whatever). Once you have the dll, and some knowledge about it, you can
create new projects that make good use of it. And so can others.
A secondary reason to use dll files is for mixing languages (say C# and VB.NET).
If you want to protect your intellectual property, putting it all in a single exe is
only a small improvement, since .NET byte codes can be decompiled with tools such as
Reflector, wheter in dll or in exe.
|
|
|
|
|
Thanx
i added all dll source code into main project.
I created this dll files to reuse just by me. but i cannot allow this files can be used by someone. I mean
how could i restrict this?
adding Strong key is a solution?
or GUID number?
or what is the best solution.
|
|
|
|
|
Hi,
I dont really know; you can make it more difficult for others to use a dll, by giving
it a complex API, with methods that need to be called in a specific order, with
extra arguments that must match some criterium, etc, but using a tool such as Reflector
one can always see how you do it.
A strong key will not help, it is intended to prevent someone to use a different
dll underneath your exe in order to falsify your app. That's not what you are after is it ?
|
|
|
|
|
I'm writing a multithreaded application, and in some phase in my program i have to add
a row to the datagridview control from thread other than the thread the control created
in, but when using this line of code
Control.CheckForIllegalCrossThreadCalls = false;
when the rows count comes out of the datagridview control visible area,and then try to
add a row the program stuck on screen (NotResponding).
so i want to know how to call an invoke method on a datagridview control to add a row?
in order to make the call a thread safe.
thanks in advance,
|
|
|
|
|
Hi,
the InvokeRequired property and Invoke/BeginInvoke methods work the same on all controls,
you can find many articles about that subject.
Both of my articles also show a very simple example; I recommend you look at MainForm.cs
in the Sokoban article.
You must follow the rules here; if you dont, it may or may not work on .NET 1.x
(not work here means freeze); on .NET 2.0 and above, it will throw an exception.
|
|
|
|
|
|
Hi, I keep getting the error "The requested URI is invalid for this FTP command." when trying to upload a file from local machine to the FTP server using code below in C# 2.0. I am getting error on the bold line below.
I would appreaciate if someone can guide me to proper solution.
thanks
Mahesh
public void Deliver()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(destinationHost); //destination host is ftp://actual IP address/
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(userId, password);
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(sourceDirectory + sourceFile);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream(); //getting error here stating requested uri is invalid for this FTP commnand.
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
}
Thanks
Needy
|
|
|
|
|
First,I'd like to thank you for this great effort
how can I shutdown and restart my computer from my app
Dad
|
|
|
|
|
Hi.
You can use WindowsController class, which you can find here: http://www.mentalis.org/soft/class.qpx?id=7
It's really easy to use, for example to shutdown your computer, just write:
WindowsController.ExitWindows(RestartOptions.ShutDown, false);
In file with this class, you'll find simple example.
-- modified at 16:58 Thursday 1st March, 2007
|
|
|
|
|
Hi,
the single-line solution is:
System.Diagnostics.Process.Start("Shutdown", "/s"); // shutdown
System.Diagnostics.Process.Start("Shutdown", "/r"); // restart
/
|
|
|
|
|
|
Hi all,
I am new to c#, learning lots iof new things everday!
I would like help with a simple function, what few lines of code do i need in order to do the following:
A String is passed into the function as parameter (string s), what would i need to add in the function for the number of words to be counted in that string and the result returned as a integer?? any ideas
I know its a simple thing, but im new and would like some help.
Cheers
|
|
|
|
|
This should do the trick:
inputString.Split(" ").Length
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
it.all,depends;on_the_definition of a'word'.
|
|
|
|
|
Luc Pattyn wrote: it.all,depends;on_the_definition of a'word'.
Very clever.
|
|
|
|