04-09-2018, 09:16 PM
Hello Gintaras,
I am hoping you can help me make this a bit more functional.
I want to have a multi-tabbed browser (similar to other samples in forum/archive).
- it appears or disappears based on page (DT_Page)
- it preloads all webpages but hidden (based on Page designation)
- The tab control is hidden and controlled by a CB with listings of various webpages
- works with splitter
I have all the above addressed below BUT:
- I have bad way of attaching control - usually would be attached by tabcontrol adjacent to splitter but since I take away VISIBLE property for tab control, I have to move up a bit so when webcontrols are created a little below, they are close enough to splitter
- I have to use ds.AttachControls(1) for each webcontrol created - works okay BUT:
- everytime I move splitter bar, it redraws all webpages - not a problem when just one or two but if many, it flips through them all very fast
- after moving splitter bar, the webpage doesn't always redraw properly, sometimes yes, sometimes no.
- I don't know if there is a call back like WM_MOVE or WM_DRAWITEM but that is specific for moving splitter - though some case lParam or case wParam, but if so I could send some RedrawWindow window message.
I tried this but it didn't work: (hDlg 0 0 RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN|RDW_FRAME)
Thanks so much. I think I am pretty close.
Much appreciated.
S
Function dlg_MultiPage_tabbed_web_browser
I am hoping you can help me make this a bit more functional.
I want to have a multi-tabbed browser (similar to other samples in forum/archive).
- it appears or disappears based on page (DT_Page)
- it preloads all webpages but hidden (based on Page designation)
- The tab control is hidden and controlled by a CB with listings of various webpages
- works with splitter
I have all the above addressed below BUT:
- I have bad way of attaching control - usually would be attached by tabcontrol adjacent to splitter but since I take away VISIBLE property for tab control, I have to move up a bit so when webcontrols are created a little below, they are close enough to splitter
- I have to use ds.AttachControls(1) for each webcontrol created - works okay BUT:
- everytime I move splitter bar, it redraws all webpages - not a problem when just one or two but if many, it flips through them all very fast
- after moving splitter bar, the webpage doesn't always redraw properly, sometimes yes, sometimes no.
- I don't know if there is a call back like WM_MOVE or WM_DRAWITEM but that is specific for moving splitter - though some case lParam or case wParam, but if so I could send some RedrawWindow window message.
I tried this but it didn't work: (hDlg 0 0 RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN|RDW_FRAME)
Thanks so much. I think I am pretty close.
Much appreciated.
S
Function dlg_MultiPage_tabbed_web_browser
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
InitSplitter
out
str controls = "6 7"
str cb6 e7
e7 = "always present element"
if(!ShowDialog("dlg_MultiPage_tabbed_web_browser" &dlg_MultiPage_tabbed_web_browser &controls)) ret
if(!ShowDialog("dlg_MultiPage_tabbed_web_browser" &dlg_MultiPage_tabbed_web_browser &controls)) ret
;BEGIN DIALOG
;0 "" 0x10CF0A48 0x100 0 0 691 662 "QM tabbed web browser"
;6 ComboBox 0x54230243 0x0 4 28 96 213 ""
;36 QM_Splitter 0x54000000 0x1 124 340 564 14 ""
;7 Edit 0x54030080 0x200 122 50 568 290 ""
;1003 SysTabControl32 0x44000040 0x0 124 338 566 402 ""
;4 Button 0x54032000 0x0 0 0 110 18 "Show MultiBrowser"
;5 Button 0x54032000 0x0 124 0 88 18 "Hide Browser"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "0" "" ""
ret
;messages
type TWB_TAB ~path ~name hwndwb
ARRAY(TWB_TAB)- ta
int- iTab
SHDocVw.WebBrowser wbDTWB2
int i htb
RECT rct
DlgSplitter ds.Init(hDlg 36)
sel message
,case WM_INITDIALOG
,,;specify tabs in CSV format: title, URL.
,,str pagesCSV=
,,;Google, www.google.com
,,;Bing, www.bing.com
,,;Google, www.google.com
,,;Bing, www.bing.com
,,;Google, www.google.com
,,;Bing, www.bing.com
,,;Google, www.google.com
,,;Bing, www.bing.com
,,
,,int- ctrlId
,,;add tabs
,,ICsv csv=CreateCsv(1); csv.FromString(pagesCSV)
,,htb=id(1003 hDlg)
,,TCITEMW ti.mask=TCIF_TEXT
,,for i 0 csv.RowCount
,,,TWB_TAB& r=ta[]
,,,r.path=csv.Cell(i 1)
,,,ti.pszText=@csv.Cell(i 0)
,,,SendMessage htb TCM_INSERTITEMW i &ti
,,,CB_Add id(6 hDlg) csv.Cell(i 0)
,,,TabControlGetClientRect htb hDlg rct
,,,ctrlId=iTab*100+1000 ;;this id will work with DT_Page
,,,r.hwndwb=CreateControl(0 "ActiveX" "SHDocVw.WebBrowser" 0 rct.left rct.top rct.right-rct.left rct.bottom-rct.top hDlg ctrlId)
,,,BringWindowToTop r.hwndwb
,,,ds.AttachControls(1)
,,,wbDTWB2._getcontrol(r.hwndwb)
,,,wbDTWB2.Silent=TRUE
,,,wbDTWB2.Navigate(r.path)
,,,
,
,,iTab=-1
,,SelectTab htb -1 ;;none
,,DT_Page hDlg -1
,
,case WM_PAINT
,,out lParam
,,out wParam
,,RedrawWindow(hDlg 0 0 RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN|RDW_FRAME)
,,
,
,case WM_DESTROY
,
,case WM_SIZE
,
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,
,case CBN_SELCHANGE<<16|6
,,htb=id(1003 hDlg)
,,int CbIndex = CB_SelectedItem(id(6 hDlg))
,,for(i 0 ta.len) if(ta[i].hwndwb) hid ta[i].hwndwb ;;hide all
,,&r=ta[CbIndex]
,,if(r.hwndwb)
,,,hid- r.hwndwb ;;if the control already created, unhide
,,,BringWindowToTop r.hwndwb
,,
,case 4
,,DT_Page hDlg 0
,case 5
,,DT_Page hDlg -1
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case TCN_SELCHANGE ;;a tab selected
,htb=nh.hwndFrom
,for(i 0 ta.len) if(ta[i].hwndwb) hid ta[i].hwndwb ;;hide all
,i=SendMessage(htb TCM_GETCURSEL 0 0); if(i<0 or i>=ta.len) ret
,iTab=i
,&r=ta[i]
,if(r.hwndwb)
,,hid- r.hwndwb ;;if the control already created, unhide
,,BringWindowToTop r.hwndwb