Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart26-Aug-04 14:06
protectorHeath Stewart26-Aug-04 14:06 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle26-Aug-04 14:17
kayhustle26-Aug-04 14:17 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart26-Aug-04 14:20
protectorHeath Stewart26-Aug-04 14:20 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle26-Aug-04 15:23
kayhustle26-Aug-04 15:23 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart27-Aug-04 8:56
protectorHeath Stewart27-Aug-04 8:56 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle27-Aug-04 10:21
kayhustle27-Aug-04 10:21 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart27-Aug-04 10:25
protectorHeath Stewart27-Aug-04 10:25 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle27-Aug-04 11:44
kayhustle27-Aug-04 11:44 
Interesting, I've definitely learned a lot. I was able to make the cast and pass in the user agent. However, it still sends the 400 bad request exception. What I found though, which is strange is that I can navigate to the image using the webbrowser control using the same or even a different Web Browser Control.
Once the browser has navigated I can call this getimage() function, which grabs the picture indirectly from the graphics card buffer. The downside to this is that the browser has to be in focus of course. I still don't get why it would send a bad request to the HttpWebRequest and not to a browser object, but I'm still glad that I can at least grab the picture indirectly.
Thanks,

<code>
private void getimage()
{
Control c = this.axWebBrowser1 as Control;
Bitmap bmp = CaptureControl(c);
bmp.Save("codeword.jpeg",ImageFormat.Jpeg);
}

[System.Runtime.InteropServices.DllImport("gdi32.dll")] private static extern bool BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop);
		public static Bitmap CaptureControl(System.Windows.Forms.Control control)
		{
			Graphics g1 = control.CreateGraphics();
			Bitmap bitmap = new Bitmap(control.ClientRectangle.Width, control.ClientRectangle.Height, g1);
			Graphics g2 = Graphics.FromImage(bitmap);
			IntPtr dc1 = g1.GetHdc();
			try
			{
				IntPtr dc2 = g2.GetHdc();
				try
				{
					BitBlt(dc2, 0, 0, control.ClientRectangle.Width, control.ClientRectangle.Height, dc1, 0, 0, 13369376);
				}
				finally
				{
					g2.ReleaseHdc(dc2);
				}
			}
			finally
			{
				g1.ReleaseHdc(dc1);
			}
			return bitmap;
		}</code> 

GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart27-Aug-04 11:57
protectorHeath Stewart27-Aug-04 11:57 
QuestionQ. How do you start 2 or more other classes to threading from a single Form1?? Pin
gman4426-Aug-04 12:57
gman4426-Aug-04 12:57 
AnswerRe: Q. How do you start 2 or more other classes to threading from a single Form1?? Pin
kayhustle26-Aug-04 13:25
kayhustle26-Aug-04 13:25 
AnswerRe: Q. How do you start 2 or more other classes to threading from a single Form1?? Pin
LongRange.Shooter27-Aug-04 10:15
LongRange.Shooter27-Aug-04 10:15 
GeneralLooking for someone who is familiar with iTextSharp library (PDF files creating) Pin
Member 103390726-Aug-04 12:13
Member 103390726-Aug-04 12:13 
GeneralRe: Looking for someone who is familiar with iTextSharp library (PDF files creating) Pin
Heath Stewart26-Aug-04 13:38
protectorHeath Stewart26-Aug-04 13:38 
GeneralRe: Looking for someone who is familiar with iTextSharp library (PDF files creating) Pin
Member 103390727-Aug-04 10:51
Member 103390727-Aug-04 10:51 
Generalreading NTFS Master File Table Pin
redjoy26-Aug-04 11:58
redjoy26-Aug-04 11:58 
GeneralRe: reading NTFS Master File Table Pin
Anonymous26-Aug-04 12:49
Anonymous26-Aug-04 12:49 
Generaladding an item to a listview Pin
yitzstokes26-Aug-04 10:05
yitzstokes26-Aug-04 10:05 
GeneralRe: adding an item to a listview Pin
Nick Parker26-Aug-04 11:46
protectorNick Parker26-Aug-04 11:46 
GeneralWhen is Archer's Inside C# 3rd edition slated for publishing Pin
Joe Woodbury26-Aug-04 10:04
professionalJoe Woodbury26-Aug-04 10:04 
GeneralRe: When is Archer's Inside C# 3rd edition slated for publishing Pin
Jon Sagara26-Aug-04 14:57
Jon Sagara26-Aug-04 14:57 
General.Net applications in Linux Pin
vadim_3k26-Aug-04 9:21
sussvadim_3k26-Aug-04 9:21 
GeneralRe: .Net applications in Linux Pin
leppie26-Aug-04 9:30
leppie26-Aug-04 9:30 
GeneralRe: .Net applications in Linux Pin
Judah Gabriel Himango26-Aug-04 9:34
sponsorJudah Gabriel Himango26-Aug-04 9:34 
GeneralRe: .Net applications in Linux Pin
Heath Stewart26-Aug-04 10:36
protectorHeath Stewart26-Aug-04 10:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.