News:

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

Dhtmled control

Started by ToutEnMasm, February 03, 2009, 06:09:22 PM

Previous topic - Next topic

ToutEnMasm

Hello,
I search some source code in c++,i have no hope in masm, that used the control.
Any help on the subject is welcome

donkey

#1
Hi ToutEnMasm,

I have no examples to offer but I do have a beta version of the activex interface header file that will eventually (after it is verified and tested) be included in the header project. I have attached it here, note that it is a beta version so the IIDs may be mislabeled etc... but it should be enough to give you the means to experiment (and hopefully do the corrections for me !!!)



[attachment deleted by admin]
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ToutEnMasm


Thanks for this
I am in the fog when i search to connect the IDHTMLSafe interface.

reading the registry progid = "DHTMLSafe.DHTMLSafe.1"
reading the typelib  IID_IDHTMLSafe =<0CE04B590h,02B1Fh,011D2h,<08Dh,01Eh,00h,0A0h,0C9h,059h,0BCh,0Ah>>
Quote
    [
      odl,
      uuid(CE04B590-2B1F-11D2-8D1E-00A0C959BC0A),
      helpstring("IDHTMLEdit Safe for Scripting Interface"),
      dual,
      oleautomation
    ]
    interface IDHTMLSafe : IDispatch {


It isn't the same GUID as yours,I try all and there is no one who works.
Seems that some informations are missing or wrong

contents of registry
Quote
[HKEY_CLASSES_ROOT\CLSID\{2D360201-FFF5-11d1-8D03-00A0C959BC0A}]
@="DHTML Edit Control Safe for Scripting for IE5"
\InprocServer32] @="C:\\Program Files\\Fichiers communs\\Microsoft Shared\\Triedit\\dhtmled.ocx"
"ThreadingModel"="Apartment"
\MiscStatus] @="0"
\MiscStatus\1] @="131473"
\ProgID] @="DHTMLSafe.DHTMLSafe.1"
\ToolboxBitmap32] "C:\\Program Files\\Fichiers communs\\Microsoft Shared\\Triedit\\dhtmled.ocx, 2"
\TypeLib] @="{683364A1-B37D-11D1-ADC5-006008A5848C}"
\Version] @="1.0"
\VersionIndependentProgID] @="DHTMLSafe.DHTMLSafe"


donkey

Hi ToutEnMasm,

I can't see the conflict or differences you are talking about, the GUIDs appear to match exactly those in my header (I may have changed the labels since you downloaded however)

#define GUID_TLBID_IDHTMLEdit <0x683364A1,0xB37D,0x11D1,0xAD,0xC5,0x00,0x60,0x08,0xA5,0x84,0x8C>
#define GUID_CLSID_IDHTMLSafe <0x2D360201,0xFFF5,0x11D1,0x8D,0x03,0x00,0xA0,0xC9,0x59,0xBC,0x0A>
#define GUID_IID_IDHTMLSafe <0xCE04B590,0x2B1F,0x11D2,0x8D,0x1E,0x00,0xA0,0xC9,0x59,0xBC,0x0A>

You should be able to either open the class using the guid or version independent program id and create an instance using the IID (I haven't tried either way). Note that the typelib is only necessary if you need to create an ActiveX container for the control. You can see how to do this with Ernie's great COM tutorials...

http://ourworld.compuserve.com/homepages/ernies_world/a.htm

edit>> Sorry I corrected the file here but did not upload the new version, I have done that now in my original post
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

This works...

DATA SECTION
IID_IDHTMLSafe GUID GUID_IID_IDHTMLSafe

CODE SECTION
invoke GetInterface,"DHTMLSafe.DHTMLSafe",offset IID_IDHTMLSafe

GetInterface FRAME ProgId,pIID
LOCAL wszProgID[1024]:W
LOCAL pInterface:D
LOCAL clsid :GUID

invoke MultiByteToWideChar,CP_ACP,NULL,[ProgId],-1,offset wszProgID,1024
// Get our Class ID
invoke CLSIDFromProgID,offset wszProgID, offset clsid
// Create an instance
invoke CoCreateInstance,offset clsid, NULL, CLSCTX_ALL,[pIID], offset pInterface
test eax,eax
jnz >>.NOINSTANCE
mov eax,[pInterface]
RET

.NOINSTANCE
mov eax,0
RET
ENDF


At least it returns an interface pointer, which would indicate a successful creation of an instance, what to do with it I have no idea. On my system it starts Windows installer, apparently the control is automatically installed if it isn't found.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

 :dazzled: Man, is this what they called COM?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

evlncrn8

yup, and its a total mess.. almost as bad as winsxs :)

ToutEnMasm


I think i take the good way.
I finally find how to connect the IDHTMLSafe interface.

I have loaded dynamically the triedit.dll and call the DllRegisterServer and DLLUnregisterServer as in the com stuff of hernie.
The good function to connect is cocreateinstance
Quote
;CLSID_DHTMLSafe GUID <02D360201h,0FFF5h,011d1h,<08Dh,03h,00h,0A0h,0C9h,59h,0BCh,0Ah>>
;see upper the look of the register base ,you will find it
;IID_IDHTMLSafe GUID <0CE04B590h,02B1Fh,011D2h,<08Dh,01Eh,00h,0A0h,0C9h,059h,0BCh,0Ah>>
;This one is given by oleview , typelib in texte

   invoke CoCreateInstance,addr CLSID_DHTMLSafe, NULL,CLSCTX_LOCAL_SERVER,\
         addr IID_IDHTMLSafe,addr ppvIDHTMLSafe
   .if eax == S_OK
      mov ppvIDHTMLSafe,eax
   .endif

To make a dynamic load of the library

Quote
;declarations
   PDllCanUnloadNow TYPEDEF PROTO
   FDllCanUnloadNow TYPEDEF PTR PDllCanUnloadNow
   TrieditDllCanUnloadNow TEXTEQU <FDllCanUnloadNow ptr ADRDllCanUnloadNow>

   PDllGetClassObject TYPEDEF PROTO :DWORD,:DWORD,:DWORD
   FDllGetClassObject TYPEDEF PTR PDllGetClassObject
   TrieditDllGetClassObject TEXTEQU <FDllGetClassObject ptr ADRDllGetClassObject>

   PDllRegisterServer TYPEDEF PROTO
   FDllRegisterServer TYPEDEF PTR PDllRegisterServer
   TrieditDllRegisterServer TEXTEQU <FDllRegisterServer ptr ADRDllRegisterServer>

   PDllUnregisterServer TYPEDEF PROTO
   FDllUnregisterServer TYPEDEF PTR PDllUnregisterServer
   TrieditDllUnregisterServer TEXTEQU <FDllUnregisterServer ptr ADRDllUnregisterServer>

.data
   Htriedit   dd 0   
   ADRDllCanUnloadNow dd 0
    db "DllCanUnloadNow",0
   ADRDllGetClassObject dd 0
    db "DllGetClassObject",0
   ADRDllRegisterServer dd 0
    db "DllRegisterServer",0
   ADRDllUnregisterServer dd 0
    db "DllUnregisterServer",0
      dd 0,0
.code

   invoke SearchAdresse,SADR("Path_to..\triedit.dll"),\
            addr Htriedit,addr ADRDllCanUnloadNow


   SearchAdresse PROC uses esi edi pNomDLL:DWORD,pHdll:DWORD,pFirstAdresse:DWORD
            Local  retour:DWORD
            Local  Hdll:DWORD
            ;Local    [LimiteMaxPhrase]:BYTE
         mov retour,0
      invoke LoadLibrary,pNomDLL
      mov edi,pHdll
      mov [edi],eax
      mov Hdll,eax
      .if eax == 0
         ;invoke RetrouveMessageErreur, SADR("LoadLibrary failed")"
         jmp FindeSearchAdresse
      .endif
      mov esi,pFirstAdresse
      NouvelleAdresse:
      mov edi,esi
      add esi,4
      invoke GetProcAddress,Hdll,esi
      mov [edi],eax
         .if eax == 0
            invoke RetrouveMessageErreur,esi
            ;jmp FindeSearchAdresse
         .endif
      ;passer le nom
      @@:
      .if byte ptr [esi] != 0
         inc esi
         jmp @B
      .endif
      inc esi         ;passe le zero de fin de nom
      .if dword ptr [esi+4] != 0
         jmp NouvelleAdresse
      .endif
      mov retour,1
    FindeSearchAdresse:
            mov eax,retour
            ret
   SearchAdresse endp


here is the needed include file (.sdk) to call properly the interfaces
Later , i will post a complete sample





[attachment deleted by admin]

ToutEnMasm


Seems i go too fast , and ... REGDB_E_CLASSNOTREG is the only answer i have.
here is perhaps some lights.
http://msdn.microsoft.com/en-us/library/aa663363.aspx?ppud=4

donkey

HiToutEnMasm,

I am not completely sure why you feel compelled to call the DllRegisterServer and DLLUnregisterServer functions, you should never have call these directly when simply instancing a COM object. You would normally have already run regsvr32.exe to do that for you. As a matter of fact, since there is a registry entry for the interface it is already registered and you should be able to instance it. I am having no problems at all getting an instance of DHTMLSafe both with the CLSID/IID from my header and the PROGID/IID. If Ernie used DllRegisterServer and DLLUnregisterServer it was probably in creating his own COM interface, in which case he would have to implement those functions along with DllCanUnloadNow and DllGetClassObject as well as the IUnknown interface (these make up the minimum requirements for a COM server). I have used COM extensively and have never been forced to call those functions, but if you do be sure to call DllCanUnloadNow before you call DLLUnregisterServer, since other applications may be attached to the server as well. Note that after you call DLLUnregisterServer no other application can use the interface until DllRegisterServer is called and since you would normally not call it as a simple client, most if not all applications using it will fail.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ToutEnMasm


Seems answer is here
Quote
Activating the MSHTML Editor
Microsoft Visual Basic, C++, and script all offer ways to activate the MSHTML Editor. This means you can use the Editor in an application hosting MSHTML or the WebBrowser, or on a Web Page displayed by Windows Internet Explorer. The Editor can be activated on a whole document or on individual elements within a document.
To learn how to activate the MSHTML Editor, see Activating the MSHTML Editor

There is a lot of writing to do before hosting the webBrowser,best sample i found is here
It is in c and there is a dll if you tired with writing code
http://www.codeproject.com/KB/COM/cwebpage.aspx
Microsoft explain on the control
http://msdn.microsoft.com/en-us/library/aa753630(VS.85).aspx




ToutEnMasm

Perhaps are you searching a fast way to add webpage in your application ?

The source code refered in my last post is of real good help.
he can be compiled with the vc++ express edition
He is fully commented
http://www.codeproject.com/KB/COM/cwebpage.aspx

I have translated and modify the sample of use for masm ,here is the result.
You have just now to play with
Unpack it before use,the compiled dll is in it



[attachment deleted by admin]

donkey

#12
Hi ToutEnMasm,

RadASM also has a web browser custom control written by Xtreme, you have simply to add a control with the class "WEB_BROWSER" to a dialog (or window) and call LoadLibrary. It is controlled by simple messages (WBM_NAVIGATE, WBM_GOBACK, WBM_GOFORWARD). Source, dll and lib are available on Ketil's web site and the control is integrated into the RadASM IDE. It also provides one of the best examples around for using ActiveX controls in assembly language.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ToutEnMasm

To donkey,Thanks for information.
I have finally found lights on the question.
http://www.kkhtmleditor.com/wishlist.php
Make your choice in this soap.
Best method to connect:
The values of the CLSCTX_ constant can be responsible of most of the failed to connect.
Something solve the problem,the CoCreateInstance can made the better choice between further values.
So using "CLSCTX_INPROC_HANDLER OR CLSCTX_INPROC_SERVER OR CLSCTX_LOCAL_SERVER" is a good choice.
Here is the way to connect the two controls.

GUID
Quote
IID_IkkHTMLEditor GUID <9B3DC827h,0DAC6h,4E4Fh,<93h,0E9h,4Dh,3Ah,82h,25h,37h,88h>>
IID_IDHTMLSafe GUID 0CE04B590h,02B1Fh,011D2h,<08Dh,01Eh,00h,0A0h,0C9h,059h,0BCh,0Ah

calls

Quote
invoke GetInterfaceFromProgId,SADR("kkHTMLEditorX.kkHTMLEditor"),addr IID_IkkHTMLEditor
;-------------------------------------------------------------------------
invoke GetInterfaceFromProgId,SADR("DHTMLSafe.DHTMLSafe.1"),addr IID_IDHTMLSafe

The GetInterfaceFromProgId function
Quote
GetInterfaceFromProgId PROC pProgId:DWORD,pIID:DWORD
   LOCAL wszProgID[1024]:word
   LOCAL ppv:Dword,retour,pchaine      
   LOCAL clsid   :GUID
   mov retour,0
   invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,pProgId,-1,addr wszProgID,sizeof wszProgID
   invoke CLSIDFromProgID,addr wszProgID,addr clsid
   .if eax == S_OK
      ;CLSCTX_INPROC_SERVER CLSCTX_LOCAL_SERVER
      invoke CoCreateInstance,addr clsid, NULL,
         CLSCTX_INPROC_HANDLER OR CLSCTX_INPROC_SERVER OR CLSCTX_LOCAL_SERVER,
            pIID,addr ppv
      .if eax == S_OK          
         PuPo retour,ppv
      .endif
   .endif
   mov eax,retour     ;NULL if failed
   RET
GetInterfaceFromProgId endp

This work in XP SP3

donkey

Hi ToutEnMasm,

As I had said in the Help2 thread, "CLSCTX_INPROC_HANDLER OR CLSCTX_INPROC_SERVER OR CLSCTX_LOCAL_SERVER" is the same as CLSCTX_ALL, it is generally what I use when playing with a new interface.

Code looks good though, congrats.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable