Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Thu, 20 Mar 2008 03:02:33 -0700 (PDT),    group: microsoft.public.inetsdk.programming.webbrowser_ctl        back       


Changing drop-down menu Dynamically (IE Toolbar button)   
Sub:Changing drop-down menu  Dynamically (IE Toolbar button)

Hi,
We are developing a IE extension . The extension adds a toolbar button
to IE and gives a drop down menu./ menu button pls seee image :
http://img209.imageshack.us/my.php?image=iemenubutton1vt0.jpg

Q1:Is thr anyway to dynamically change the contents of Drop down menu
(of the Menubutton )??this seems to be main trouble!

here are some problems and issues we are facing,pls need help on this
since i'm new to IE extensions/BHO.
(we are using com/atl/c++ to implement the extension..but any
technology will do i guess  C# .NET)


1] When the user selects an item from the drop down (frm the extension
to be more specific) ,
  the user is directed to our site for login.Before login the drop
down shown to user is different
(say DropDown 'A' with 3 options)

2] Now when the user is logged in,we want him to see more options in
dropdown
(ie.Somehow adding more options to dropdown list) .Is it possible?Is
it possible to toggle options in it?

3] Also is there a way to inject/insert scriplets like 'div' and
'script' tag elements into DOM through COM/C++/ATL  dynamically?

4] Also can IE extensions/BHO  read/write cookies ?(we need to know
whether user has logged in to site etc)

Please reply .
 Any help is welcomed.

Regards and Thanks.
Amit Dhamal
date: Thu, 20 Mar 2008 03:02:33 -0700 (PDT)   author:   unknown

Re: Changing drop-down menu Dynamically (IE Toolbar button)   
wrote in message
news:2281946e-5ce4-4f09-8b48-243cca4df200@e6g2000prf.googlegroups.com
> We are developing a IE extension . The extension adds a toolbar button
> to IE and gives a drop down menu./ menu button pls seee image :
> http://img209.imageshack.us/my.php?image=iemenubutton1vt0.jpg
>
> Q1:Is thr anyway to dynamically change the contents of Drop down menu
> (of the Menubutton )??this seems to be main trouble!

How did you put the menu there in the first place? You should be able to 
use the same technique to modify it.

> 3] Also is there a way to inject/insert scriplets like 'div' and
> 'script' tag elements into DOM through COM/C++/ATL  dynamically?

You can definitely insert <div> and any other elements. I'm not sure 
about <script>: I mean, you can of course insert the element, but I seem 
to recall that the script inside doesn't actually run, so it's rather 
pointless.

> 4] Also can IE extensions/BHO  read/write cookies ?(we need to know
> whether user has logged in to site etc)

See InternetGetCookie[Ex], InternetSetCookie[Ex]
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Thu, 20 Mar 2008 08:34:40 -0400   author:   Igor Tandetnik

Re: Changing drop-down menu Dynamically (IE Toolbar button)   
thx sir :)

1] About Menu:
The menu was created inside a DLL (using COM code).
But at runtime is it possible to change DLL or something similar.does
it require browser restart??
The menu was hardcoded in DLL so whenever the extension/DLL is loaded
by IE the MenuButton appears in the IE toolbar.
http://img209.imageshack.us/my.php?image=iemenubutton1vt0.jpg
so how to dynamically change that?

2]About Script injection:
suppose if  an  element is dynamically created as <script
src="www.xyz.com/jsfilename.js">
or <img src=""www.xyz.com/jsfilename.js">
or an hidden iframe?
will it work??

thx for reply :)
date: Thu, 20 Mar 2008 06:04:16 -0700 (PDT)   author:   unknown

Re: Changing drop-down menu Dynamically (IE Toolbar button)   
wrote in message
news:935078eb-66a6-4910-a879-48e7afcc1987@u10g2000prn.googlegroups.com
> 1] About Menu:
> The menu was created inside a DLL (using COM code).

So I guess similar code could modify it.

> But at runtime is it possible to change DLL or something similar

What do you mean, change DLL? Why would you want to? Just write code in 
the DLL you already have that modifies the menu, similar to code that 
created it in the first place.

> The menu was hardcoded in DLL so whenever the extension/DLL is loaded
> by IE the MenuButton appears in the IE toolbar.

Having a button with a drop-down menu is not possible using standard IE 
extension mechanisms. There must be some specific code in your DLL that 
creates this menu. Find it, study it, figure out how it works. Then it 
should be obvious how to modify this menu on the fly.

See also InsertMenuItem, SetMenuItemInfo, DeleteMenu

> 2]About Script injection:
> suppose if  an  element is dynamically created as <script
> src="www.xyz.com/jsfilename.js">
> or <img src=""www.xyz.com/jsfilename.js">
> or an hidden iframe?
> will it work??

I'm not sure. Try it.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Thu, 20 Mar 2008 09:23:00 -0400   author:   Igor Tandetnik

Re: Changing drop-down menu Dynamically (IE Toolbar button)   
thx for reply :D

sorry for dumb questions ..
i got the code from
http://www.codeproject.com/KB/shell/IEMenuButton.aspx
and used that code.This code creates a similar effect with pop-ups.
i was trying to create button similar to Mail button in toolbar in IE6
http://img137.imageshack.us/my.php?image=mailmenusp2.jpg

is there directly a way to do this kind of button i searched but
didn't find much,
http://img137.imageshack.us/img137/4822/mailmenusp2.jpg
Also need to dynamically change the menu items.

2)about the code injection,it is similar to XSS or CSRF attacks.i
guess some other
idea needs to be found out.

also can XMLHTTPREQUEST (XHR) request be made from within Extension?
the idea was to check user login with cookies but changing to XHR .
i needed script injection for that purpose.
instead of injecting a script and making a XHR ,now have to make XHR
from
extension and check with the server for login.

thx
amitd
date: Thu, 20 Mar 2008 17:09:00 -0700 (PDT)   author:   unknown

Re: Changing drop-down menu Dynamically (IE Toolbar button)   
wrote in message
news:2d341faf-d68b-4da7-ad09-19992d141aa3@s19g2000prg.googlegroups.com
> sorry for dumb questions ..
> i got the code from
> http://www.codeproject.com/KB/shell/IEMenuButton.aspx
> and used that code.This code creates a similar effect with pop-ups.
> i was trying to create button similar to Mail button in toolbar in IE6
> http://img137.imageshack.us/my.php?image=mailmenusp2.jpg
>
> is there directly a way to do this kind of button

No. You need the code shown in the article, or substantially similar, to 
do that.

> Also need to dynamically change the menu items.

In step 5 in the article, the menu is shown with TrackPopupMenu. Instead 
of loading the menu from resources, you can create it programmatically. 
See CreatePopupMenu, InsertMenuItem

> also can XMLHTTPREQUEST (XHR) request be made from within Extension?

Yes.

> the idea was to check user login with cookies

So what stopped you from doing that?
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Thu, 20 Mar 2008 22:01:52 -0400   author:   Igor Tandetnik

using createElement and appendChlid function   
thx for help.
some more help needed.
i have to insert html elements or tags like <div> in the currently
loaded page of the browser.
so i tried to use createElement and appendChlid function:
i have the following code:**but it has errors**..
                            {
                            CComPtr<IDispatch> pDisp;
                            HRESULT hr = m_pWebBrowser2-
>get_Document(&pDisp);
                            CComQIPtr<IHTMLDocument2,
&IID_IHTMLDocument2> spHTML;
                            CComPtr<IHTMLElement>  m_pNewElem = NULL;
                            spHTML = pDisp;
                            hr = 0;
                            BSTR bstrDiv = ::SysAllocString(L" DIV
id='myDiv' ");
                            hr = spHTML->createElement(bstrDiv,
&m_pNewElem);
                            BSTR bstrVal=::SysAllocString(L"Created
using the createElement method");
                            m_pNewElem->put_innerHTML(bstrVal);

                            IHTMLDOMNode* pDiv;
                            hr = m_pNewElem-
>QueryInterface(IID_IHTMLDivElement, (void**)&pDiv);
                            ::SysFreeString(bstrVal);
                            ::SysFreeString(bstrDiv);

                            IHTMLDOMNode* theBody;
                            hr = m_pNewElem-
>QueryInterface(IID_IHTMLDOMNode, (void**)&theBody);
                            IHTMLDOMNode* theDiv;
                            hr=theBody->appendChild(pDiv, &theDiv);//
Error here ..IE crashes
                            pDiv->Release();
                            return S_OK;
                           }
the code tries to create an  <div> and tries to append it.
but i don't know how to get append the newly created element <div>
inside the DOM..it gives error.?dunno why?can it be resolved ?
and also suppose if i want to append the "div" element to a specific
element say "<head>" or "<body>"  then how to do that?


I have code which can retrieve already created <div> element which is
hardcoded.
if HTML is like ::>  <html><body><div id="myDiv"> hiiiii AMITD </div></
body></html>
then using following code we can retrieve the contents of element with
ID = myDiv
                               {
                                CComPtr<IHTMLElement> m_pBody;
                                HRESULT hr;
                                hr = spHTML->get_body(&m_pBody);
                                hr = spHTML3-
>getElementById(L"myDiv",&newHtml);
                                BSTR temp;
                                newHtml-
>get_innerHTML(&temp);
                               //work with string temp here..
                                newHtml->put_innerHTML(temp);
                                MessageBox(NULL,temp,L"AMIT",MB_OK);
                              }

i need to create the myDiv dynamically in extension and append to some
element say 'X' in the DOM...?

regards.
amitd
date: Mon, 24 Mar 2008 05:18:32 -0700 (PDT)   author:   unknown

using createElement and appendChild   
thx for help.
some more help needed.
i have to insert html elements or tags like <div> in the currently
loaded page of the browser.
so i tried to use createElement and appendChlid function:

i have the following code:**but it has errors**..

 {
CComPtr<IDispatch> pDisp;
HRESULT hr = m_pWebBrowser2->get_Document(&pDisp);

CComQIPtr<IHTMLDocument2,&IID_IHTMLDocument2> spHTML;
CComPtr<IHTMLElement>  m_pNewElem = NULL;
spHTML = pDisp;
hr = 0;
BSTR bstrDiv = ::SysAllocString(L" DIV id='myDiv' ");
hr = spHTML->createElement(bstrDiv,&m_pNewElem);
BSTR bstrVal=::SysAllocString(L"Created using the createElement
method");
m_pNewElem->put_innerHTML(bstrVal);

IHTMLDOMNode* pDiv;
hr = m_pNewElem->QueryInterface(IID_IHTMLDivElement, (void**)&pDiv);
::SysFreeString(bstrVal);
::SysFreeString(bstrDiv);

IHTMLDOMNode* theBody;
hr = m_pNewElem->QueryInterface(IID_IHTMLDOMNode, (void**)&theBody);

IHTMLDOMNode* theDiv;
hr=theBody->appendChild(pDiv, &theDiv);//Error here ..IE crashes
pDiv->Release();
return S_OK;

 }

the code tries to create an  <div> and tries to append it.
but i don't know how to append the newly created element <div>
inside the DOM..it gives error.?dunno why?can it be resolved ?
and also suppose if i want to append the "div" element to a specific
element say "<head>" or "<body>"  then how to do that?

I have code which can retrieve already created <div> element which is
hardcoded.
if HTML is like ::>
<html><body><div id="myDiv"> hiiiii AMITD </div></body></html>
then using following code we can retrieve the contents of element with
ID = myDiv

 {
CComPtr<IHTMLElement> m_pBody;
HRESULT hr;
hr = spHTML->get_body(&m_pBody);
hr = spHTML3->getElementById(L"myDiv",&newHtml);

BSTR temp;
newHtml->get_innerHTML(&temp);

 //work with string temp here..
newHtml->put_innerHTML(temp);
MessageBox(NULL,temp,L"AMIT",MB_OK);

}

1] i need to create the myDiv dynamically in extension and append to
some
element say 'X' in the DOM...?

2] how to get the reference to a particular element in DOM to append a
child to using createElement and appendChild ?
(my concepts of DOM/Javascript are getting confused..so all the
problems!)

regards.
amitd
date: Mon, 24 Mar 2008 05:31:39 -0700 (PDT)   author:   unknown

Re: using createElement and appendChlid function   
wrote in message
news:b481f2f7-3c5f-45f3-92e2-839a8aa525cc@s13g2000prd.googlegroups.com
> i have to insert html elements or tags like <div> in the currently
> loaded page of the browser.
> so i tried to use createElement and appendChlid function:
> i have the following code:**but it has errors**..
>
>                            BSTR bstrDiv = ::SysAllocString(L" DIV
> id='myDiv' ");

That's not how you do it. You must pass simply "div" to createElement, 
then insert the element into the document, and finally set its id= 
attribute (and any other attributes you want) with 
IHTMLElement::setAttribute

>                            IHTMLDOMNode* theBody;
>                            hr = m_pNewElem-
>> QueryInterface(IID_IHTMLDOMNode, (void**)&theBody);

You seem to believe this call will magically give you the pointer to the 
<body> element, just because you named your variable "theBody". Unless 
you also sprinkle it with pixie dust, it doesn't work this way: 
QueryInterface always returns an interface pointer to the same COM 
object you call it on. Use IHTMLDocument2::get_body.

> and also suppose if i want to append the "div" element to a specific
> element say "<head>" or "<body>"  then how to do that?

You call appendChild on whatever element you want to append a child to, 
of course.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Mon, 24 Mar 2008 08:43:45 -0400   author:   Igor Tandetnik

Re: using createElement and appendChlid function   
Hi,
Can you please share some sample code wherein we can see how to get
the current document object and add some tags to it.?

Actually we need to get a task done in a short time and we do not have
much knowledge about COM.
So it ll be better if you could share some sample code.

Thanks.
date: Mon, 24 Mar 2008 22:07:21 -0700 (PDT)   author:   unknown

Re: using createElement and appendChlid function   
wrote in message
news:3d2a0165-f878-4919-bcb2-2f9fe5f12c25@e6g2000prf.googlegroups.com
> Can you please share some sample code wherein we can see how to get
> the current document object and add some tags to it.?

Can you please share some of your salary with me?

> Actually we need to get a task done in a short time and we do not have
> much knowledge about COM.

Then I guess you should hire someone with much knowledge about COM.

http://en.wikipedia.org/wiki/Project_triangle

> So it ll be better if you could share some sample code.

I don't quite understand. How would it be better for me if I do this?
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Tue, 25 Mar 2008 08:10:17 -0400   author:   Igor Tandetnik

Re: using createElement and appendChlid function   
On Mar 25, 5:10 pm, "Igor Tandetnik"  wrote:
>  wrote in message
>
> news:3d2a0165-f878-4919-bcb2-2f9fe5f12c25@e6g2000prf.googlegroups.com
>
> > Can you please share some sample code wherein we can see how to get
> > the current document object and add some tags to it.?
>
> Can you please share some of your salary with me?
>
> > Actually we need to get a task done in a short time and we do not have
> > much knowledge about COM.
>
> Then I guess you should hire someone with much knowledge about COM.
>
> http://en.wikipedia.org/wiki/Project_triangle
>
> > So it ll be better if you could share some sample code.
>
> I don't quite understand. How would it be better for me if I do this?
> --
> With best wishes,
>     Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925


Hey no need of hiring or paying anyone its not that impossible we just
wanted to save time, . we were working on it.
and here's the code for u : " next time it ll be usefull for someone
who wants to save on time and not lose any money for it cos its free
from our side :)"


 CComPtr<IDispatch> pDisp;
HRESULT hr = m_pWebBrowser2->get_Document(&pDisp);
  CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML;
  CComQIPtr<IHTMLDocument3, &IID_IHTMLDocument3> spHTML3;
CComPtr<IHTMLElement>  newHtml = NULL;
spHTML = pDisp;
spHTML3 =  pDisp ;
 IHTMLElementCollection *pIhtml;
 if (spHTML)
 {
        IHTMLElement* pHead;
         HRESULT hr;
         spHTML->get_body(&pHead);

      IHTMLDOMNode* pDOMNode = NULL;
       if (SUCCEEDED(hr = pHead->QueryInterface( IID_IHTMLDOMNode,
(LPVOID*)&pDOMNode )))
        {
                IHTMLElement* createDiv = NULL; // A new HTML <base>
element
                 IHTMLDOMNode* RefDomNode = NULL;// reference to new
element inserted
                BSTR tagName =L"DIV";
               hr=spHTML->createElement(tagName,&createDiv);
               VARIANT v1;
	VariantInit(&v1);
               v1.bstrVal=L"my sudhir haaan created!";
               v1.vt = VT_BSTR;

       createDiv->put_innerHTML(L"<div  id='bubbleContent' name =
'bubbleContent'>hiiiiiiiii newwwwwww divvv</
div>");//;style='visibility:hidden'
                         IHTMLDOMNode* NewDomNode= NULL;
                         if (SUCCEEDED(hr = createDiv-
>QueryInterface( IID_IHTMLDOMNode, (LPVOID*)&NewDomNode)))
                         {
                             MessageBox(NULL,L"success
AMit",L"AMIT",MB_OK);
                             hr = pDOMNode-
>appendChild(NewDomNode,&RefDomNode);
                         }

                         BSTR amd;
                        RefDomNode->QueryInterface(IID_IHTMLElement,
(VOID**)&createDiv);
                        createDiv->get_innerHTML(&amd);
                        MessageBox(NULL,amd,L"aftr append !
innerhtml",MB_OK);

                        if((!SUCCEEDED(hr))||NULL ==
RefDomNode)
                        {
                            MessageBox(NULL,L"Failed
AMit",L"AMIT",MB_OK);

                        }
                     IHTMLElement* createScript = NULL;
                        hr=spHTML-
>createElement(L"SCRIPT",&createScript);
                        if(hr == S_OK)
                        MessageBox(NULL,L"new node created
",L"AMIT",MB_OK);
                        VARIANT v2,v3;
                        VariantInit(&v2);
                        VariantInit(&v3);
                        v2.bstrVal=L"text/javascript";
                        v2.vt=VT_BSTR;
                        hr = createScript->setAttribute(L"Type",v2,1);
                        if(hr == S_OK)
                        MessageBox(NULL,L"attribute type
set",L"AMIT",MB_OK);

                        v3.bstrVal=L"http://localhost/amd/a.js";
                        v3.vt=VT_BSTR;

                        createScript->setAttribute(L"src",v3,1);

                        MessageBox(NULL,L"src done",L"AMIT",MB_OK);


                        IHTMLDOMNode
*scriptnode=NULL,*refscriptnode=NULL;

                        createScript->QueryInterface(IID_IHTMLDOMNode,
(void**)&scriptnode);

                        RefDomNode-
>appendChild(scriptnode,&refscriptnode);



        }

  }
date: Tue, 25 Mar 2008 05:40:34 -0700 (PDT)   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us