Solved

Changing a frame size with IHTMLFrameSetElement

Posted on 2001-09-07
2
262 Views
Last Modified: 2013-11-20
I'm working with a CWebBrowser2 object and am currently using interface pointers to manipulate and create items on a web page.  I need to change the size of a frame in a frameset and the IHTMLFrameSetElement seems capable to doing this, but I can't figure out a way to get an interface pointer to an IHTMLFrameSetElement.

Any help would be much appreciated. Thanks.
0
Comment
Question by:Taz
2 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 150 total points
ID: 6472872
Working with these COM interfaces in C++ is the most frustrating task on earth.  The Driller Sample:
  http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/browser/driller/Default.asp

shows the techniques.

In the code below, I change the FRAMESET COLS= setting of the currently-loaded page from "25%,50%,25%" to "25%,25%.50%"  Lookup IHTMLFrameSetElement in MDSN for other things you can do with a frameset.


#include <Mshtml.h>
//-----------------------------
// find the first of a specified element type
//
IDispatch* FindElement( REFIID riid, IDispatch* pDispBrowser )
{
    HRESULT hr;
     IHTMLDocument2* pHTMLDocument2;

     hr= pDispBrowser->QueryInterface( IID_IHTMLDocument2, (void**)&pHTMLDocument2 );
    if (hr != S_OK) return 0;

     IHTMLElementCollection* pColl;
     hr= pHTMLDocument2->get_all( &pColl );
    if (hr != S_OK) return 0;

     LONG celem;
     hr = pColl->get_length( &celem );
    if (hr != S_OK) return 0;

    for ( int i=0; i< celem; i++ ) {
          COleVariant varIndex( (long)i );
          COleVariant var2;
          IDispatch* pDisp;

          hr = pColl->item( varIndex, var2, &pDisp );
        if ( hr != S_OK ) {
            return 0;
        }
          IHTMLElement* pElem;
        //---------- see if this one is of the requested type...
          hr = pDisp->QueryInterface( riid, (void **)&pElem );
        if ( hr == S_OK ) {   // YES!
            pDisp->Release();
             return( pElem );
        }
        pDisp->Release();
    }
    return(0);
}

void CD10WebDlg::OnButton1()
{
    CWebBrowser2* pBrowser= (CWebBrowser2*)GetDlgItem( IDC_EXPLORER1 );

     IHTMLFrameSetElement* pFrameSetElem= (IHTMLFrameSetElement*)FindElement(
        IID_IHTMLFrameSetElement, pBrowser->GetDocument()
    );
    if ( pFrameSetElem == NULL ) {
        return; // no FRAMESET elements in the document
    }
    BSTR bstr;
    pFrameSetElem->get_cols( &bstr );
    CString s= bstr; //------------- so you can eyball the current value

    bstr= L"25%,25%,50%";
    pFrameSetElem->put_cols( bstr );  // set it to a new value
    pFrameSetElem->Release();
}


-- Dan
0
 

Author Comment

by:Taz
ID: 6476882
Thanks!  This is exactly what I needed.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 87
notReplace  challenge 53 102
no14 challenge 14 57
haveThree challenge 22 100
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now