|
You should actually declare them as const s. When it comes down to it, that's all they really are in C/C++ - constants. Since they're pre-proc definitions, they can't be changed by code. The value is actually inserted.
When you declare them as consts, the value is actually used as well. Those values will never change, and using consts is faster.
You can also use enums, which is another common way (but often requires casting to an int or something). The values of the enum are also used in place of a reference (they're value types).
That's just the way it is.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
t h a n k s
/\ |_ E X E GG
|
|
|
|
|
Since you cant use C++ .H files in C#, you have to recode the structures and constants you need from the header files into C# code. Just like Mazy showed you...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
like sorta make a class library out of them?
/\ |_ E X E GG
|
|
|
|
|
You could. Then in that library, you make the function declarations static so you don't have to instantiate the class in order to use the functions.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If I insert .wmf file to an RTF file programatically Or simply by 'opening that RTF file and insert picture' way, it works fine. But when I select the image and try to compress or enlarge it, the line width of the image changes. How to avoid that? I want to make the widh of lines FIX.
Please guide
|
|
|
|
|
What do you mean by "lines"? An image - such as a .wmf - takes up a block of space, not lines. When you change the size of the image, the lines above and below it (perhaps beside it as well, if there's any wrapping) will move, too. This is true even in Word unless you change a lot of settings that aren't available in RTF.
If you want to learn about the RTF codes that you could try to fanagle, read the RTF 1.7 Specifications, available for download at http://www.microsoft.com/downloads/details.aspx?FamilyID=e5b8ebc2-6ad6-49f0-8c90-e4f763e3f04f&DisplayLang=en[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the reply. I am reading RTF 1.8 Specification.
Let me re arrange my words, "Lines" means, lets say I draw a simple line in .wmf file and add that to RTF document. When I open the document and select .wmf image with the help of mouse and enlarge it, the size (width and height) of the rectangle (i.e. wmf image) increases that is acceptable but at the same time the line's width also increases, it becomes fat. Can we not control it at the time of creation of .wmf image?
sorry for messy description
|
|
|
|
|
That's what's supposed to happen. WMF is a vector graphic, meaning, basically, that the instructions to draw shapes is stored, not the shapes themselves. This is so that proportionally the graphic looks the same at any resolution.
Now, there may be a way to draw a rasterized shape (rendered) but I really don't know.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yes you are very correct, all theory I read so far say the same thing about vector graphics and it is also said that .wmf can contain rasterized shapes (like bitmaps ) but nothing is said about how to add bitmaps to .wmf
may be i need to search more.
thanks
|
|
|
|
|
I have three classes A,B & C
A can instantiate B
B can instantiate C
but A cannot instantiate C
How can we do that
|
|
|
|
|
Put B and C in a separate DLL and mark C as 'internal', instead of 'public'.
Other way is making C a protected (or private) class inside the class B.
Yes, even I am blogging now!
|
|
|
|
|
I give up. Is there an option D?
|
|
|
|
|
Hi, where can i foud a library for probabilty.
normal, binomial, etc probabilty distrbutions.
Thanks.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Hi there!
I had the same problem some months ago and couldn't find a complete C# library for this. So I've done this myself. In recent future, I want to write an article about that but have no time for this now.
Anyway, to get what you want, there are two ways.
Either you can look for some Probability Library which is written for C++ or so and use it to create a Class Library for .NET. Take a look at this article[^] here on CodeProject which presents a wrapper for the random generators of the Boost.Random library for C++. As the Boost library also contains numerous distributions you could write a wrapper for them on your own orientating on the work done with the random generators.
The other and as I think preferable way would be implementing the distributions completely on your own. This isn't very hard, as they only do some mathematical operations with the numbers provided by a random generator. To know which mathematical ops you have to perform take a look at existing implementations of distributions like the Boost Library. Also I found this nice site[^] which provides good information about some distribution including formulas how to create the random numbers.
Hope this helps!?
www.troschuetz.de
|
|
|
|
|
Thank you! I will be waiting your article.
For now I will make something with my old probabilty books andyour links.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
The pleasure was mine!
machocr wrote:
I will be waiting your article.
Good to know that at least someone will read it
I will try to remember giving you a note when it's online. Hope I get this done in July after finishing my Bachelor thesis.
Until then, Happy Programming
www.troschuetz.de
|
|
|
|
|
Hello, just wanted to say hello. I recently started programming in C# and this looks to be a good place to gain knowledge. I hope to share my rambling thoughts with you and pester you for questions as the year progresses... anyway; well met!
Work by day, learn by night.
|
|
|
|
|
Is there a way to make drawing of Metafile (WMF) anti-aliased?
When I draw any metafile I get jagged edges for lines or circles.
I tried using:
Graphics.InterpolationMode
Graphics.PixelOffsetMode
Graphics.SmoothingMode
and they don't do anything for metafiles. They do work when I use drawline or drawcircle.
Thanks.
|
|
|
|
|
still looking for a good (and fast) solution for the same problem...
please someone help
|
|
|
|
|
Hi, I'm writing a project that takes values out of a n OleDbDataReader and places them into a text file exactly.
In other words, it has start codes, end codes, and line terminator codes. The line terminator sequence is a 0x0A (LF) followed by 0x00 (NULL). However, when writing this, the next string to be written has strange characters in front of it, like it'll have the 0x00 and then 0x13, which if left in and used in production, will cause the system that processes this file to reject it.
I'm using a BinaryWriter, and it's opened with ASCII encryption specified, so I do not know what is wrong. Anyone have any ideas?
|
|
|
|
|
Since you have specified ASCII encoding, I assume you are using the string overload of the BinaryWriter.Write method. This method writes strings prefixed by their length. That explains the strange characters you are seeing.
You would be better of converting the string to a series of bytes or chars first.
|
|
|
|
|
Using the String class's ToCharArray() worked, but just out of curiousity, is there a similar function that would do the conversion into a byte array?
And thanks for the solution, like I said, it's just a matter of curiousity, what I have now does work.
|
|
|
|
|
See the System.Text.Encoding class, and use the correct encoding.
Also, keep in mind this isn't a text file you're creating. The line endings are wrong (should be Environment.NewLine , but can be others except the null-terminator throws it out of whack). It you want a text file, use a TextWriter derivative. Unless you're trying to write a CSV, you can always base64-encode (or whatever encoding you want, but the .NET FCL doesn't have support for others at this time) binary data. You can use the Convert.ToBase64String or Convert.ToBase64CharArray methods, or the ToBase64Transform for streaming support (in this case you'll need to use a StreamWriter to get access to the string, or use a MemoryStream temporarily then use the Encoding class to write it to your text file).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have written a couple of windows services apps. when I test them they run fine and do what they are supposed to do. But after a couple of days or so, they are still running but do not perform the tasks. Any suggestions, if what could be causing it !
Would really appreciate any help.
Vinayak Katkam
japanreddy@yahoo.com
|
|
|
|