Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog with Web Browser Auto Resize to suit screen
#1
Hi Gint,

Im using your browser code to load a web page but im unsure how to set the window/dialog to auto resize to the users screen.

Code:
Copy      Help
Function [b]Dialog_with_web_browser[/b] [help1][/help1]
[code]\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;Web browser control is defined in SHDocVw type library, which is already declared, so we don't have to declare it again.

str controls = "3"
str ax3SHD

;To initialize web browser control, you can assign an URL or path or HTML to
;the variable, like in the commented examples below. Or, later use setwintext.
;Or you can use Navigate, like in the code below.

;ax3SHD="" ;;load empty page
;ax3SHD="#" ;;open an URL
;ax3SHD="<p>text <b>bold</b></p>" ;;load HTML (must begin with "<")
;IntGetFile "http://www.quickmacros.com" ax3SHD; err ret ;;at first download HTML from the web

if(!ShowDialog("Dialog_with_web_browser" &Dialog_with_web_browser &controls _hwndqm)) ret

;BEGIN DIALOG
;0 "" 0x10CF0A48 0x100 0 0 277 200 "Form"
;3 ActiveX 0x54000000 0x4 12 20 236 154 "SHDocVw.WebBrowser"
;4 Button 0x54032001 0x4 0 0 48 14 "Back"
;5 Button 0x54032000 0x4 48 0 48 14 "Forward"
;6 Button 0x54032000 0x0 96 0 48 14 "Stop"
;7 Button 0x54032000 0x0 144 0 48 14 "Refresh"
;8 Button 0x54032000 0x0 192 0 48 14 "Home"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "" "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3._getcontrol(id(3 hDlg))
,we3._setevents("we3_DWebBrowserEvents2")
,we3.Silent=TRUE ;;prevent script error messages
,we3.Navigate("#")
,
,case WM_SIZE
,RECT r; GetClientRect(hDlg &r)
,MoveWindow id(3 hDlg) 0 30 r.right r.bottom-30 1
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [4,5,6,7,8]
,err-
,we3._getcontrol(id(3 hDlg))
,sel wParam
,,case 4 we3.GoBack
,,case 5 we3.GoForward
,,case 6 we3.Stop
,,case 7 we3.Refresh
,,case 8 we3.GoHome
,err+
,
,case IDOK
,case IDCANCEL
ret 1
[/code]
#2
is their a better way then using "max win"?
#3
save window position in registry
Function Dialog101
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("Dialog101" &Dialog101 0)) ret

;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x0 0 0 217 129 "Dialog"
;END DIALOG
;DIALOG EDITOR: "" 0x2030400 "*" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,RegWinPos hDlg "my web browser" "\MyMacros" 0 1
,EnsureWindowInScreen hDlg 1
,
,case WM_DESTROY
,RegWinPos hDlg "my web browser" "\MyMacros" 1
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#4
I believe the line in WM_INITDIALOG should read
Code:
Copy      Help
,RegWinPos hDlg "my web browser" "\MyMacros" 0
for restore
This is a handy method for doing this. I will find many uses for it.
Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)