WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

HTML

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

HTML Inside Dialogs: HTML Viewer

Keywords:   html viewer  HTML Control using QHTML library

I found this dll that creates an HTML control, which apparently works with wb dialogs. I noticed that the dialog has to be visible before creating the control, so i used a little trick to have the control displayed at the beggining.

You can use it to put in an hyperlink, load html files, and more.

There is a free version of the dll, but it's big (284kb).

Homepage:

http://www.gipsysoft.com/qhtm/index.shtml

DLL Download:

http://www.gipsysoft.com/qhtm/qhtmlight.zip

The dll (QHTMLight.dll) must be in the same directory of this script to run.

Below is code for an html viewer, just loads an htm or html file into the control.

I did a function to create the control to make things easier, also i noticed that you must close the dialog before freeing the dll.

And i compressed the dll from 248 to 105kb and works.

;HTML Viewer using QHTM dll
;Guido 08/2002

;constants
WS_CHILD=1073741824
WS_VISIBLE=268435456
WS_EX_CLIENTEDGE=512
WM_USER=1024
SW_SHOWNORMAL=1

QHTM_LOAD_FROM_FILE=WM_USER+2

;Creates an HTML control
#definefunction HTMLControl(id,x,y,w,h,exstyle,style,handle)
user32=strcat(dirwindows(1),"user32.dll")
hinst=dllhinst("")
return dllcall(user32,long:"CreateWindowExA",long:exstyle,lpstr:"QHTM_Window_Class_001",lpstr:"",long:style,long:x,long:y,long:w,long:h,long:handle,long:id,long:hinst,long:0)
#endfunction

;dll handles
QHTMLight=dllload(strcat(dirget(),"QHTMLight.dll"))
user32=dllload(strcat(dirwindows(1),"user32.dll"))
hinst=dllhinst("")

;initialize library
r=dllcall(QHTMLight,long:"QHTM_Initialize",long:hinst)
if r<>1
  message("Error","Failed to initialize library.")
  exit
endif

;DIALOG CALLBACK
#definesubroutine dialogproc(handle,DialogMessage,DialogControlID,p4,p5)
switch DialogMessage
  case 0 ;Init
    DialogProcOptions(Handle,2,1) ;Push buttons
    ;show dialog
    dllcall(user32,long:"ShowWindow",long:handle,long:SW_SHOWNORMAL)
    ;create html control
    hqhtm=HTMLControl(1,15,20,500,350,WS_EX_CLIENTEDGE,WS_CHILD|WS_VISIBLE,handle)
    break
  
    case 2 ;Button pushed
    switch DialogControlID
      case 1 ;Open
        DialogProcOptions(handle,1000,1) 
        htmfile=askfilename("",":\","HTM files|*.htm|HTML files|*.html","",1)
        DialogProcOptions(handle,1000,0)
        ;load html file
        intcontrol(22,hqhtm,QHTM_LOAD_FROM_FILE,0,htmfile)
        return -2
      
      case 2 ;cancel
        return -1
  endswitch
endswitch
return -1
#endsubroutine

;DIALOG
MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`HTML Viewer`
MyDialogX=-1
MyDialogY=-1
MyDialogWidth=320
MyDialogHeight=204
MyDialogNumControls=002
MyDialogProcedure=`dialogproc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`

MyDialog001=`270,011,036,012,PUSHBUTTON,DEFAULT,"Open",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`270,175,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

;free libs
dllfree(user32)
dllfree(QHTMLight)
;END SCRIPT

You can also input an html dialog inside a winbatch box (see code below):

; ----------Begin code------------------
;HTML Control using QHTML library

;constants
WS_CHILD=1073741824
WS_VISIBLE=268435456
WM_USER=1024

;dll handles
;debug(1)
QHTMLight=dllload(strcat(dirget(),"QHTM.dll"))
user32=dllload(strcat(dirwindows(1),"user32.dll"))
hinst=dllhinst("")
h=dllhwnd("")

;initialize library
r=dllcall(QHTMLight,long:"QHTM_Initialize",long:hinst)
if r<>1
message("Error","Failed to initialize library.")
exit
endif

hyperlink="HTML CODE HERE"

hqhtm=dllcall(user32,long:"CreateWindowExA",long:0,lpstr:"QHTM_Window_Class_001",lpstr:"",long:WS_CHILD|WS_VISIBLE,long:0,long:0,long:200,long:50,long:h,long:1,long:hinst,long:0)
dllcall(user32,long:"SetWindowTextA",long:hqhtm,lpstr:hyperlink)

Boxopen("toto","")

timedelay(5)
dllcall(user32,long:"DestroyWindow",long:hqhtm)
boxdestroy(1)

dllfree(user32)
dllfree(QHTMLight)
;------ end code------------------------- 

Article ID:   W15284
File Created: 2004:01:21:10:17:16
Last Updated: 2004:01:21:10:17:16