Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
close the dialog with a web page
#1
Sometimes, I need to close the dialog with a web page(webpage 3 second delay). Although the close prompt window pops up, but it cannot be closed. Is there any solution(I need to use some code in the webpage to close the dialog)? Thanks   Smile

Macro close win
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
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3.Navigate(_s.expandpath("$desktop$\close win.html"))
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Attached Files
.html   close win.html (Size: 65 bytes / Downloads: 358)
#2
Macro Macro3033
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
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
#3
thanks for your help,

I need close the QM dialog(add the code in the web page). Can I do this? In a real IE8 browser, the code in my web page can close the browser.  Huh
#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)
   
#5
the error message is very clear your variable has no value  so therefore  will error every time because your saying clo 0
the reason is because your missing a declaration that assigns a value to that variable.
i'm guessing you removed that part from further up in the code
In its current state it's just an empty variable.
 read more here
http://www.quickmacros.com/help/Language...ABLES.html 
and here
http://www.quickmacros.com/help/Language/IDP_SCOPE.html
 read section
http://www.quickmacros.com/help/
Variables, constants, numbers, strings
#6
Quote:In addition, I have defined four hotkeys, two in the main window and two in the child window. I often have hot-key errors.


__RegisterHotKey registers hotkeys that work in all windows of all apps, and fails if that hotkey is already registered by some app or some your dialog. Why not to use DT_SetAccelerators? http://www.quickmacros.com/forum/showthr...2#pid31122.
#7
I modified the code to use DT_SetAccelerators instead of __RegisterHotKey, but F1 and F3 do not take effect. F2 clicks the OK button in the main window to close the main window. why? Huh


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

sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "1 F1"
,DT_SetAccelerators hDlg "2 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_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 1 ;mes "F1"
,case 2 ;mes "F2"
,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

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,
,DT_SetAccelerators hDlg "3 F3"
,DT_SetAccelerators hDlg "4 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 3 ;mes "F3"
,case 4 ;mes "F4"
,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
#8
Take a little more time  to understand how the function  works id 1 and 2 are for ok and cancel buttons which you  don't have in your  dialog
dialog ids 0,1, and 2 are reserved

id 1= ok button
id2= cancel button
if you would be more specific as to what you want these Accelerators keys to do we can help more
#9
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

sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "1 F1"
,DT_SetAccelerators hDlg "2 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_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 1 ;mes "F1"
,case 2 ;mes "F2"
,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

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,
,DT_SetAccelerators hDlg "3 F3"
,DT_SetAccelerators hDlg "4 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 3 ;mes "F3"
,case 4 ;mes "F4"
,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


My file, in the attachment, please extract to the desktop, you can run the code  Smile

After a long time of thinking, I still can't understand why the main window is closed when the child window is closed(automatically).

@kevin  Can you guide me? Thank you very much. This may be something I can't understand. This problem has also been encountered before. Undecided


Attached Files
.zip   web.zip (Size: 653 bytes / Downloads: 345)
#10
get back to ya asap afk atm
#11
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

sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "11 F1"
,DT_SetAccelerators hDlg "12 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_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 11 ;mes "F1"
,case 12 ;mes "F2"
,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

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,
,DT_SetAccelerators hDlg "13 F3"
,DT_SetAccelerators hDlg "14 F4"
,DT_SetAutoSizeControls hDlg "3s"
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CLOSE
,DT_Ok(hDlg)
ret
;messages2
sel wParam
,case 13 ;mes "F3"
,case 14 ;mes "F4"
,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

I changed the ID but still can't work

Id11    to  F1
Id12    to  F2
Id13    to  F3
Id14    to  F4
#12
I am still unsure what your trying to accomplish here
Accelerators working here
but i don't understand your logic with close window
why open a child window only to close it?


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

sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 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_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 401
,mes  "F1"
,case 402
,mes "F2"
,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

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,;int- t_hdlg=hDlg
,DT_SetAccelerators hDlg "403 F3[]404 F4"
,DT_SetAutoSizeControls hDlg "3s"
,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
,case 403
,mes "F3"
,case 404
,mes "F4"
ret 1


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

Cancel=1
;int- t_hdlg
;clo t_hdlg
the main window close as well because you have a coding error that you haven't fixed yet so the thread ends because of error
i just can't understand what your trying to accomplish here. 
PLease explain fully what your trying to do with all this code would make things alot easier instead of going back and forth explain idea fully please!
#13
1.why open a child window only to close it?

Reply:  I want to automatically close a web page after a certain period of time

2.I am still unsure what your trying to accomplish here

Reply:  I am trying to use QM to open and control webpage e-books(I often look at e-books, the URL is here http://fliphtml5.com/explore) to automate some operations, but because I have no basis for programming, it is very difficult to learn. 

At the moment, I can only modify some of the sample code to implement some functions, but some of the features are not yet fully understood for me.

Thank you very much for your help. Heart
#14
Are you trying have  a list of links in 1 file then when you click a link in index html it opens in another  dialog then have the second  dialog  close after a given length of time and return  to the main dialog? Also what will be the functions of the accelerator keys? More details please
#15
@Kevin

The following error, I have been trying to find a solution, but the ability is limited, can not be resolved, I search a lot of code about the modal window in Google, can understand the meaning, but can not solve the problem in QM, No similar case was found on the QM forum.   can you help me again?  Smile

Error (RT) in <open ":3040: /2759">Macro2 ok:we3_WindowClosing:  window not found (the handle is 0).    <help #IDP_ERR>?



Macro [b]Macro2 ok
[/b]
Code:
Copy      Help
#sub we3_WindowClosing
function @IsChildWindow @&Cancel ;;SHDocVw.IWebBrowser2'we3

Cancel=1
int- t_hdlg
clo t_hdlg

1.What will be the functions of the accelerator keys?

Reply: Sometimes I need to click on a button in the eBook so I define a hot key to operate it   Smile

In QM, some simple operations are easier. For dialog boxes, I feel it is difficult to learn.

2.Are you trying have  a list of links in 1 file then when you click a link in index html it opens in another  dialog then have the second  dialog  close after a given length of time and return  to the main dialog?

Reply: No, at the moment I only want to close the child window on the page (that adds the specific delay code) E.g:

<body onload="window.setTimeout('window.close()',3000)">
………………
</body>


I don't understand why it can't be implemented, only close the current window, and the main window keep open
#16
Again the error is because  the variable  has no value 
Its  saying  close nothing  which qm or any program would red flag and say no i can't do that with clo function
Please take more time to read qm help it will better explain how things work
a variable needs specific things in order for it to do anything for example
you cant just say
i=4
or
url="www.google.com"
and then use it
first have to declare it
int i=4
str url="www.google.com"
and also need to understand what  the declarations mean
int is for numbers but only certain types of numbers
str can be many things
http://www.quickmacros.com/help/Language...ABLES.html
read again  
help topics
http://www.quickmacros.com/help/
in category Variables, constants, numbers, strings
this information is also built into QM itself under help

since your trying to close the child dialog need to first set the child dialogs window handle value to a variable in his case variable t_hdlg and pass that id to the child dialogs close sub function to the close the child window


Code:
Copy      Help
#sub DlgProc2
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,int- t_hdlg=hDlg
,DT_SetAccelerators hDlg "403 F3[]404 F4"
,DT_SetAutoSizeControls hDlg "3s"
,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
,case 403
,mes "F3"
,case 404
,mes "F4"
ret 1


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

Cancel=1
int- t_hdlg
clo t_hdlg
 then only the child dialog will close
#17
,int- t_hdlg=hDlg

This code is effective


Thank you very much, Heart I always think that(the variable hDlg is public), it seems that each dialog should be defined separately, I will focus on learning later Smile


I hope that the above examples are a good help for beginners. Tongue
#18
there are some global variables in qm hDlg is not one of them
 there is a a few ways to create Global variables but it's good practice to not use global variables unless absolutely needed
#19
Okay, thanks again for your remind  Heart

@Kevin

It's a little weird , in actual use, many times, the main window and sub-window will still close at the same time   Huh

The following prompt appears:
window not found (the handle is invalid).    <help #IDP_ERR>?

The first time I click on the link, the popup window closes automatically and it's normal.

The second time I click the link, the main window and child window will be closed at the same time Huh


Macro Macro1 no
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

sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "11 F1"
,DT_SetAccelerators hDlg "12 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_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 11 ;mes "F1"
,case 12 ;mes "F2"
,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

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,int- t_hdlg=hDlg
,DT_SetAccelerators hDlg "403 F3[]404 F4"
,DT_SetAutoSizeControls hDlg "3s"
,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
,case 403
,mes "F3"
,case 404
,mes "F4"
ret 1


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

Cancel=1
int- t_hdlg
clo t_hdlg
#20
Didnt have that  issue here. Maybe better to not use child dialog since  your  not passing anything back to main dialog.there  are other options .cant tell for sure from  error  message  what is rhe issue  maindialog will close  if error  anywhere in the  function code including  sub  function ect. The error mesaage has a click able link  click it  it will show the  line that the error  came from
#21
On my windows 7 system, I can run it successfully only once. The second time ,All dialogs close at the same time


Attached Files Image(s)
   
#22
I can confirm i am having the same problem. and same error 2nd time clicking link dialog2 handle is 0
#23
@Gintaras 

Hello, can you help me? This feature is very useful for me,Thanks in advance Smile
#24
change code  to

Code:
Copy      Help
#sub we3_WindowClosing
function @IsChildWindow @&Cancel ;;SHDocVw.IWebBrowser2'we3
Cancel=1
int w=win("Dialog2" "#32770")
clo w
#25
Thank you very much. It is working fine now.   Heart

This way of defining variables, I can understand, can you explain to me, is this variable definition different from the previous definition of variables?   Undecided
#26
after some more testing this is probably a better solution
just need to move the 1st t_hdlg declaration statement out of WM_INITDIALOG


Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CB0AC8 0x0 0 0 900 432 "Browser"
;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

sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 F1[]402 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_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 401
,mes  "F1"
,case 402
,mes "F2"
,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
int- t_hdlg
sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,t_hdlg=hDlg
,DT_SetAccelerators hDlg "403 F3[]404 F4"
,DT_SetAutoSizeControls hDlg "3s"
,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
,case 403
,mes "F3"
,case 404
,mes "F4"
ret 1


#sub we3_WindowClosing
function @IsChildWindow @&Cancel ;;SHDocVw.IWebBrowser2'we3
Cancel=1
int- t_hdlg
clo t_hdlg
WM_INITDIALOG is called many times when creating a dialog so for some reason t_hdlg=hDlg was losing its value.
but either solution will work

both variables are of the same type just different scope is different. w is a local variable t_hdlg is thread variable
read more here
http://www.quickmacros.com/help/Language...ABLES.html


Forum Jump:


Users browsing this thread: 2 Guest(s)