Solved

Changing a frame size with IHTMLFrameSetElement

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 66
centeredAverage challenge 8 186
zeroMAx challenge 20 126
c++  placing data into a form and an editbox 5 24
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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