|
Thank you very much for your answer. But, I write an application that is similar to MS Word, so I want to insert an image when my application is running. I can insert image, but when I use mouse to resize the image to a smaller or larger size, the image doesn't display correctly.
|
|
|
|
|
I see. I've used RichTextBox controls before, but never for images. Can you tell me how you insert the image? Do you drag and drop an image file into the running application, or use an OpenFileDialog, or ...? Also, are you trying to resize just the image inside of the RichTextBox or is the problem when you resize the application window?
|
|
|
|
|
I read an article at Codeproject http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp, and follow these instructions to insert image, but I have problem when I resize the image that I insert in my richtextbox.
Thank you for your help
|
|
|
|
|
Hello again,
Sorry to take so long to get back to you. I read the article you mention, and I think it's a good one. I'm assuming you started your application with something based on the RtfInsert project. This application will accept an image into the ExRichTextBox control, but it does not handle resizing those images. That, of course, is the problem.
To solve the problem, you will need to add code to your application to handle resizing the images. There are many ways to do this, that's the fun of programming! I'll suggest one possible way to go about it.
When an image gets inserted, you'll need to keep track of where it is located in the ExRichTextBox. That will allow you to determine if the user is clicking the mouse on the edge of the image to resize it. Also keep track of the path containing the image.
You'll need to handle the MouseDown and MouseUp events, some suggestions for those handlers appear next:
private void rtBox_Main_MouseDown(object sender, MouseEventArgs e)
{
Point mouse = new Point ( e.X , e.Y ) ;
_pointMouseDown = mouse ;
_resizingImage = true ;
}
private void rtBox_Main_MouseUp(object sender, MouseEventArgs e)
{
if ( _resizingImange )
{
Point mouse = new Point ( e.X , e.Y ) ;
}
}
Once you have the new dimensions, you can reload the image specifying the new dimensions. To do this, you'll need to modify the ExRichTextBox class. See the comments before the GetImagePrefix() function. You'll need to add a way to do most of this same stuff except using the dimensions you calculated earlier in place of the local variables "picwgoal" and "pichgoal."
Sounds like a lot of work? Yes, it will be. Should be a little bit of fun, too.
Happy programming!
BDF
|
|
|
|
|
Your reply helps me a lot. Thank you very much.
|
|
|
|
|
Hi,
I am developing a user app, which has to email me the errors if occur (hopefully not to many ). I do this with the system.net.mail namespace and works execellent within my office.
When delivering to beta-testers erros are not being mailt because the smtp server is not valid. Okay i get the security issues and spam issues to prevent this. But i would not have my users to add a smtp server by hand. So i thought i use my own domain mailserver and let users log in there and sent the mail to me. Compiled the smtp server, username, password in code. But the ISP does not allow any other smtp server on his network to send mails except its own. So this does not work either.
Is there a way to retrieve the current valid smtp server of the computer or read out of outlook and use that one.
The last solution is create a mail and popup outlook, but i rather do not.
Kind regards,
Marcel Vreuls
http://www.marcelvreuls.com
< >
|
|
|
|
|
Marcel Vreuls wrote: Is there a way to retrieve the current valid smtp server of the computer or read out of outlook and use that one.
What does the Outlook Object Model Primary Interop Assembly documentation say about that?
|
|
|
|
|
have not take a look at it. just wanted to focus on the first solution. Planning on doing that tonight and will post what i have found. Probably have to worry about different outlook versions or outlook express
Kind regards,
Marcel Vreuls
http://www.marcelvreuls.com
< >
|
|
|
|
|
What about a setup application where you ask the user to specify the smtp server?
Or you could use the yahoo smtp and send mail to a yahoo account. I think it allows that.
|
|
|
|
|
Or, skip the entire SMTP method and expose a WebService to the Internet that your application calls to report it's errors. No email involved.
|
|
|
|
|
There is no easy or certain way to find such a setting. There might be a default mail program, and there might not. The default mail program might have a user account that uses smtp, and it might not. The mail program might expose the user settings, and it might not. Probably not.
I was thinking the same as Dave, when I read your question. A web service seems like a good solution.
---
single minded; short sighted; long gone;
|
|
|
|
|
Indeed that i did not think of that . A webservice is the solution. just have to check if there is a internet connection present and go with it. Can store it in a database.
Exellent tip
Thank you
Kind regards,
Marcel Vreuls
http://www.marcelvreuls.com
< >
|
|
|
|
|
Is there a way to override the F1 event on the helpProvider?
|
|
|
|
|
There are three columns in a datagrid and first column will always contains values(for ex 4 records) but the second & third column may contain only 1 value or 4 records so kindly let me know in this type of scenario how to merge the rows and display the single value in middle against the first column values.
Thanks In Advance
Thanks In Advance
|
|
|
|
|
I propose you to make a googling[^].
I Love SQL
|
|
|
|
|
Hi all,
I have a combobox initially filled with a few string. When one of them is selected, the user is given the possibility to change it using a textbox. My problem is that I don't know how to modify the nth entry of a combobox. I thought to removing and reinserting it with the new value in the same position, but the selection of an entry starts a set of operations that make this quite complex to do.
Of course, I can think to a couple ways to hack this, but none of them appear elegant nor easy to make, so I wonder if there is a easier way.
Somone has a solution?
Thank you!
|
|
|
|
|
Reference the Items property of the combobox, passing in the index of the item you want to update.
Paul
|
|
|
|
|
To alter the selected text...
myListBox.Items[myListBox.SelectedIndex ].Text = "My New Value"; To alter a specific item...
myListBox.Items[ 4 ].Text = "Item 4 Text";
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Hi,
I've inherited a batch of functions whose signatures differ only in the fact that one group takes a short[] as the first parameter and one takes an int[] as the first parameter. I'd like to merge the bulk of the code into one function so that changes don't have to be replicated accross versions (there already is some code difference, but no functional difference!). My two ideas were: to use a generic method, or to have one of the overloaded versions call the other version.
The problem with the first (generics) is that I only want it to be able to accept int[] or short[], not some other type, and there are some explicit assignments such as "shortArray[i] = -12345;" that the compiler doesn't appreciate when I try to make it generic.
The problem with the second, is that I cannot figure out how to convert from a short[] to an int[] without copying to another array and converting it in the loop (.CopyTo), the arrays are massive, so every time I have to copy is a performance hit (it isn't exactly performance critical at the moment, but I'd like to avoid needless operations right now to save time later during optimization).
Any suggestions?
Thanks,
Phil
|
|
|
|
|
Use a generic function and then check the Type to make sure that it is a valid type - i.e. throw an exception if it's not a short[] or int[]. Hint - use the is operator.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi Pete,
I'm sure this idea would work (with a bit of effort), but I don't know if it will work for me.
Correct me if I'm wrong, but I'd still have to cast it to the appropriate type (short[] or int[]) and then carry around whichever version is the correct one along with flags signifying which to use (or copy it over to another short[] if it is an int[], which brings me to the 2nd problem presented in the original post). Adding an additional type - long, for instance, would require even more logic to be added all over the function to use the correct version. Furthermore, I'd like it to throw a compile time error and not a run-time exception.
|
|
|
|
|
All you need to do to support part of your problem is do something like:
public void Test<T>(IList<T> list)
{
if (list.Count > 0)
{
Console.WriteLine("Hello");
}
} Then, you can pass in short[] and int[] to your hearts content. It doesn't solve the constraining to short[] and int[] issues, but it does solve the other side (and you don't have to copy the arrays over).
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi Phil,
how about this:
- build one method DoIt() that accepts IArray as its main operand
- define an interface IArray similar to an array, supporting whatever Doit() needs
- define a class that implements IArray when given an int[]
- build a method that accepts an int[], instantiates said class and calls DoIt()
- define a class that implements IArray when given a short[]
- build a method that accepts a short[], instantiates said class and calls DoIt()
That's it, solved without generics. Would even run on 1.x
All this at the expense of a glue layer (the two classes described).
|
|
|
|
|
Yes, perfect! I only need an indexer, so the Interface would be nice and light.
Thanks again Luc!
|
|
|
|
|
Hello,
I'm developing an application for file processing. Basically I have a .txt file witch contains data from an AFM meassurement. The file itself contains the headers with information about the performed experiment and two segments built up by numbers, whitch are the actual experimental data. In order to be able to process the AFM data easier I want to divide the file in two parts, one part per header, and also remove the headers themselves.
I solved the problem by just copying the data connected to the first header in a new file and the data connected with the second header to another new file.
The problem is that the last line of each new copied file is not complete.
The last line of the original file is for example:
3.4327463E-6 1.8961255E-9 3.4336897E-6 2.8574045E-6 0.004730297 -0.020049555
The last line of my newly created file (witch is supposed to be an exact copy of the original line) is for example:
3.4327463E-6 1.89
A very large portion of the origninal information is lost.
I use an object of the StreamWriter Class to write the new file and an object of the StreamReader Class to read the original file. So I guess it's a problem with the StreamWriter.
Thank you for your help in advance.
|
|
|
|