المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to show file association icon,one button and a progress bar on webbrowser control c#



C# Programming
01-02-2013, 04:33 AM
i work with webbrowser for showing simple text. i am in situation where i want that when user drag any file on webbrowser control then i want to show a icon for that file and one progressbar and one button programmatically. i manage to show file associated icon ob richtextbox just like using System.Drawing.Icon.ExtractAssociatedIcon(string filePath)
here is the code for handling file drag drop on richtextbox like below one

public Form1() { InitializeComponent(); richTextBox1.AllowDrop = true; //richTextBox1.EnableAutoDragDrop = true; this.richTextBox1.DragEnter += new DragEventHandler(richTextBox1_DragEnter); this.richTextBox1.DragDrop += new DragEventHandler(richTextBox1_DragDrop); } void richTextBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if ((e.Data.GetDataPresent(DataFormats.FileDrop))) { e.Effect = DragDropEffects.Copy; } } void richTextBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //Image img = default(Image); //img = Image.FromFile(((Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString()); //Clipboard.SetImage(img); //this.richTextBox1.SelectionStart = 0; //richTextBox1.AppendText("Hello"); //this.richTextBox1.Paste(); /* Dim img As Image = Image.FromFile(fname) Clipboard.SetImage(img) RichTextBox1.Paste() */ string strFilePath = ((Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); Icon oIcon= System.Drawing.Icon.ExtractAssociatedIcon(strFilePath); Bitmap myBitmap = new Bitmap(oIcon.ToBitmap()); Clipboard.SetDataObject(myBitmap); DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap); richTextBox1.Text = ""; if (richTextBox1.CanPaste(myFormat)) { richTextBox1.Paste(myFormat); richTextBox1.AppendText(" " + System.IO.Path.GetFileName(strFilePath)); } else { MessageBox.Show("The data format that you attempted site" + " is not supportedby this control."); } }
here is one image link for your visualization purpose http://i.stack.imgur.com/5oRkt.png
i want to accomplish the same thing for webbrowser control for handing file drag drop and want to show one file associated icon and one progressbar and one button. please guide me with sample code for doing with webbrowser control. thanks
tbhattacharjee