I want to draw a reversible frame on my windows form. I have found the method ControlPaint.DrawReversibleFrame, but this method is not, what I'm looking for.
I need a dotted frame like a fokus rectangle.
Is there somebody who can tell me, how I can draw such a frame or how I can draw dashed lines with a XOR combination of colors?
If you need a focus rectangle, why not use ControlPaint.DrawFocusRectangle? You can specify both the foreground and background colors. If you need to invert the colors, you can create a new Color by XOR'ing each of the R, G, and B components with 0 or 0xfff.
If you want to draw a rectangle around the bounds of the control itself use the Control.Bounds property for the rectangle param of the DrawFocusRectangle method.
If neither of these approaches is quite what you want, you can draw dotted lines by using a custom Pen with the Pen.DashStyle property set in calls to Graphics.DrawLine or Graphics.DrawRectangle and similar methods.
sharing internet offline files between two OS?
which i mean if i have two OS Win 98 and 2000 Pro
and each one on different partition
and i connect to the internet using win 98 i want to see
the offline files win i'm using win 2000
i want to write program that do this or if there are solution at the windows
please tell me
Why are you posting this in the C# forum? This is a Windows question and should be directed to the appropriate forum or the Lounge. I will answer anyway, but please do not post in an inappropriate forum again.
There is a solution in Windows already. Add a favorite to a web site and check the "Offline" check box (or something like that) to download a cached copy. This will be limited to the current OS unless you share the same Internet Cache folder for Internet Explorer in both operating systems, but remember that Windows 9x/ME cannot access NTFS so you'll either have to format your Win2K partition as FAT32 (not a good idea because you loose file security features) or have Win2K access the FAT/FAT32 partition in Windows.
If you're talking about offline network share files, only Windows NT (which includes 2000, XP, and 2003) supports this so your Win98 installation will have to access that folder, which means you'll have to format the partition as FAT32 (again, a bad idea).
I'm curious if you know of any good documentation on how to convert a C# string to an MFC CString. A C# application I'm working on needs to call a C++ function exported by a dll, and the prototype of that function includes several MFC CString objects.
I suspect it's trivial to do, but that it involves some esoteric knowledge of the built-ins that I just don't have. I'm also hoping to circumvent the use of managed C++ to do this but simply preparing the correct byte-format structure that can sit in and be accepted and properly interpreted as a CString by the C++ function.
The first thing to do is read the documentation for the DllImportAttribute in the .NET Framework SDK, as well as the MarshalAsAttribute. The first is how you P/Invoke native functions. Since an MFC CString can be cast to an LPTSTR, you use use the UnmanagedType.LPTStr in the MarshalAsAttribute for the string parameter. There's also several articles about P/Invoke and interoperability in the .NET Framework SDK that should help.
I have any unusual question for you all. My piqued interest in the Thai lanugage/culture has prompted me to develop my own Thai Learning System. For the various consonants and vowels I want to animate how to draw each symbol. I was thinking of using a Thai True Type font and for each character animate along it to demostrate how it is drawn.
My problem is how can I read the true type fonts coordinates and animating along the symbol? Perhaps I need to hook the event that actually paints the symbols on the canvas then with my own event actually paint the symbol in some sort of time lapse fashion to present it in an animated fashion.
My other thought was to create a bunch of methods that draw each symbol as lines/arcs/Bezier Curves, but I figured it would be easier tracing the true type font in a generic fashion. With the lines/arcs/Bezier Curves I don't know how to get teh GDI+ engine to animate the points. Is there a way?
If anyone has any other suggestions or a better solution, which I am sure exist, please let me know.
First of all, .NET doesn't contain such low-level hooks. All you could do is draw the fonts yourself. I'm not even aware of any way to control fonts to such a degree exposed in the Win32 APIs and I've spent over a decade getting headaches from them (though such headaches might have lead to temporary blindness, causing me to miss such functionality )! This would be a function of GDI so you could look into the documentation.
Besides, true type fonts don't really contain any data that would allow you to show how each character is drawn. They contain points that help with resizing but those aren't in any order that is representational to how a human would draw them.
Your best bet will be to - as you didn't want to do - use lines, beziers, etc., to draw the characters.
Might I recommend Macromedia Flash, though? I've seen a lot of examples of similar presentations that actually draw things in steps. You would also be able to easily host this in a web page (you can with .NET controls, but it requires the ~20 MB framework and a pre-installed security policy to allow your code form a specific site to run), any COM client, or even a .NET application (which can be a COM client).
If you wanted to use GDI+ in a .NET application, you would have to worry about all the animation. For example, if you use Graphics.DrawLine to draw a line, the line is just there. It won't be animated. You'd instead have to call Graphics.DrawLine repeatedly to draw longer and longer lines until you reached the desired length! That's easy, though, compared to curves - you would have to calculate each point in the spline or the start and sweep angles for arcs with each iteration of the animation!
You could use Managed DirectX - which will help you with graphics a little - but you'd still need to worry about creating a package to handle the character animation. Things like Flash and even DHTML with vector graphics already have this support - you just have to tell it how to animate what you want.
While the GraphicsPath and Matrix classes aren't supported in the Compact Framework, the Graphics class is. It won't be easy since you'll have to do a lot of calculates instead of harnessing the power of the Matrix (and I thought the "Matrix" was a bad thing! ), but you could perform all the drawing using the methods of the Graphics class.
I've stumbled upon a behavior of the .NET RichTextBox that I think is a bug, and I wanted somebody to do a sanity check before I report this to MS.
Below is a code listing. It displays a form with a RichTextBox control in it. Ctrl++ and Ctrl+- increase/decrease zoom. Space and Backspace keys change content of the text box.
Currently, zoom step is 0.5. Notice that when zoom factor is 2.0 (you can make it that by pressing Ctrl++ twice), the text box doesn't retain the zoom factor when its content changes. When you uncomment MessageBox statement in DisplayText (uses Clear() method of the text box class) method, you can more glimpse of the weird behavior. It is actually different with the MessageBox there. Increase zoom to 2.0 by pressing Ctrl++ twice and then press Space or Backspace repeatedly and notice zoom factor change from 2.0 to 1.0 to 2.0 to 1.0, …
After that, change the zoom step to, say, 0.3 (zoom factor doesn't become 2.0 with this step), and notice that the box behaves as expected (the zoom factor remains as set).
Is this a bug or reflection of my wrong expectations?
#region Windows Form Designer generated code
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
private void InitializeComponent()
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)
I'm seeing this behavior too, odd. I don't see anything wrong with your code right off hand (hey, just have to check before filing a bug ) and looking at the IL for the RichText.set_ZoomFactor (and a subsequent call to a private method) doesn't show any calculation bugs either. I'm guessing this is actually a problem with the Rich Edit common control somewhere in the EM_SETZOOM message handler.
So, googling for "Rich Edit" EM_SETZOOM[^] shows you're not the only one! Feel free to report, though. Maybe someone hasn't yet. Never know.
Problem: I need to call a function when either a combo box selection is changed or some new text is typed into the combo box.
SelectedIndexChanged takes care of the first half, but I can't figure out the OnTextChanged part.
Does anyone know what event is triggered when a user types in text into the ComboBox?
I know there are Enter and Leave events... but then I will have to keep track of whether the text changed myself, and that's my very last resort, because I have a gut feeling (called laziness ) that there has to be a better way to do this
I don't see the advantage of using the KeyDown event instead of the Leave event. I got to store the value and do everytyhing manually anyway.
Plus neither KeyDOwn nor Leave will catch the cases when the ComboBox is set programmatically.
I guess there is no ComboBox.OnSelectedValueChaged silver bullet.
The TextChanged event fires if your ComboBox.DropDownStyle is set to ComboBoxStyle.DropDown. The unfortunate part is that is fires for every character typed, so you might want to handle the LostFocus event or the Validating event in order to add the new text or to call the function after the text is entered in its entirety.