Getting the width of a webbrowser frame
-
Hello, I have a web browser control in my dialog and I want to resize the control to fit the html inside. First of all, is it actually possible to get the size of the document/top frame? There is only one frame in the document and I'm hoping to read it's height and width properties, but I've been trying to drill down to the Frame but I keep getting an error. I've checked a lot of the newsgroups and I think I'm going through the IE DOM correctly. I'd appreciate any help. Thanks, John IDispatch* spDispatch = NULL; IHTMLDocument* m_spDoc1 = NULL; IHTMLDocument2* m_spDoc2 = NULL; IHTMLFramesCollection2* m_pFrames = NULL; HRESULT hr = NULL; spDispatch = m_browser.GetDocument(); spDispatch ->QueryInterface (IID_IHTMLDocument, (void**)&m_spDoc1); m_spDoc1->QueryInterface(IID_IHTMLDocument2, (void**)&m_spDoc2); m_spDoc2->get_frames(&m_pFrames); //the following code was taken from an example //which iterates through the frames / but since my page has just one frame, frameCount returns 0 //and since it is zero based I'm presuming this is correct LONG framesCount; m_pFrames->get_length(&framesCount); for( long i=0; i <= framesCount; i++) { VARIANT varIdx; varIdx.vt=VT_UINT; VARIANT varResult; varIdx.lVal=i; VariantInit(&varResult); hr = m_pFrames ->item(&varIdx, &varResult); if (SUCCEEDED(hr)) // always fails here
-
Hello, I have a web browser control in my dialog and I want to resize the control to fit the html inside. First of all, is it actually possible to get the size of the document/top frame? There is only one frame in the document and I'm hoping to read it's height and width properties, but I've been trying to drill down to the Frame but I keep getting an error. I've checked a lot of the newsgroups and I think I'm going through the IE DOM correctly. I'd appreciate any help. Thanks, John IDispatch* spDispatch = NULL; IHTMLDocument* m_spDoc1 = NULL; IHTMLDocument2* m_spDoc2 = NULL; IHTMLFramesCollection2* m_pFrames = NULL; HRESULT hr = NULL; spDispatch = m_browser.GetDocument(); spDispatch ->QueryInterface (IID_IHTMLDocument, (void**)&m_spDoc1); m_spDoc1->QueryInterface(IID_IHTMLDocument2, (void**)&m_spDoc2); m_spDoc2->get_frames(&m_pFrames); //the following code was taken from an example //which iterates through the frames / but since my page has just one frame, frameCount returns 0 //and since it is zero based I'm presuming this is correct LONG framesCount; m_pFrames->get_length(&framesCount); for( long i=0; i <= framesCount; i++) { VARIANT varIdx; varIdx.vt=VT_UINT; VARIANT varResult; varIdx.lVal=i; VariantInit(&varResult); hr = m_pFrames ->item(&varIdx, &varResult); if (SUCCEEDED(hr)) // always fails here