?
Solved

Changing a frame size with IHTMLFrameSetElement

Posted on 2001-09-07
2
Medium Priority
?
278 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 600 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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: 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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 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