|
Hi.
Im trying to make an automated gallery browser that can scroll through web pages and download all the images off them. It is currently working, using a webBrowser control. I have a list of all the images on the page in a listbox on the side, each with a thumbnail preview image. However, i am on dial up (laugh and get it out of the way), and the way the application currently works is to download the url to the browser, extract the img tags from the source code, and download each image as a bitmap. This takes ages as it has to download each image twice, once in the web browser and once from the url of the image.
I am wondering if there is anyway to extract the images from the webBrowser control so i dont have to download them twice?
I have played around with the webBrowser.DocumentStream, but cant work out how to get the images.
Any help appreciated.
-- modified at 18:23 Sunday 25th November, 2007
|
|
|
|
|
Just an idea, not sure it will work, not sure you will like it:
tell Internet Explorer to not show images (uncheck Tools/Internet Options/Advanced/Multimedia/
Show Pictures). That way the browser should not follow the IMG tags automatically.
I reckon you'd better forget about the browser control, and do HTTP calls yourself,
using the System.Web namespace.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
The browser control is embedded in a form, its not using internet explorer.
Guess i will have to start doing some research into the HTTP Requests.
I knew taking the easy way would catch up with me in the end
Is there anything good to be said about using the AxSHDocVw.AxWebBrowser, or is it similar to the Windows.Forms.WebBrowser?
|
|
|
|
|
Did you try what I suggested?
AFAIK WebBrowser uses the settings set in IE.
I expect WebBrowser and AxSHDocVw to be very similar.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Using HttpWebRequest is actually pretty easy, in around 8 lines or something like that, you will have a stream or similar of the html code for the page, which you can then just search for the img tags. I'll just go grab some code...
using System.Net;
...
HttpWebRequest Pie = (HttpWebRequest)WebRequest.Create("http://www.pie.com");
HttpWebResponse response = (HttpWebResponse)Pie.GetResponse();
Stream pieStream = response.GetResponseStream();
SR = new StreamReader(pieStream, true); 8 lines, 4 lines, its the same thing!
Anyways, then you can just read the text using the stream reader.
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
Thanks for the pointer Luc.
The Undefeated: Code snippet helped a lot
I have the stream of the web page. Does that contain the images in the page as well?
I am using a webBrowser control to experiment. I have set it to give me a message whenever the FileDownload event occurs, and am getting differing numbers of messages per page, as expected. However i cant work out what files the FileDownload event is occurring for.
Is there any way i can extract the the images on a page from the webpage stream or am i on the wrong track?
|
|
|
|
|
Hi There,
Can anyone tell me how to get the color of a string?
E.g.: I am passing a string to a function. The function needs to return the color of that string.
public Color GetColor(string);
I am extracting this string from a RichTextBox line.
Thanks in advance.
-----------------------------------------------
"Don't crib about your job. Only 1% are doing something meaningful and I have never seen any of them."
|
|
|
|
|
Hi,
a string has no color, it only holds characters.
an RTB can show a string with extra attributes such as font style, color, e.a.
You can get or set the color of some text INSIDE an RTB using RichTextBox.SelectionColor().
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
thanks a ton!!!
|
|
|
|
|
Hi all,
I am working on C# project using C# 2.0. I have a DataGrid that contains 10 rows and at runtime I insert one more row at DataGridView.Insert(0,1); in my next step, I want to delete the row from DataGridView at DataGridView.RemoveAt(9) // Index 9 is the last row in the grid. But, I am not able to delete the row. I am getting following exception: System.InvalidOperationException:Uncommitted new row cannot be deleted. at System.Windows.Forms.DataGridViewRowCollection.RemoveAt(Int32 index)
Please help if you know the solution.
Thanks in advance for your help.
A.Asif
|
|
|
|
|
The easy way to delete the row of the data gird is to get reference of the current row. Note: I assume that Grid is bound to a BindingSource names "bindingSource". Put the following code inside the event of Delete button.
DataRowView DRV = bindingSource.Current;<br />
if(DRV!=null)
DRV.Delete();<br />
Regards
|
|
|
|
|
1st of all, let me tell you that I am new to Windows (Desktop) Applications. I am basically ASP.NET developer and have worked much in this field. Now I am trying to work on windows applications and facing lot of challenges. One of which is described below.
IF YOU HAVE NOT ENOUGH TIME TO READ THIS ALL, JUST GO TO THE END AND READ MY QUESTIONS IN A FEW LINES. This may not clear, why I need this.
Goal
-----
Create the window for data input. On Ok, record should be entered in data set On Cancel, record should be discarded. User can enter as many records as required and also can update some existing records. By navigating to each records, user can cancel the changes of each record. To commit the changes, user have to click Save button. To reject the changes, user have to reload all data.
Design
-------
I am working on C# project. I've created the Typed data set. Windows form is populated with required controls (Text Box, Check Box only for my current window), one Binding Source control bound to the table of Data Set (Which automatically created Table Adapter for me. I've bound the form controls (Text Boxes) to the Binding Source's properties (Automatically created by designer). I've also created navigation controls manually.
Run time behavior
------------------
Some records already exist in the database, so when Application is run, records are automatically displayed in the controls(by fact they are bound). Navigation controls(Next,Previous,First & Last including the record position and total records) are working properly and displayed contents are changed properly.
Problems
---------
1. How I can add new record?
Binding Source's Add method requires parameter as object to be inserted. What object I can pass? and how to get / construct that object?
Binding Source's AddNew() method is working (NOTE: I am calling AddNew method of the BindingSource in a method, where I initialize all the controls(texboxes) of the form(record) to initial values. TextBoxes are also assigned Empty string). Record pointer & navigation controls are updated. At this level, It seems everything is ok. When Add New button is clicked (To add an other new record) exception is thrown saying [columnname] do not allow null value.
To overcome this, I changed the way to enter the new record. Now I enter the new row directly to the DataTable in the dataset, rather than adding to the Binding Source by calling its AddNew() method. After adding I change the position of the Binding source to the last record of the data table. The problem with this is, the row is already entered by bypassing some business rules (validations).
How I can cancel the changes of each record ?
-----------------------------------------------
On the cancel, I am checking the row state of the displayed record (current record). If its new (Added), i am simply deleting the record. This is working.
When I navigate to the existing record, and I change some values in text boxes, and then try to Cancel the changes. Nothing is changed? (old values are not shown in controls). I put the condition to check, On Cancel click, if current record's row sate is Modified, I am calling CancelEdit() method of the Binding source (Same buttons Added state is handled correctly as i mentioned above). While debugging, I encountered that some times row sate is shown Detached and some times Modified. I put both conditions with OR (||) operator, surely CancelEdit() method is called but still control is displaying new values (means changes are not reverted at control level). I tried to call EndEdit() method of current row, Before and after CancelEdit, but still no luck.
One more thing, on FormClosing event of the window, i am checking if any changes were made to the records and ask from the user Yes=Save,No=Discard,Cancel=Dont close the window. After editing a text box and trying to close the window, doesn't display the dialog box to ask. Why changes were not made to the Table in Dataset?
Let me confess that, while working on this, I canceled the new added rows, which I mentioned above that its working fine. I didn't try to save new added rows. so I don't know while saving, it'll throw any exception or not.
phewwwwwww!!!!
Summary of the problem and help needed
----------------------------------------
Is there easy way to add/update records with cancel (changes) functionality in Windows forms? Note that there are many fields/columns, so Its not preferred to use Data Grid.
How to cancel changes of the updated record by using Binding Source ?
Am I going to wrong direction ?
Regards
|
|
|
|
|
i have to fill SQl 2000 tables from window forms the problem is when filling the 1st table i load the database table in a datset in the form load event now when filling the second table what will be the possible event to fire that it load the second table in the datset
sas
|
|
|
|
|
I think its not clear what you exactly need. I am sorry at least for me, its not clear. Would you like to explain please ?
|
|
|
|
|
sir the problem is i am working on a HR database u have worked on web forms the application consists of 4 forms every form is associated with two tables in sql2000 the question is that when the user open the application in the form load event i kept the dataset filling method for the first table now when user switch on to the next table what will be the event to load the second datatable in the datset
sas
|
|
|
|
|
well sorry to say dear Sajid, you've failed to describe your problem. HOW?
1st of all, you are talking about the FORMS of the application, on other hand you are talking about switching to next TABLE
I think there is no any TABLE control in C#.NET.
If you are talking about FORMS, talk about the controls on the form.
So now I am asking, as you said, every form is associated with two tables, How these 2 tables you are displaying on the form? i mean which controls you are using to display the data of the Table ?
This way we can know and figure out what events are available for that control. NOT THE TABLE..
I hope now you understand what I mean to clearify
Regards
|
|
|
|
|
hi.
I am writing a program with c# and sql as database.
i have a MDIform as startup form which one of my form(frmMain) opens with it.
in frmMain i have a combobox which is filled with data from CityTable. it means that I used Value Member and Display Member to fill it.
when I press the button "Add City" on MDIform another form opens and i can add a new city.
the frmMain still is open.
my problem is here how can I update city Combo box in frmMain?
please help me.
i have asked from a few persons and they gave 2 solutions :
1-raise an event
2-open City From using showDialog()
now please tell which one to choose and how?
|
|
|
|
|
As per my knowledge, Do this.
Make the data source(Table containing the Cities) of Combobox, publicly accessible by declaring in the mainForm a static propertly which return the data table of cities.
In the dialog box, where you add new record, access the data table of mainForm and add city in it. It'll automatically shown in combo box because its already bound to that table.
Regards
|
|
|
|
|
thanx for answer
appreciate
|
|
|
|
|
Since C# 3.0 natively supports LINQ in the language wouldn't that make the ADO.NET stuff part of the CLR and BCL?
|
|
|
|
|
Why would LINQ change ADO.NET ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi there,
I have a stored procedure written on a RichTextBox. On the click of a button, this stored procedure should be executed and errors, if any, should be displayed in a messagebox.
Thanks in advance!
|
|
|
|
|
Hi!
You can access the text in the RTB via its Text property (I can't see what else this has to do with the topic).
To execute a SP with a given name you can use classes from the System.Data.* namespace, depending on the RDBMS you want to use, for example the SqlCommand class.
There's a ton of samples for this on MSDN for example, try googling for it if you still have troubles.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks mav,
Currently I am using this option. The problem is that SqlCommand class can handle only one SQL command at time. What I need is to send an entire SP, execute it and after the whole SP is executed in "one go";
1. If successful, a message box saying "Successful Execution" should be displayed; else,
2. Whatever exception has been returned, that needs to be displayed.
|
|
|
|
|
You can't "send an entire SP". A SP is something stored within the DB (hence the name). You _could_ execute an SQL command containing something like "CREATE PROCEDURE ..." to create a SP on-the-fly, but I think that's not a good solution.
If you have several queries you have to execute together, then the SP should be available in the DB, not be created everytime, IMO.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|