Below is I added the ChromiumWebBrowser CefSharp components, in actual operation of form is I show that this control, but I don't intercept the form of diagram shows the browser controls, I changed some of its background color, border lines can be displayed, do not know why, please help have a look at the great god, the question has bothered me for a long time QWQ
In fact, I demand is separate browser intercept screenshots, initially intercept down browser screen is blank, can't find the problem just had the following test
Interception of the form:
Actual running form:
Code:
Private static ChromiumWebBrowser browser=new ChromiumWebBrowser (" http://www.baidu.com "); Private void Form2_Load (object sender, EventArgs e) { The FrameLoadEnd +=new EventHandler<frameLoadEndEventArgs> (browser_FrameLoadEnd); The Visible=true; The Dock=DockStyle. The Fill; GroupBox1. Controls. The Add (browser); } Private void browser_FrameLoadEnd (object obj, EventArgs e) { Int width=this. Width; Int height=this. Height; Bitmap Bitmap=new Bitmap (width, height);//create a canvas size A Rectangle Rectangle=new Rectangle (0, 0, width, height);//painting area The DrawToBitmap (bitmap, rectangle); Bitmap. The Save (" D: \ \ test. JPG ", System. Drawing. The Imaging. ImageFormat. Jpeg); } CodePudding user response:
Where a great god QWQ
CodePudding user response:
Such a big BBS didn't understand
CodePudding user response:
GG...
CodePudding user response:
Private void button1_Click (object sender, EventArgs e)
{
Graphics g=this. CreateGraphics ();
The Size s=this. Size;
Bitmap image=new Bitmap (s. idth and Sheldon horowitz eight, g);
Graphics g2=Graphics. FromImage (image);
G2. CopyFromScreen (enclosing the Location X, enclosing the Location. The Y, 0, 0, s);
G2. DrawImage (image, 0, 0).
Image. The Save (a. "pg");
}
CodePudding user response:
The
reference 4 floor myheadachecase reply: private void button1_Click (object sender, EventArgs e) { Graphics g=this. CreateGraphics (); The Size s=this. Size; Bitmap image=new Bitmap (s. idth and Sheldon horowitz eight, g); Graphics g2=Graphics. FromImage (image); G2. CopyFromScreen (enclosing the Location X, enclosing the Location. The Y, 0, 0, s); G2. DrawImage (image, 0, 0). Image. The Save (a. "pg"); } I need to control in the case of invisible web page for screenshots, this implementation CodePudding user response:
reference 5 floor qq_36434521 reply: I need to control in the case of invisible web page for screenshots, this implementation of Ok, out after notification, CodePudding user response:
Try the Visible=true mentioned in front, other screenshots method is to use a click event debugging is better CodePudding user response:
To be honest, cefsharp is not allow you to capture, cut yarn, CodePudding user response:
reference 5 floor qq_36434521 reply: Quote: refer to 4th floor myheadachecase response: Private void button1_Click (object sender, EventArgs e) { Graphics g=this. CreateGraphics (); The Size s=this. Size; Bitmap image=new Bitmap (s. idth and Sheldon horowitz eight, g); Graphics g2=Graphics. FromImage (image); G2. CopyFromScreen (enclosing the Location X, enclosing the Location. The Y, 0, 0, s); G2. DrawImage (image, 0, 0). Image. The Save (a. "pg"); } I need to control in the case of invisible web page for screenshots, this implementation of Failed to understand, control is not visible? The control is not visible? Is a browser control is not visible? Invisible how screenshot? CodePudding user response:
Turn the webBrowser picture The class NativeMethods { [ComImport] [Guid (" 0000010 - d - 0000-0000 - C000-000000000046 ")] [InterfaceType (ComInterfaceType. InterfaceIsIUnknown)] Interface IViewObject { Void the Draw ([MarshalAs (UnmanagedType. U4)] uint dwAspect, int lindex, IntPtr pvAspect, [In] IntPtr PTD, IntPtr hdcTargetDev, IntPtr hdcDraw, [MarshalAs (UnmanagedType. Struct)] ref the RECT lprcBounds, [In] IntPtr lprcWBounds, IntPtr pfnContinue, [MarshalAs (UnmanagedType. U4)] uint dwContinue); } [StructLayout (LayoutKind. Sequential, Pack=4)] Struct the RECT { Public int Left; Public int Top; Public int Right; Public int Bottom; } Public static void GetImage (object obj, Image destination, Color backgroundColor) { Using (Graphics Graphics=Graphics. FromImage (destination)) { IntPtr deviceContextHandle=IntPtr. Zero; The RECT rectangle=new the RECT (); A rectangle. Right=destination. Width; A rectangle. The Bottom=destination. Height; Graphics. Clear (backgroundColor); Try { DeviceContextHandle=graphics. GetHdc (); IViewObject viewObject=obj as IViewObject; ViewObject. The Draw (1, 1, IntPtr. Zero, IntPtr. Zero, IntPtr. Zero, deviceContextHandle, ref rectangle, IntPtr. Zero, IntPtr. Zero, 0). } The finally { If (deviceContextHandle!=IntPtr. Zero) { Graphics. ReleaseHdc (deviceContextHandle); } } nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull