1
Answer

Wait for webpage to completely load.

Ask a question
Joe Cook

Joe Cook

18y
2.5k
1
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:

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

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.

Answers (1)