|
Unicode makes room for something like a million characters. Unicode does not take up any "bytes". It just define which "character" is at which number. In order to represent Unicode in memory or on file, you need an encoding of the Unicode character set.
The UTF-16 encoding (which is probably what you refer to as this is what C# use internally) will use 2 or 4 bytes per character.
|
|
|
|
|
well you can always use byte vectors, or pointers to byte in an unsafe part of the code... then you can use normal io.streamwriter for writing and io.streamreader for reading
<- true inside to understand outside ->
|
|
|
|
|
|
Im having a trouble to catch KeyDown event on the form.. it just doesnt work..
any other control on the form can get KeyDown event if ill set it to him
but the form event just doesnt work..
thanks..
|
|
|
|
|
The form itself rarely ever has the focus. The controls on the form have it, so the form's KeyDown event is rarely ever called. Unless, that is, the Form's KeyPreview property is set to true . This will pass all the keyboard events going to the form's control with the focus to the form's handlers first, then pass them on to the control that has the focus. There is a side effect to setting this though. The KeyDown event will fire for every keystroke going to any control on your form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks exactly what i was looking for !
they didnt mention that on MSDN..
|
|
|
|
|
Hi, I'm curious, why would a form need to catch keyboard events? What are you using it for? I can't think of any scenario where this can be used.
/Patric
My C# blog: C# Coach
|
|
|
|
|
Im building a small program which you can get the color of any pixel on the screen, color picker
after pointing on a pixel and getting its RGB and HEX into text boxes how would you remember them?
just clicking on a button will get them into a list of colors
|
|
|
|
|
Actually, they did. Form.KeyPreview[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How does one prototype an exported function call that has a HANDLE* parameter argument? I have tried "ref IntPtr" with no success.
Example:
C Prototype:
__declspec (dllexport) DWORD CALLTYPE func(HANDLE* phandle);
C# Prototype:
[DllImport("func.dll")]
static extern uint canOpen(ref IntPtr ptrHandle);
I get a "Invalid Handle" error from the OS when this is called.
TPF
|
|
|
|
|
Could the ref be causing the problem somehow? I'm using IntPtr's for handles while accessing user32.dll without issue.
|
|
|
|
|
T Finn wrote: ref IntPtr ptrHandle
Dont use ref . Else you are creating a pointer to a pointer.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
What is confusing here is that the argument is a pointer to a IntPtr (HANDLE). Passing a IntPtr as a handle works but this function calles for passing a pointer to a handle (HANDLE*).
T Finn
|
|
|
|
|
T Finn wrote: IntPtr (HANDLE).
Since when? HANDLE is a struct, iow a valuetype.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
After 22 years I am leaving AS/400 (shudder), dec unix, Linux, Java, openVms, MFC, C++, VB, Access, blah blah blah) to a new job that is pure C#/SQL.
After many years of being unmanaged , I am finally gonna get managed . ( I wish I could use VS C++ 2005 compiler for managed code, so I could manage the memory myself, sigh)
I have only done a few thousand lines of C# so here goes.
Pray for me.
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
Good luck then. I came from an unmanaged background as well (though admittedly not as extensive as yours), and am loving C#.
Oh, by the way, if you've done Java, then you've done 'managed' code already.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
> I wish I could use VS C++ 2005 compiler for managed code, so I could manage the memory myself, sigh
Don't worry. With experience you will slowly begin appreciate the fact that the computer can manage memory better at runtime than you think can at compile time.
Matt Gerrans
|
|
|
|
|
I have a picturebox, which displays a bitmap.
I have coordinates, width, and height defined which correspond to a section of the image the picturebox displays.
I need to create a new image, from the section of the previous image that corresponds to my x,y,width,height variables.
Basically, I just need to extract the corresponding section of the image and create a new image from it.
Any ideas?
Thanks!
|
|
|
|
|
Assuming you have controls PictureBox1 and PictureBox2, and you want (for instance) a 50x50 pixel area of the image in PictureBox1 to appear in PictureBox2, then the following should work:
Image original = pictureBox1.Image;
Bitmap bmp = new Bitmap(50, 50);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(original, new Rectangle(0, 0 , 50 , 50), 50, 50, 50, 50, GraphicsUnit.Pixel);
pictureBox2.Image = (Image)bmp;
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Members,
I have a user control embedded on a single form. The form has a pubic method that I created. I want this child control to notify the parent page when new data is entered in to a text field on the user control. I want to keep the user control responsible for only the information that it is gathering. However, I want this parent page notified when new records are created.
How do I pass the record id as a string from the embedded control to the public function on the parent page?
Thanks for the thought...
SD
|
|
|
|
|
Raise a message in the control that the parent form handles.
|
|
|
|
|
You may ( for further use ) create an event on the usercontrol itself which may be this_DataChanged and it tracks all the changes that may have been done , and then in every parent you add this control in you just handle it.
ex:
public class MyControl : UserControl
{
public MyControl() { }
public event EventHandler DataAdded;
public DataType PropertyName
{
get { return dataField; }
set { this.dataField = value; this.OnDataAdded(); }
}
private void OnDataAdded(object sender, EventArgs e)
{
if (this.DataAdded != null)
{
this.DataAdded(this.DataAdded, e);
}
}
}
public class MyForm : Form
{
this.MyInheritedUserControl.DataAdded+=new EventHandler(this.MyEventHandler);
}
hope this helps.
"I am a liar." Is this statement true or false ?
|
|
|
|
|
LongHC,
Thank you very much for the solution.
Per you comment, it depends...In the land of Knights and Knaves, where Knights always tell the truth and Knaves always lie, you could not be a Knight and a Knave would never offer the truth--therefore, you must be a Paradox.
William
|
|
|
|
|
Hello, Everyone. I am just wandering, if anyone has ever tried adding a NumericUpDown control to a MenuItem. Any feedback would be greatly appreciated. Thank you very much in advance!
|
|
|
|
|
Can't figure this one out. I've got a picturebox on my form. In the designer it's visibility property is set to true. In code depending on inputs I want to either have it display an image, or be invisible (with other controls adjusting their layout to take it's place). When I traced into the setup method I found that on entry the property was false, and remainded so regardless of attempts to set it. All 3 lines of code below represent attempts to change the property. The first is what I had originally, the 2nd and 3rd were done just to see what would happen. In the latter case I was checking against the posibility that somehow the clr was !ing the parameter.
this.m_pbImage.Visible = true; //false before, false after
this.m_pbImage.Visible = !this.m_pbImage.Visible; //false before, false after
this.m_pbImage.Visible = false; //false before, false after
If I set the image property it will display despite visible being set to false immediately before calling show dialog. I could do the repositioning code where I'm currently setting the Visible property, but I'd rather only doso once in an if-else than in each of a halfdozen case values.
|
|
|
|
|