08-19-2018, 05:24 PM
here is a working example using a combo box instead of a text area i edited your html file as well.
Function HtmlElementsDialog3
here is the revised html file to go with this
index+revised.zip (Size: 1.03 KB / Downloads: 335)
Function HtmlElementsDialog3
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 448 214 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 448 214 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040701 "*" "" "" ""
str controls = "3"
str ax3SHD
ax3SHD="$desktop$\index+revised.html";; change to location of your html files
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- t_hdlg
sel message
,case WM_INITDIALOG
,t_hdlg=hDlg
,;Gets document
,MSHTML.HTMLDocument doc=sub.DT_GetHtmlDocument(hDlg 3)
,;get input button1 element and set events for it
,MSHTML.HTMLInputElement- button1=+doc.getElementById("Button1")
,button1._setevents("sub.button1")
,;get input button2 element and set events for it
,MSHTML.HTMLInputElement- button2=+doc.getElementById("Button2")
,button2._setevents("sub.button2")
,;get input button3 element and set events for it
,MSHTML.HTMLInputElement- button3=+doc.getElementById("Button3")
,button3._setevents("sub.button3")
,
,;get input button4 element and set events for it
,MSHTML.HTMLInputElement- button4=+doc.getElementById("Button4")
,button4._setevents("sub.button4")
,
,;Note: HTMLInputElement can be used for any type of input elements. For some element types also can be used specific interfaces, eg HTMLInputTextElement.
,;Note: Use thread variables for html elements for which is called _setevents.
,;Note: After navigating to other page, if these thread variables still must be used, they must be reinitialized, and _setevents called again. If not used, they should be cleared (=0).
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#sub DT_GetHtmlDocument
function'MSHTML.HTMLDocument hDlg ctrlid [flags] ;;flags: 1 - return 0 if not loaded
;Returns MSHTML.HTMLDocument interface pointer of a web browser control which is on a custom dialog.
;Call this function from dialog procedure.
;Returns 0 if the control currently is not displaying a html document.
;hDlg - parent dialog
;ctrlid - web browser control id
;SHDocVw.WebBrowser we3
SHDocVw.WebBrowser we
we._getcontrol(id(ctrlid hDlg))
if(flags&1) if(we.Busy or we.ReadyState!=SHDocVw.READYSTATE_COMPLETE) ret
ret we.Document
#sub button1_onclick
function MSHTML.DispHTMLInputElement'btn1
out "button 1 clicked"
mes "sub1 button has been clicked"
#sub button2_onclick
function MSHTML.DispHTMLInputElement'btn2
out "button 2 clicked"
mes "this is QM mes"
#sub button3_onclick
function MSHTML.DispHTMLInputElement'btn3
;on button3 click get html document
MSHTML.HTMLDocument doc=btn3.document
,;get select box element and selected item
int- t_hdlg
Htm e=htm("SELECT" "programlist" "" t_hdlg "0" 0 0x101 3)
str selItemText result1 result2
int selItem=e.CbItem(selItemText);;finds the selected item
result2=e.el.getAttribute("value" 0);; stores program name to run
result1.from("Next Will Open " selItemText);; makes a string for mes
mes result1;;; show run message
run result2;;; run selected program
#sub button4_onclick
function MSHTML.DispHTMLInputElement'btn4
;get document
MSHTML.HTMLDocument doc=btn4.document
;;get text from input
MSHTML.HTMLInputElement text=+doc.getElementById("message1")
str s1=text.getAttribute("value" 0)
if(s1.len)
,mes s1;; show text in a message
else
,mes "Opps!! You didnt type a message"
here is the revised html file to go with this
index+revised.zip (Size: 1.03 KB / Downloads: 335)