|
You may want to look in Microsoft.DirectX.DirectSound namespace
Regards
|
|
|
|
|
using System;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public interface a<br />
{<br />
void b();<br />
}<br />
public interface c<br />
{<br />
void b();<br />
}<br />
public class Class1:a,c<br />
{<br />
public Class1()<br />
{<br />
}<br />
#region a Members<br />
<br />
public void d()<br />
{<br />
}<br />
<br />
#endregion<br />
<br />
#region c Members<br />
<br />
public void b()<br />
{<br />
}<br />
<br />
#endregion<br />
}<br />
} compiler is saying ok.
but if i have to definf different data in bath cases.
Then what?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
An interface is like a contract. It only says that for your to be a member of that conract you must have a minimum set of members -Methods & properties-. So a.b() & c.b() are only declarations of a method called b() & they have nothing to do with the implementation. The class is concerned with defining how the method will work. Let's take a clearer example
Interface Author
{
public void WriteAnArticle()
}
Interface Editor
{
public void WriteAnArticle()
}
Class Me : Author, Editor
{
public void WriteAnArticle()
{
}
}
So whether you are an author or an editor you must write an article, but how you write the article is up to you.
Regards
|
|
|
|
|
It would be easier to follow your example if you used some meaningful names, instead of names like a, b, c, d and Class1.
If you want separate implementations for the interfaces, you have to implement the explicitly:
public void a.b() {
// method used when the object is used with an a reference
}
public void c.b() {
// method used when the object is used with a c reference
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,...
My Code is like this
void hooks_MouseDown(object sender, MouseHookEventArgs e)
{
if (e.Button == MouseButtons.Left && this.thisKeyboard.CtrlKeyDown)
{
IHTMLDocument2 htmlDoc = (IHTMLDocument2)((BasketToolBar)this.Tag).WebBrowser.IWebBrowser_Document;
IHTMLElement el = htmlDoc.elementFromPoint(e.X, e.Y);
}
}
Now when i am clicking on any image inside frame i am gatting IHTMLFrameElement not IHTMLImgElement.
How can i get that IHTMLImgElement inside frame.
Kiran Banker
|
|
|
|
|
I am giving answer of my problem.
Solution is as given below.
void hooks_MouseDown(object sender, MouseHookEventArgs e)
{
if (e.Button == MouseButtons.Left && this.thisKeyboard.CtrlKeyDown)
{
IHTMLDocument2 htmlDoc = (IHTMLDocument2)((BasketToolBar)this.Tag).WebBrowser.IWebBrowser_Document;
IHTMLElement el = htmlDoc.elementFromPoint(e.X, e.Y);
if(el.tagName.ToLower().Contains("frame"))
{
HTMLFrameElement frm =(HTMLFrameElement)el;
mshtml.HTMLDocument doc =(HTMLDocumen) ((SHDocVw.IWebBrowser2)frm).Document;
el = doc.elementFromPoint(e.X, e.Y);
}
}
}
Kiran Banker
Kiran Banker
|
|
|
|
|
Hi,
My Application attache on control with Internet Explorer and control has WebBrowser window control.
Now actually we are reading data from any web page and we capturing object and embed tag from that pages.
Now when we put that captured tag in our control it makes it autoplay.
And we want to stop that autoplay.
Code....................
IHTMLDocument2 htmlDoc = (IHTMLDocument2)((BasketToolBar)this.Tag).WebBrowser.IWebBrowser_Document;
IHTMLElement el = htmlDoc.elementFromPoint(e.X, e.Y);
if (el.tagName.Equals("OBJECT"))
{
HTMLObjectElement objEl = (HTMLObjectElement)el;
}
Kiran Banker
|
|
|
|
|
Good Day,
It has always bothered me on how to print on a Pre-Printed Form.
What I mean is, you have a form (For example, a Bio-Data form), then you print directly on the "blanks".
I know that you can programatically fill the blanks by specifying the x-y coordinates of those blanks. But, is there an easier way? Like, you scan the image, then put textboxes on the black and then proceed by txtName.Text = "My Name" then print it without the image?
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
I understand you want to print a report based on a form. I'm I right?
The method you want to use -printing the form itself as an image- isn't the best way. There are several articles on this site that explains this -one of them I wrote myself-, but I believe the best practice is using Microsoft Report, or crystal reports. You'll find a Control on the toolbox called MicrosoftReportViewer.
Regards
|
|
|
|
|
Thank you. I'll take additional readings regarding Microsoft Report.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
How much memory do uninitialized arrays take up? EX: int[] numbers;
Do uninitialized value types take space too?
|
|
|
|
|
An uninitialized array is an object with all data set to zero/null, which can be served by
one or more "demand zero" pages, i.e. it gets allocated in the page tables, but does not
require physical memory pages yet.
As soon as some of its data is needed (read or write) a page error will occur, and the MMU
(Memory Management Unit, a hardware part of modern CPUs) will, with the help of some OS code,
allocate physical memory for that page, and then fill it with zeroes.
BTW the page size typically is 4KB
Conclusion: an unitialized array is as expensive as a small object, no more, no less.
Value types are:
[ADDED]
- either local types
- or value members of some other type (such as an int inside a class object).
Local value types are [/ADDED] allocated on the stack, so they consume memory corresponding to their size
(although the stack too is virtual, i.e. if you allocate a huge struct, spanning many pages,
most of these pages again would not be allocated immediately).
There is no such thing as an uninitialized value type, every value type starts of with some
value; typically the language definition and compiler enforce this; example: in a struct
your constructor must assign a value to every member.
modified on Friday, July 4, 2008 10:41 PM
|
|
|
|
|
Hello Luc,
I agree with all what you said except "Value types are allocated on the stack". I believe it depends on the context where they are declared. Local variables goes to the stack, but instance variables will be on heap, AFAIK.
|
|
|
|
|
Hi N a v a n e e t h,
N a v a n e e t h wrote: it depends on the context
yes
N a v a n e e t h wrote: Local variables goes to the stack, but instance variables will be on heap
Not quite. There is no way to get a struct (or any other value type) directly
allocated in the heap.
Local variables are on the stack, value members of a type are located inside that type
(the int inside a class).
Remember:
Rectangle rect; is allocating storage for a Rectangle struct;
rect=new Rectangle(x,y,w,h); is not allocating anything, it is just
assigning values to the members of rect. It is equivalent to rect.X=x; rect.Y=y; ...
|
|
|
|
|
Yeah - Thanks
|
|
|
|
|
Array types are reference types even the element type is a value type. So int[] numbers would take 4KB of memory and will be kept on managed heap.
gigahertz205 wrote: Do uninitialized value types take space too?
Yes. There is nothing like uninitialized value type. Value types always will have a default value. So it takes space needed for keeping that value.
|
|
|
|
|
N a v a n e e t h wrote: So it takes space needed for keeping that value.
Address space sure, memory space only when the MMU page is actually needed.
|
|
|
|
|
Luc Pattyn wrote: memory space only when the MMU page is actually needed.
Yeah, you are correct. I forgot to mention. Thanks for mentioning.
|
|
|
|
|
N a v a n e e t h wrote: So int[] numbers would take 4KB of memory and will be kept on managed heap.
No, it wouldn't. It's just a reference, so it will only take up four bytes (on a 32-bit system) wherever it's declared. If it's a local variable, it will take up four bytes of stack space.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Ohh it's 4bytes, not KB. Thanks Guffa for correcting. You rocks /
|
|
|
|
|
gigahertz205 wrote: How much memory do uninitialized arrays take up? EX: int[] numbers;
It only takes up the memory used by the reference that you have declared. You haven't created the actual array yet.
gigahertz205 wrote: Do uninitialized value types take space too?
They take up the same amount of memory regardless if they have a defined value or not.
A value type that is a class member is always initialised. It's only when you have a value type as a local variable in a method that it can be undefined. It still has a value, but that value is undefined, so the compiler protects you from using the value before you have assigned anything to the variable.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i have developed an application which records the sound in c# i have this problem that
i have to enable the opetion of wave out mix in sound control panel using c# then the sound recording works other case no recording happens just blank file can you give me simple code example which just enable the wave out mixer option or stero mixer option in widows xp
just want to enable the option of setro mixer or wave out mixer using c#.THANKS in ADVANCE
its me yami
now cheers
|
|
|
|
|
I was gonna post this on Monday when back at work with the code in front of me but it's bugging me so I thought I'd post now! (will post code on Monday if needed).
For storing some semi-sensitive data I have a string.Encrypt extension method that uses Rijndael encryption. This encrypted string is then used as a key in a dictionary, which is serialized using Binary serialization.
All this works fine and the data is encrypted/decrypted perfectly but when doing something such as
Value myValue = myDictionary[key.Encrypt()]; the key is never found, but if I do a foreach and do a decrypt on the Key from the KeyValuePair, and compare with key (no encryption) it matches!?!
Any ideas cause it's got me beat!
Dave
modified on Friday, July 4, 2008 4:14 PM
|
|
|
|
|
What does the Encrypt method return? A byte array?
The default equality comparer for a byte array doesn't compare the contents of the arrays, it only compares the references of the array object. If you want a dictionary with a byte array as key, you have to create an equality comparer that the dictionary can use.
I wrote an article about how to implement an equality comparer for a dictionary:
Dictionary with a custom key[^]
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
It returns a string so it shouldn't be anything to do with references.
As I said the codes at work but I've coded up a quick example that replicates the issue here. As you will see, the encrypted keys are different (why?) but it decrypts correctly. (This example has ruled out serializazing/deserializing as the issue)
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Crypt
{
class Program
{
public static string password;
static void Main(string[] args)
{
Console.Write("Please enter your password: ");
password = Console.ReadLine();
string plainKey = "Test key";
string value = "Test value";
MyDictionary myDictionary = new MyDictionary();
Console.WriteLine("Adding key: " + plainKey);
myDictionary.AddItem(plainKey, value);
Console.WriteLine("Looking for " + plainKey.Encrypt(password));
Console.WriteLine("Found :" + myDictionary.ContainsKey(plainKey.Encrypt(password)));
Console.WriteLine("Dictionary contents:");
foreach (KeyValuePair<string, string> entry in myDictionary)
{
Console.WriteLine("Encrypted: " + entry.Key);
Console.WriteLine("Decrypted: " + entry.Key.Decrypt(password));
}
Console.ReadKey();
}
}
class MyDictionary : SortedDictionary<string, string>
{
public void AddItem(string plainKey, string value)
{ this.Add(plainKey.Encrypt(Program.password), value); }
}
public static class Extensions
{
public static string Encrypt(this string str, string password)
{
RijndaelManaged cipher = new RijndaelManaged();
byte[] plainText = System.Text.Encoding.Unicode.GetBytes(str);
byte[] salt = Encoding.ASCII.GetBytes(password.Length.ToString());
cipher.Padding = PaddingMode.ISO10126;
PasswordDeriveBytes key = new PasswordDeriveBytes(password, salt);
ICryptoTransform encryptor = cipher.CreateEncryptor(key.GetBytes(32), key.GetBytes(16));
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write);
cryptoStream.Write(plainText, 0, plainText.Length);
cryptoStream.FlushFinalBlock();
byte[] cipherBytes = memoryStream.ToArray();
memoryStream.Close();
cryptoStream.Close();
return Convert.ToBase64String(cipherBytes);
}
public static string Decrypt(this string str, string password)
{
try
{
RijndaelManaged cipher = new RijndaelManaged();
byte[] encryptedText = Convert.FromBase64String(str);
byte[] salt = Encoding.ASCII.GetBytes(password.Length.ToString());
cipher.Padding = PaddingMode.ISO10126;
PasswordDeriveBytes key = new PasswordDeriveBytes(password, salt);
ICryptoTransform decryptor = cipher.CreateDecryptor(key.GetBytes(32), key.GetBytes(16));
MemoryStream memoryStream = new MemoryStream(encryptedText);
CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
byte[] plainText = new byte[encryptedText.Length];
int decryptedCount = cryptoStream.Read(plainText, 0, plainText.Length);
memoryStream.Close();
cryptoStream.Close();
return Encoding.Unicode.GetString(plainText, 0, decryptedCount);
}
catch
{ return string.Empty; }
}
}
}
Dave
|
|
|
|