News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Reading and writing in an html page

Started by ToutEnMasm, December 10, 2010, 06:29:36 PM

Previous topic - Next topic

ToutEnMasm

The interesting part of this sample is in the InterrogeFeuille proc
The function of IHTMLElement interface need to be more study.
To use the sample made a simple thing:
open exemple.htm with no other one html page
run html.exe
The text "chose" in the input will be change to "reussite"
Help to made it better is wellcome.
You need to donwload the ready to use sdk in
the "windows.inc project" subforum
Some modifies have been made in it ( VARIANT structure)

ToutEnMasm


Here is the missing part when we find a INPUT element
Quote
;http://msdn.microsoft.com/en-us/library/aa219328(v=office.11).aspx
IDispatch QueryInterface,addr IID_IHTMLInputTextElement,addr ppvIHTMLInputTextElement
.if ppvIHTMLInputTextElement != 0
   IHTMLInputTextElement get_type,addr bstrvide
   invoke UtoA,bstrvide
   invoke lstrcmpi,addr buffer,SADR("text")
   .if eax == 0
      IHTMLInputTextElement put_value,BSTR("Reussite")
   .endif
   IHTMLInputTextElement Release
.endif
There is such an interface for each found element ,IMG and so on,see:
http://msdn.microsoft.com/en-us/library/aa219328(v=office.11).aspx



Rockphorr

Strike while the iron is hot - Бей утюгом, пока он горячий

ToutEnMasm


Firefox isn't internet explorer.Here you see that microsoft offer more than other explorer.
Perhaps is there a typelib with firefox who can do the same ?.
The first thing to do with firefox is this one.You can also verify the names of the class windows but they are certainly differents.
If you find a typelib with firefox ,I will help you translate it for masm.

ToutEnMasm


ToutEnMasm

This one is difficult to find because the MSDN documentation is at least confuse.
The problem is to add OPTION to a SELECT box (html listbox)
Quote
      DEF_OPTION STRUCT
         text       VARIANT <>
         value       VARIANT <>
         defaultselected    VARIANT <>
         selected       VARIANT <>      
      DEF_OPTION ENDS
Quote
;IHTMLElement get_tagName,addr Unebstr --> SELECT   
invoke lstrcmpi,addr phrase,SADR("SELECT")
.if eax == 0                  
IHTMLWindow2 get_Option,addr ppvIHTMLOptionElementFactory
.if eax == S_OK
   ;définir l'option
   mov def_option.text.n1.n2.vt,VT_BSTR
   mov def_option.text.n1.n2.n3.pbstrVal,BSTR("Une_Option")
   mov def_option.value.n1.n2.vt,VT_BSTR
   mov def_option.value.n1.n2.n3.pbstrVal,BSTR("1")
   mov def_option.defaultselected.n1.n2.vt,VT_BOOL
   mov def_option.defaultselected.n1.n2.n3.boolVal,0
   mov def_option.selected.n1.n2.vt,VT_BOOL
   mov def_option.selected.n1.n2.n3.boolVal,0
   IHTMLOptionElementFactory create,def_option.text,def_option.value,\
   def_option.defaultselected,def_option.selected,addr ppvIoptions
   .if eax != S_OK
      invoke LireEr_Com,eax
      .if eax != 0                           
         invoke MessageBox,NULL,ecx,SADR("IHTMLOptionElementFactory"),MB_OK
      .endif
   .else                           
      IDispatch QueryInterface,addr IID_IHTMLSelectElement,addr ppvIHTMLSelectElement
      .if ppvIHTMLSelectElement != 0
         IHTMLSelectElement Add1,ppvIoptions,Index_New
         .if eax != S_OK
            invoke LireEr_Com,eax
            .if eax != 0                           
               invoke MessageBox,NULL,ecx,SADR("IHTMLOptionElementFactory"),MB_OK
            .endif
         .endif                              
         IHTMLSelectElement Release                              
      .endif ;ppvIHTMLSelectElement not zero
      Ioptions Release                                                   
   .endif ;ppvIoptions not zero   
   IHTMLOptionElementFactory Release                                                            
.endif ;ppvIHTMLOptionElementFactory not zero