Solved

Changing a frame size with IHTMLFrameSetElement

Posted on 2001-09-07
2
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

695 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