Skip to content

Wait for webpage to completely load.

Joe Cook

Asked Nov 19, 2005, 11:58 AM EST1 answer
Share
LinkedInX
Hi:

     I am having problems getting a webpage to load before the next code is performed.
What I am trying to do is a screen capture of a webpage. I need to make sure the page is fully loaded before capturing the image. I am using axWebBrowser with the folling code:

Java
void Btn1Click(object sender, System.EventArgs e)

{
    axWebBrowser.Navigate(myURL);
    Graphics g1 = this.CreateGraphics();
    Image MyImage = new Bitmap(400, 185, g1);
    Graphics g2 = Graphics.FromImage(MyImage);
    IntPtr dc1 = g1.GetHdc();
    IntPtr dc2 = g2.GetHdc();

    // myGroupBox contains the axWebBrowser segment I wish to capture.

    int myLeft = myGroupBox.Left + 5;
    int myTop = myGroupBox.Top = 170;
    BitBlt(dc2,0,0, 400, 185, dc1, myLeft, myTop, 13369376);
   g1.ReleaseHdc(dc1);
   g2.ReleaseHdc(dc2);
}

[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]

private static extern bool BitBlt(

IntPtr hdcDest, // handle to destination DC

int nXDest, // x-coord of destination upper-left corner

int nYDest, // y-coord of destination upper-left corner

int nWidth, // width of destination rectangle

int nHeight, // height of destination rectangle

IntPtr hdcSrc, // handle to source DC

CSS
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);
   
    Any help would be greatly appreciated.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    you might want to add a handler to document_complete of your axWebBrowser, and call your bitblt from there.
    0