|
I have an RTF which is being used do text editing. When an existing text document is placed in the control, it automatically adjusts lines based on the text fitting inside the window. However when I issue a editWindow.GetLineFromCharIndex() it returns a line number (3 for example) which is outside of the internal editWindow.Lines property within the control.
So line 3 may visually be the 3rd line of text. Yet internally all of the text only exists on line 1.
Is there any way to get the Lines property of the RTF to match the visual lines created via WordWrap???
Thanks!
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
I am new to C# and looking for a little help. I need to programmatically
add users "User Logon Name" / "WinNT logon" to the windows 2000 Active Directory. I need to control/add other properties, but for now this is the main objective.
I have successfully added pre-Windows 2000 users with DirectoryEntry & NetUserAdd, but can't find the syntax to add a WinNT logon name.
I am using Visual Studio.Net 2003
Thank you,
markaelkins@gmail.com
Other properties that I need to control/add: (password, Full name, pre-Windows 2000 logon, User cannot change password, Password never expires, Description, Office)
|
|
|
|
|
I have a progress bar. I would like to display a transparent label OVER the progress bar to show the % completed. It seems like all of the techniques related to creating a transparent label only make the label's background transparent relative to its parents background rather than relative to any sibling controls that might be draw UNDER it. Does anyone know of a way to draw a transparent label so that the text area of the label displays the content under the label rather then the background color of the parent container?
thanks.
|
|
|
|
|
A more appropriate way would be to extend the ProgressBar control and draw the label yourself. Putting a transparent control over it will require owner drawing anyway (to mask out everything but the text, which isn't easy if you want anti-aliased text) and will require more memory since another control is required (controls are windows and too many is very expensive).
So, extend the ProgressBar class and draw the text in the middle like so (just a basic example):
public class ProgressWithText : ProgressBar
{
Brush textBrush;
public ProgressWithText()
{
SetStyle(ControlStyles.UserPaint, true);
textBrush = new SolidBrush(ForeColor);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Value.ToString() + "%", Font, textBrush,
(RectangleF)Bounds);
}
protected override void OnForeColorChanged(EventArgs e)
{
base.OnForeColorChanged(e);
if (textBrush != null)
textBrush.Dispose();
textBrush = new SolidBrush(ForeColor);
}
} If you want to change the color of part of the text when the actual progress bar moves under the text, you should consider painting the whole thing (easier in the long run), which isn't too hard. Search for "progress bar" on this site for a number of good articles about owner-drawn progress bars.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks, however when I go to compile this code, the compiler tells me that I can't inherit from ProgressBar because the class is sealed.
|
|
|
|
|
Hmm...so it is. I must apologize. I've never had a reason to extend it and other controls are sealed that I have extended. Progress bars are very easy to create. Please follow my suggestion to search this site for "progress bar" and you'll find lots of articles how, including progress bars with gradients, custom pictures, and more; some even provide sample code that shows how to draw the percentage text (similar to how I did it above).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi
I'm having an error "A generic error occurred in GDI+." with the following image resize code. can anybody help. PLZ
private void cmdStart_Click(object sender, System.EventArgs e)
{
if (( File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{
//determine file name
string szFileName = System.IO.Path.GetFileName(File1.PostedFile.FileName);
Size s = new Size(75,75);
ImageResize(File1.PostedFile.FileName,s);
}
}
void ImageResize(string str_file, Size new_size)
{
try
{
System.Drawing.Image src_image = System.Drawing.Image.FromFile(str_file);
Bitmap bitmap = new Bitmap(new_size.Width, new_size.Height,src_image.PixelFormat);
Graphics new_g = Graphics.FromImage(bitmap);
new_g.SmoothingMode =System.Drawing.Drawing2D.SmoothingMode.HighQuality;
new_g.InterpolationMode =System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
new_g.DrawImage(src_image, 0, 0, bitmap.Width, bitmap.Height);
src_image.Dispose();
bitmap.Save("C:\\Inetpub\\wwwroot\\ImageConverter\\bin\\resize.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
new_g.Dispose();
bitmap.Dispose();
}
catch(Exception e)
{
string a = e.Message;
}
}
Thanks
Gary
|
|
|
|
|
I have a couple of questions.- On what line, exactly, does the exception get thrown? Please step through your code in the debugger. I'm assuming it's
Graphics.DrawImage . - What is the pixel format of the image that you ran through the method?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
The exception is being thrown on the bitmap.save method.
Thanks
Gary
|
|
|
|
|
What as the pixel format of the original image you passed through the method?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
One other thing I noticed that, if "ImageConverter" is your ASP.NET project, you should not put files in the bin sub-directory. If ASP.NET is configured to handle the .jpg extension, then - by default - users will not be able to access bin\resize.jpg because access to files in the bin directory is disallowed by ASP.NET. You should consider saving the file to a directory users can access if you plan on passing it back as the src attribute of an IMG tag.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I am trying to set the value of a DateTimePicker to the first of next month in a UK date format.
ie every day this month (March) the DTP will read 01/04/2005 then next month it will read 01/05/2004.
Anyone know how it can be done? I've sorted the month part out with AddMonth(1) but have no idea how to set the date to 01 each time?
Please can someone help?
Thanks in advance
Scott
|
|
|
|
|
Alright mate, not sure I understand your problem but hopefully the code below will help.
DateTime startOfMonth = DateTime.Now.AddMonths(1);
startOfMonth = startOfMonth.AddDays(-startOfMonth.Day + 1);
The code add's one month to the current date and then defaults the date to the 1st of the month.
|
|
|
|
|
Do keep in mind that the DateTime type always uses the Gregorian calendar, so you should use the Calendar class to truly get the right date if not doing this strickly for the DateTimePicker . See http://blogs.msdn.com/michkap/archive/2005/03/28/402839.aspx[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for replying folks, much appreciated.
The code works perfectly, thank you.
I will bear that in mind about the Gregorian Calendar too, thanks for pointing it out.
Again, much appreciated.
Scott
|
|
|
|
|
Hi all,
I was experimenting with generics and some new stuff of ASP.NET 2.0 in whidbey beta1 given during Teched 2004...everything was working fine till last night..and suddenly today morning when i opened beta1 horrible dialog box saying - "The beta period has expired- thank you for participating in our beta program, you can now safely remove Microsoft development environment from your computer" appeared...I have checked google and found that expiry date of whidbey beta1 is around 15th July 2005..so whats up???
The strange thing is - "It didnt show me any warning that my version is going to expire..." My colleagues are using the same version(teched beta1) but its fine for them...
So, Is there any way by which I can open that solution!!!!
Thanks in advance!!!
REgards
MaulikCE
i don want
|
|
|
|
|
Why not just use the Whidbey Beta 1 that's freely available on MSDN? You can download the express versions or have them mail you a DVD of the Enterprise version.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
Check the date on your system. You system may be set to a date of future.
|
|
|
|
|
I want to duplicate a file.
However, exception occured when I use the Copy method twice.
e.g.
File.Copy("from1.jpg","to.jpg,true");
File.Copy("from2.jpg","to.jpg,true");
How can i solve it?
|
|
|
|
|
|
Thank you for your reply.
The exception is about the file is being used by other application.
In my algorithm, they should be copied to the same file name.
How can I solve it?
|
|
|
|
|
|
BTW, why are you copying these files to one file? The second copy operation is overwriting the first copy you did, so why copy the first file at all?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Greetings to you all
I'd Like to know if there is a simple way to do the application translation to another languages
something like the string tables in the VC++
Best Regards
Diogo Alves
|
|
|
|
|
Not translation, no, but localization and globalization, yes. Read Developing World-Ready Applications[^] in the .NET Framework SDK for detailed information. ResX files are actually better than string tables because you can store more than just strings. Even something as simple as string formatting is better in .NET because you can specify which arguments go where in a string, meaning that you can localize the format string but still specify the parameters in the same order for any language. See my article, Custom String Formatting in .NET[^], for a discussion about this.
If you're using Visual Studio .NET to develop your managed applications, developing world-ready applications could be much easier. Design your UI and all the text, the select the form and open the PropertyGrid (should already be open; otherwise, right-click and select "Properties"). Find the "Localizable" property and set it to "True", then find the "Language" property and set that to another language. You can then change your strings, control sizes and locations, and more.
A few things to keep in mind. The neutral language - the language in which you develop and that the primary assembly (the assembly with code) uses - should not be localized separately. This is also the fallback language if a satellite assembly cannot be found. This is covered in the documentation I linked first. To make your application run faster, you should put the following attribute in your AssemblyInfo.cs file (or anywhere, actually, but that source file is most common):
[assembly: System.Resources.NeutralResourcesLanguage("en-US")] Here, my neutral language would be "en-US" (English (U.S.)) because that's the language in which I developed the primary assembly. I could then switch to "German" (for an invariant locale, which means I'm just localizing the German language but not for a particular region) and change my UI. When you compile, several assemblies are produced. You must ship all to have your localized UI displayed correctly.
The localized UI is controlled by the Thread.CurrentUICulture . Windows will set the thread's LANGID (the CurrentUICulture) to the user's preferred (or the system's default) LANGID, but you can override that by setting Thread.CurrentUICulture before displaying your UI.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|