Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
close the dialog with a web page
#4
Macro Macro1
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 488 254 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 488 254 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "3"
str ax3SHD="$desktop$\close win.html"
;ax3SHD=
;;<body onload="window.setTimeout('window.close()',3000)">
;;</body>
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
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


#sub we3_WindowClosing
function @IsChildWindow @&Cancel ;;SHDocVw.IWebBrowser2'we3

Cancel=1
int- t_hdlg
clo t_hdlg

Success, thank you very much for your help  Heart

I have a suggestion that may be more convenient: Idea

1. When I drag a file after the = or (, it becomes directly like this, don't add run

str ax3SHD="$desktop$\close win.html"

2. When you are at the top of the line, add run or web

web "$desktop$\close win.html"
run "$desktop$\close win.html"

@Gintaras


I just found a problem. If the page is opened in the modal window, after using the above code, the main window and the modal window will be closed at the same time. Then the error in the image below will appear. I just want to close the modal window. I need to modify it. Where? Undecided  thanks

@Gintaras
This is my complete code. When the webpage is opened from a subwindow, it will close both the main window and the modal window

In addition, I have defined four hotkeys, two in the main window and two in the child window. I often have hot-key errors. Because I have limited programming, please give me more instructions. Thank you.


Macro Macro1
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CB0AC8 0x0 0 0 900 432 "Dialog"
;4 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "4"
str ax4SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
__RegisterHotKey- t_hk1
__RegisterHotKey- t_hk2

sel message
,case WM_INITDIALOG
,t_hk1.Register(hDlg 1 0 VK_F1) ;;F1
,t_hk2.Register(hDlg 2 0 VK_F2) ;;F2
,SetTimer hDlg 1 100 0
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,we4._setevents("sub.we4")

,we4.Navigate(_s.expandpath("$desktop$\web\index.html")) 
,DT_SetAutoSizeControls(hDlg "4s")
,
,case WM_HOTKEY
,sel wParam
,,case 1 ;mes "F1"

,,case 2 ;mes "F2"

,case WM_TIMER
,sel wParam
,,case 1
,,int wies=child("" "Internet Explorer_Server" id(4 hDlg)); if(wies=0) ret
,,SetWindowSubclass(wies &sub.WndProc_Subclass 2 0)
,,KillTimer hDlg wParam
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y           ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
ret 1


#sub WndProc_Subclass
function# hwnd message wParam lParam uIdSubclass dwRefData

;OutWinMsg message wParam lParam ;;uncomment to see received messages

sel message
,case WM_RBUTTONDOWN
,str s=
,;>menu
,;,1 submeu 1
,;,<
,MenuPopup x.AddItems(s)
,int i=x.Show
,ret

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass)
,
,;case ...

ret R


#sub we4_NewWindow3
function IDispatch&ppDisp @&Cancel dwFlags BSTR'bstrUrlContext BSTR'bstrUrl SHDocVw.IWebBrowser2'we3

int hDlg2=sub.Dialog2
SHDocVw.WebBrowser d2_we3._getcontrol(id(3 hDlg2))
ppDisp=d2_we3


#sub Dialog2
function# [hwndOwner]

str dd=
;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x0 0 0 900 432 "Dialog2"
;3 ActiveX 0x54030000 0x0 0 0 900 432 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "3"
str ax3SHD
ret ShowDialog(dd &sub.DlgProc2 &controls hwndOwner 1) ;;modeless dialog


#sub DlgProc2
function# hDlg message wParam lParam
__RegisterHotKey- t_hk3
__RegisterHotKey- t_hk4

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,
,t_hk3.Register(hDlg 3 0 VK_F3) ;;F3
,t_hk4.Register(hDlg 4 0 VK_F4) ;;F4
,DT_SetAutoSizeControls hDlg "3s"
,
,case WM_HOTKEY
,sel wParam
,,case 3 ;mes "F3"
,,case 4 ;mes "F4"

,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case IDOK
,ifk(Y)
,,key Y           ;; Enter
,,ret 0
,case IDCANCEL
,ret 0
ret 1


#sub we3_WindowClosing
function @IsChildWindow @&Cancel ;;SHDocVw.IWebBrowser2'we3

Cancel=1
int- t_hdlg
clo t_hdlg


Attached Files Image(s)
   


Messages In This Thread
close the dialog with a web page - by win - 04-30-2018, 02:26 PM
RE: close the dialog with a web page - by win - 04-30-2018, 03:39 PM
RE: close the dialog with a web page - by win - 04-30-2018, 04:41 PM
RE: close the dialog with a web page - by Kevin - 04-30-2018, 07:46 PM
RE: close the dialog with a web page - by win - 04-30-2018, 10:21 PM
RE: close the dialog with a web page - by Kevin - 04-30-2018, 10:30 PM
RE: close the dialog with a web page - by win - 04-30-2018, 10:41 PM
RE: close the dialog with a web page - by Kevin - 04-30-2018, 10:45 PM
RE: close the dialog with a web page - by win - 04-30-2018, 10:47 PM
RE: close the dialog with a web page - by Kevin - 04-30-2018, 11:33 PM
RE: close the dialog with a web page - by win - 04-30-2018, 11:52 PM
RE: close the dialog with a web page - by Kevin - 05-01-2018, 12:12 AM
RE: close the dialog with a web page - by win - 05-01-2018, 12:18 AM
RE: close the dialog with a web page - by Kevin - 05-01-2018, 12:33 AM
RE: close the dialog with a web page - by win - 05-01-2018, 01:12 AM
RE: close the dialog with a web page - by Kevin - 05-01-2018, 01:15 AM
RE: close the dialog with a web page - by win - 05-01-2018, 01:31 AM
RE: close the dialog with a web page - by Kevin - 05-01-2018, 02:11 AM
RE: close the dialog with a web page - by win - 05-01-2018, 02:19 AM
RE: close the dialog with a web page - by Kevin - 05-01-2018, 03:22 AM
RE: close the dialog with a web page - by win - 05-01-2018, 03:26 AM
RE: close the dialog with a web page - by Kevin - 05-01-2018, 03:39 AM
RE: close the dialog with a web page - by win - 05-01-2018, 03:53 AM
RE: close the dialog with a web page - by Kevin - 05-01-2018, 03:57 AM

Forum Jump:


Users browsing this thread: 4 Guest(s)