|
Makes perfect sense. Obviously not to the subject of Word Documents but anyway, thanks Colin
led mike
|
|
|
|
|
I'm sure I've answered you before but I can't be bothered to look. You're persistant at least - I'll give you that.
A quick bit of Googling revealed this page[^] that gives you code in C to write and read.
You may need to build this yourself to a dll in C++ and then provide a c# wrapper to it.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Miss_hacker wrote: why this code didn't execute??? what are my errors
Did it tell you anything? Or do you just expect people to read your mind?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
If I want a button to be repainted permanently at the click of the same button, how can I do?
So far I have tried to send the button as sender after it has been clicked to the button's paint event. This only works to some extent, the repainting comes on but as soon as the mouse cursor leaves the button, the repainting wears off.
I am looking for a way to make the repainting stay on permanently.
|
|
|
|
|
This may seem like a silly answer (I never use the painting stuff and I'm really having trouble saying this without sounding like a prat), what's wrong with the background/foreground settings. Why are you trying to "repaint" it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Not a silly question at all. I am trying to repaint it because the next course in school will have exercises where repainting in this manner is necessary. I am just trying to get prepared.
|
|
|
|
|
You really can't do this because your going to tie up the UI thread with constant WM_PAINT messages. You won't be able to do anything else in the application.
Perhaps a better explanation of what the point of repainting a button would help? And don't say "because that's what were doing in class"...
|
|
|
|
|
Sounds like you need to set a flag that you can test to see if your painting should be used everytime the control is Invalidated and test that flag in the overridden OnPaint.
This site[^] has some cool user button codes that you may find useful.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi!
I need the coding for inserting image in header/footer of a word document using c#, Windows Application.
Thank you...
|
|
|
|
|
No.2[^]
While (true) { Human.isLearnable = true; }
|
|
|
|
|
|
Morning fellow code writers...
I have a try and catch process that is giving me fits...If I eliminate the throw new Exception(ex.Message); line I get an error: Error 3 Use of unassigned local variable 'tbl'.
Can somebody enlighten me as to why this is happening??
catch (Exception ex)
{
MessageBox.Show("The following error occurred :" + ex.Message, Application.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Information);
string logFile;
string logPath = Application.StartupPath + "\\logs\\";
logFile = (logPath + global.logDate + ".log");
StreamWriter writer = new StreamWriter(logFile, true, System.Text.Encoding.ASCII);
writer.WriteLine(System.DateTime.Now);
writer.WriteLine("[Process #]");
writer.WriteLine("[get data]");
writer.WriteLine(ex.Message);
writer.WriteLine("\r");
writer.Close();
throw new Exception(ex.Message);
}//end of catch
return tbl;
}
}//end of class name
}//end of namespace
TIA
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Rafone wrote: return tbl;
What is this "tbl"?
While (true) { Human.isLearnable = true; }
|
|
|
|
|
I guess you always throw an exception in the try block as well. If that's the case, the return statement would never execute and the compiler ignored the fact that you used tbl without assigning a value to it. If you remove the throw statement (either in the catch or in the try block), that line of code would execute and therefore the compiler complains.
|
|
|
|
|
I guess you are assigning value to tbl in try block don't you? If an exception occurs then tbl variable can be unassigned so if you remove throw new Exception(ex.Message); from your catch block then the function must return tbl but it will be unassigned hence the error. On the other hand, throwing new exception means that there is no need to return tbl.
By the way, why don't you use log4net[^] for logging purposes?
|
|
|
|
|
THX for the tips..
Giorgi Dalakishvili wrote: By the way, why don't you use log4net[^] for logging purposes?
Ignorance....I did not know it existed. I will look into that.
thanks again
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
I found NLog[^] more accessible, although it appears not to have been updated for a while. NLog is derived from log4net. The forum is active though and 2.0 is in the works.
Kevin
|
|
|
|
|
Rafone wrote: Morning
It is early evening where I am.
Rafone wrote: If I eliminate the throw new Exception(ex.Message); line I get an error
Without seeing the rest of your code I'm guessing here.
You have, I guess, declared tbl outside of the try/catch block. Something is assigned to it inside the try block.
When you throw the exception in the catch the compiler knows that return tbl will always have something assigned to it, because in all other instances you are exiting the method before it can return it.
Also, your code contains a bit of a WTF. At the end of your catch you have throw new Exception(ex.Message) - By doing that you are discarding all the information in the current exception (there is a lot more in there besides the message you know). You should retain that information so that you can debug things properly in the future. You have two strategies:
1. throw new Exception(ex.Message, ex);
or
2. throw;
In this situation option #2 is preferable because you are adding no value in #1.
Finally, don't catch Exception, use a specific exception type. Don't throw an Exception either, again, use a specific exception type. If a specific type does not exist then create one.
|
|
|
|
|
Thanks for the explanation it has helped alot.
Colin Angus Mackay wrote: You should retain that information so that you can debug things properly in the future. You have two strategies:
1. throw new Exception(ex.Message, ex);
or
2. throw;
I have implemented option #2 here
Thanks for the advice...
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Rafone wrote: Error 3 Use of unassigned local variable 'tbl'.
That's pretty self explanatory. What is the code that is in the try block? You are attempting to return something for tbl when it has not been assigned anything. Not an error but rather a warning.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hey guys.
In the try block I am populating a datset and a table(tbl) and doing some other processing then saving the data to disk. All of the code works in the try block.
I set up an exception in the file name that I am saving to to get some error logging going.
the catch is almost a verbatum translation from some older vb code that works fine.
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
When you declare tbl, you aren't actually assigning anything to it. So, it probably looks something like this
DataTable tbl; Then you are assigning items to it in the try block. What you actually need to do is set it up like this
DataTable tbl = null; or better still, assign it in the try block and return it there. If there's an error then the return is superfluous, and it won't be hit.
|
|
|
|
|
I just finished reading a great article on Garbage Collection in the .NET Framework:
http://msdn.microsoft.com/msdnmag/issues/1100/GCI/
This article says that a garbage collection occurs whenever a new object needs to be created and there is not enough room on the heap for it. It says that the garbage collection will clear out the garbage objects to make room for the new object, but what if you have a large number of live (non-garbage) objects and the garbage collector is unable to free enough space for the new object?
Can the size of the heap grow at this point?
If so, what is the heap's default size and by how much will it grow in this situation?
I have searched and I have been unable to find the answers to these questions documented anywhere. There needs to be some official documentation on this.
Thanks,
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Mogaambo wrote: Can the size of the heap grow at this point?
Yes, you can check it out yourself. Open Perfmon (type perfmon.msc at the command prompt), right click on the graph and select Add Counters, select .NET CLR Memory and select one of the heap related parameters (#Total Committed Bytes, for example). Select your process and click OK. You should be able to watch the GC heap expand as you create more objects and don't release much.
Mogaambo wrote: If so, what is the heap's default size and by how much will it grow in this situation?
I don't the heap's default size (Gen 0 + Gen 1 + Gen 2 + Large Object Heap), I would imagine it would vary by platform (x86 vs x64), workstation vs server etc. The max size of the heap would be restricted to the max virtual memory of a process, which is 2 GB (actually 4, but the OS takes 2) on x86.
|
|
|
|
|
I recently read about writing Unsafe code in C#. Can anyone provide me with a simple scenario where this can prove to be useful. I can then implement it to have a better understanding of it.
I also read about stackalloc . It seems to be a very efficient way of using arrays. Still can not see it that prominent in codes. What is reason for that?
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|