Solved

Changing a frame size with IHTMLFrameSetElement

Posted on 2001-09-07
2
263 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

943 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

4 Experts available now in Live!

Get 1:1 Help Now