forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Browse.dsu (ctl)

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Units
View previous topic :: View next topic  
Author Message
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Fri Apr 22, 2011 3:46 am    Post subject: Browse.dsu (ctl) Reply with quote

Browse.dsu (ctl)
updated 4/22/2011
Compliant with:
Request For Comment (RFC): VDS Built Custom Controls for VDS
http://www.vdsworld.com/forum/viewtopic.php?t=5154

To fully utilize this control you should familiarize yourself with execcommand parameters. Several are supported although it states not supported.

http://msdn.microsoft.com/en-us/library/ms533049(v=vs.85).aspx

Parent Spreadsheet Program
Code:
gosub initialize

  external vdsbrw50.dll
#include browse.ctl
title Simple Spreadsheet
  DIALOG CREATE,Simple Spreadsheet,-1,0,800,600,RESIZABLE,savepos,class spxreadsheet
     dialog add,menu,&File,&New,&Open,&Save,&Save As,&Publish
     dialog add,status,status1
    DIALOG SHOW
REM *** Modified by Dialog Designer on 4/10/2011 - 22:48 ***
  browse add,browse,browser1,#spxreadsheet,0,0,@dlgpos(,w),@diff(@dlgpos(,h),20)
   %%browser = @browse(browser,1)
  dialog add,button,hidecaret,0,0,20,20," "

 rem dialog add,button,button1,0,0,100,200,test
 option errortrap,runas
registry write,root,.owx,,"Office.WebSpreadsheet"
registry write,root,Office.WebSpreadsheet\shell\Open\command,,@chr(34)%0@chr(34) @chr(34)@chr(37)1@chr(34)
    option errortrap,""
   
     if %1
  if @equal(%1,runasadmin)
   if %2
   dialog set,@browse(browser,1),%2
   else
   list savefile,1,@path(%0)temp.html
   dialog set,@browse(browser,1),@path(%0)temp.html
   end
   
   else
  dialog set,@browse(browser,1),%1
  end
  else
   list savefile,1,@path(%0)temp.html
   dialog set,@browse(browser,1),@path(%0)temp.html
  end
 

rem info @regread(root,.owx\shell\Open\command)
goto resize

 :timer
   browse update,1
 
   :evloop
  rem  %%t = @getdomreturn(@browse(browser),Book1_17125_Spreadsheet.ActiveCell.Value)
   dialog select,0
     if %%file
  dialog title,@name(%%file) - Simple Spreadsheet
   dialog set,status1,%%file
  else
  dialog title,Simple Spreadsheet
  end
    wait event,1
    parse "%%event;%%dialog",@event(d)
    dialog select,%%dialog
  goto %%event
 
  :hidecaretbutton
 dialog set,@browse(browser),javascript:alert(Book1_17125_Spreadsheet.ActiveCell.Formula);void(0);
  goto evloop
 
   :save asmenu
   dialog select,1
  dialog set,@browse(browser,1),@browse(getlargeattribute,tag,html,outerHTML,0,1)
  %%filedlg = @filedlg("HTML Spreadsheet (OWX)"|*.owx,Save "Spreadsheet",,save)
  if %%filedlg
  if @null(@ext(%%filedlg))
  %%filedlg = %%filedlg.owx
  end
  browser savefile,@browse(browser,1),%%filedlg
  %%file = %%filedlg
  else
rem  info Save aborted.
  end
  goto evloop
 
  :savemenu
  if %%file
  rem do nothing
  else
  goto save asmenu
  end
  dialog select,1
     dialog set,@browse(browser,1),@browse(getlargeattribute,tag,html,outerHTML,0)
         browser savefile,@browse(browser),%%file 
      goto evloop
     
  :openmenu
  %%file = @filedlg("HTML Spreadsheet (OWX)"|*.owx,"Open Spreadsheet")
  if %%file
  dialog select,1
  dialog set,@browse(browser,1,0),%%file
  rem setattribute browser1,tag,body,contentEditable,True,0
  end
  goto resize
 
  :newmenu
  %%ask = @ask(Save Spreadsheet?)
  if %%ask
  goto save asmenu
  end
  %%file = ""
  dialog select,1
  dialog set,@browse(browser,1),@path(%0)temp.html
    goto resize
 
  :close
  exit
 
  :resize
  %%browserwin = @browse(window,1,0)
  %%width = @dlgpos(,w)
  %%height = @diff(@dlgpos(,h),20)
  %%h = @diff(@dlgpos(,h),25)
  %%w = @diff(@dlgpos(,w),5)
  window position,%%browserwin,0,0,%%width,%%height
rem  window position,@window(@getbrowserid2(),CHILD),0,0,@dlgpos(,w),@diff(@dlgpos(,h),20)
browse update,1
dialog setpos,hidecaret,@diff(@dlgpos(,h),20),@diff(@dlgpos(,w),20),20,20
  browse setattribute,id,Book1_17125_Spreadsheet,height,%%h
  browse setattribute,id,Book1_17125_Spreadsheet,width,%%w
  goto evloop


     :runas
     if %1
     shell runas,@chr(34)%1@chr(34),runasadmin
     else
     shell runas,@chr(34)%0@chr(34),runasadmin,@chr(34)@Path(%0)@chr(34)
     end
     stop
     
     :publishmenu
    rem Content-Type: text/html
   rem Content-Transfer-Encoding: 8bit
 %%xl = @browse(getlargeattribute,tag,html,outerHTML,0,1)
 dialog set,@browse(browser),<!--@cr()Content-Type: text/html@cr()Content-Transfer-Encoding: 8bit@cr()@cr()%%xl
  %%filedlg = @filedlg("Web Archive (MHT)"|*.mht,Save "Spreadsheet",,save)
  if %%filedlg
  if @null(@ext(%%filedlg))
  %%filedlg = %%filedlg.mht
  end
  browser savefile,@browse(browser),%%filedlg
  %%file = %%filedlg
  else
rem  info Save aborted.
  end
  goto evloop

 
  :initialize
   list create,1
 list loadtext,1
"<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:o = "urn:schemas-microsoft-com:office:office" xmlns:x = "urn:schemas-microsoft-com:office:excel"><HEAD>
"<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
"<META name=ProgId content=FrontPage.Editor.Document>
"<META name=Generator content="Microsoft Excel 11"><LINK rel=File-List href="Book1_files/filelist.xml"></HEAD>
"<BODY style="overflow:'hidden'" contentEditable=false style="margin-top:0;margin-left:0;margin-bottom:0;margin-right:0">
"<DIV id=Book1_17125 align=center x:publishsource="Excel" height=100% width=100% style="margin-top:0;margin-left:0;margin-bottom:0;margin-right:0">
"<OBJECT style="margin-top:0;margin-left:0;margin-bottom:0;margin-right:0" id=Book1_17125_Spreadsheet classid=CLSID:0002E559-0000-0000-C000-000000000046 width=100% height=100%>
"<PARAM NAME="AllowPropertyToolbox" VALUE="1">
"<PARAM NAME="AutoFit" VALUE="0">
"<PARAM NAME="Calculation" VALUE="-4105">
"<PARAM NAME="Caption" VALUE="Freedom Spreadsheet">
"<PARAM NAME="DisplayColumnHeadings" VALUE="-1">
"<PARAM NAME="DisplayGridlines" VALUE="-1">
"<PARAM NAME="DisplayHorizontalScrollBar" VALUE="-1">
"<PARAM NAME="DisplayOfficeLogo" VALUE="0">
"<PARAM NAME="DisplayWorkbookTabs" VALUE="0">
"<PARAM NAME="DisplayPropertyToolbox" VALUE="-1">
"<PARAM NAME="DisplayRowHeadings" VALUE="-1">
"<PARAM NAME="DisplayTitleBar" VALUE="0">
"<PARAM NAME="DisplayToolbar" VALUE="0">
"<PARAM NAME="DisplayVerticalScrollBar" VALUE="-1">
"<PARAM NAME="MaxHeight" VALUE="100%">
"<PARAM NAME="MaxWidth" VALUE="100%">
"<PARAM NAME="DisplayWorkbookTabs" VALUE="-1">
"<PARAM NAME="EnableEvents" VALUE="-1">
"<PARAM NAME="MoveAfterReturn" VALUE="-1">
"<PARAM NAME="MoveAfterReturnDirection" VALUE="-4121">
"<PARAM NAME="RightToLeft" VALUE="0">
"<PARAM NAME="ScreenUpdating" VALUE="-1">
"<PARAM NAME="LockedDown" VALUE="0">
"<PARAM NAME="ConnectedToChart" VALUE="0">
"<PARAM NAME="DefaultQueryOnLoad" VALUE="-1">
"<PARAM NAME="EnableUndo" VALUE="-1">
"<PARAM NAME="DataType" VALUE="XMLDATA">
"<PARAM NAME="XMLData" VALUE='<?xml version="1.0"?>
<ss:Workbook xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet">
 <x:ExcelWorkbook>
 
"<x:ProtectStructure>False</x:ProtectStructure>
  <x:ActiveSheet>0</x:ActiveSheet>
 </x:ExcelWorkbook>
 
"<ss:Styles>
  <ss:Style ss:ID="Default">
   <ss:Alignment ss:Horizontal="Automatic" ss:Rotate="0.0"
"ss:Vertical="Bottom"
    ss:ReadingOrder="Context"/>
   <ss:Borders>
   </ss:Borders>
   
"<ss:Font ss:FontName="Arial" ss:Size="10" ss:Color="Automatic" ss:Bold="0"
    ss:Italic="0"
"ss:Underline="None"/>
   <ss:Interior ss:Color="Automatic" ss:Pattern="None"/>
   <ss:NumberFormat
"ss:Format="General"/>
   <ss:Protection ss:Protected="1"/>
  </ss:Style>
 </ss:Styles>
 
"<c:ComponentOptions>
  <c:Label>
   <c:Caption>Microsoft Office Spreadsheet</c:Caption>
 
"</c:Label>
  <c:SpreadsheetAutoFit/>
  <c:MaxHeight>80%</c:MaxHeight>
 
"<c:MaxWidth>80%</c:MaxWidth>
  <c:NextSheetNumber>4</c:NextSheetNumber>
 </c:ComponentOptions>
 
"<x:WorkbookOptions>
  <c:OWCVersion>11.0.0.5531         </c:OWCVersion>
 </x:WorkbookOptions>
 
"<ss:Worksheet ss:Name="Sheet1">
  <x:WorksheetOptions>
   <x:Selected/>
   
"<x:ViewableRange>R1:R262144</x:ViewableRange>
   <x:Selection>R1C1</x:Selection>
   
"<x:TopRowVisible>0</x:TopRowVisible>
   <x:LeftColumnVisible>0</x:LeftColumnVisible>
   
"<x:ProtectContents>False</x:ProtectContents>
  </x:WorksheetOptions>
  <c:WorksheetOptions>
 
"</c:WorksheetOptions>
 </ss:Worksheet>
 <ss:Worksheet ss:Name="Sheet2">
 
"<x:WorksheetOptions>
   <x:ViewableRange>R1:R262144</x:ViewableRange>
   
"<x:Selection>R1C1</x:Selection>
   <x:TopRowVisible>0</x:TopRowVisible>
   
"<x:LeftColumnVisible>0</x:LeftColumnVisible>
   <x:ProtectContents>False</x:ProtectContents>
 
"</x:WorksheetOptions>
  <c:WorksheetOptions>
  </c:WorksheetOptions>
 </ss:Worksheet>
 
"<ss:Worksheet ss:Name="Sheet3">
  <x:WorksheetOptions>
   
"<x:ViewableRange>R1:R262144</x:ViewableRange>
   <x:Selection>R1C1</x:Selection>
   
"<x:TopRowVisible>0</x:TopRowVisible>
   <x:LeftColumnVisible>0</x:LeftColumnVisible>
   
"<x:ProtectContents>False</x:ProtectContents>
  </x:WorksheetOptions>
  <c:WorksheetOptions>
 
"</c:WorksheetOptions>
 </ss:Worksheet>
</ss:Workbook>
'>
"   <p style='margin-top:100;font-family:Arial;font-size:8.0pt'>To use this Web
" page interactively, you must have Microsoft® Internet Explorer 5.01 Service
" Pack 2 (SP2) or later and the Microsoft Office 2003 Web Components.</p>
" <p style='margin-top:100;font-family:Arial;font-size:8.0pt'>See the <a
" href="http://r.office.microsoft.com/r/rlidmsowcpub?clid=1033&amp;p1=Excel">Microsoft
" Office Web site</a> for more information.</p></OBJECT></DIV></BODY></HTML>
exit



Browse.dsu (ctl)
Code:
external vdsbrw50.dll
#define command,browser
#define function,browser
#define function,getdomreturn
#define command,setdom
#define command,browse
#define function,browse
#define function,domsearchloop

:browse
if @equal(%1,add)
goto addbrowse
end
if @equal(%1,update)
goto browseupdate
end
if @equal(%1,window)
goto browsewindow
end
if @equal(%1,browser)
goto browsebrowser
end
if @equal(%1,getdom)
goto getdomreturn
end
if @equal(%1,setdom)
goto setdom
end
if @equal(%1,selectAdd)
goto selectAddOption
end
if @equal(%1,selectRemove)
goto selectRemoveOption
end
if @equal(%1,noscroll)
goto browsernoscroll
end
if @equal(%1,norclick)
goto browsernorclick
end
if @equal(%1,zoom)
goto browserzoom
end
if @equal(%1,getattribute)
goto getattribute
end
if @equal(%1,setattribute)
goto setattribute
end
if @equal(%1,execcommand)
goto execcommand
end
if @equal(%1,getlargeattribute)
goto getlargeattribute
end
if @equal(%1,inserthtml)
goto inserthtml
end
if @equal(%1,getbrowserID)
goto getbrowserID
end

:addbrowse
%%browsecount = @succ(%%browsecount)
dialog create,%3,%5,%6,%7,%8,,notitle,class browsectl
dialog add,browser,browser%%browsecount,0,0,@dlgpos(,w),@dlgpos(,h),""
dialog add,text,browserctl,0,0,0,0,browser%%browsecount
dialog hide,browserctl
dialog add,text,browserparent,0,0,0,0,%4
dialog hide,browserparent
dialog add,text,browserchild,0,0,0,0,@winexists(#browsectl)
dialog hide,browserchild
LOADLIB user32.dll
 if @ok()
 %%controlsampledummy = @lib(user32.dll,SetParent,NIL,@strdel(@winexists(@dlgtext()),1,1),@strdel(@winexists(@dlgtext(browserparent)),1,1))
 end
 FREELIB user32.dll
    dialog show
    exit
   
:browseupdate
dialog select,%2
if @equal(@winactive(c),browsectl)
%P = @sendmsg(@winexists(@dlgtext(browserparent)),$0086,1,1)
end
dialog setpos,@dlgtext(browserctl),0,0,@dlgpos(,w),@dlgpos(,h)
if %3
dialog select,%3
end
exit

:browsewindow
if %2
dialog select,%2
end
%4 = @dlgtext(browserchild)
if %3
dialog select,%3
end
exit %4

:browsebrowser
if %2
dialog select,%2
end
%4 = @dlgtext(browserctl)
if %3
dialog select,%3
end
exit %4
   
      :getDOMreturn 
       option fieldsep,|
   %3 = @regread(curuser,Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,Cookies,0)
  list create,8
  list create,9
 %4 = @datetime()
dialog set,@dlgtext(browserctl),javascript:document.cookie = 'vdsdata=|%4|'+%2+'|;expires=Fri"," 26 Dec 2099 10:00:00 GMT';void(0);

list filelist,8,%3\*.*
:domsearchloop
%5 = @next(8)
if %5
list loadfile,9,%5
:domrecurse
%6 = @next(9)
if %6
parse ";%7;%8",%6
if @equal(%7,%4)
goto domendsearch
else
goto domrecurse
end
else
goto domsearchloop
end
else
%8 = ""
end
:domendsearch
list close,9
list close,8
exit %8

:browsernoscroll
if %2
dialog select,%2
end
dialog set,@dlgtext(browserctl),javascript:document.getElementsByTagName('body')[0].style.overflow = 'hidden';void(0);
if %3
dialog select,%3
end
exit

:browsernorclick
if %2
dialog select,%2
end
 dialog set,@dlgtext(browserctl),javascript:function clickIE4(){if (event.button==2){return false;}}function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){return false;}}}if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}document.oncontextmenu=new Function('return false');void(0);
if %3
dialog select,%3
end
  exit
 
:setdom
dialog set,@dlgtext(browserctl),javascript:%2='%3';void(0);
exit
   
:selectAddOption
if %6
dialog select,%6
end
if @equal(@lower(%2),id)
dialog set,@dlgtext(browserctl),javascript:var y = new Option('%4');document.getElementById('%3').add("y,"2);void(0);
end

if @equal(@lower(%2),tag)
dialog set,@dlgtext(browserctl),javascript:var y = new Option('%4');document.getElementsByTagName('%3').item(%5).add("y,"2);void(0);
end

if @equal(@lower(%2),name)
dialog set,@dlgtext(browserctl),javascript:var y = new Option('%4');document.getElementsByName('%3').item(%5).add("y,"2);void(0);
end
if %7
dialog select,%7
end
exit

:selectRemoveOption
if %6
dialog select,%6
end
if @equal(@lower(%2),id)
dialog set,@dlgtext(browserctl),javascript:document.getElementById('%3').remove(%4)
end

if @equal(@lower(%2),tag)
dialog set,@dlgtext(browserctl),javascript:document.getElementsByTagName('%3').items.(%5).remove(%4)
end

if @equal(@lower(%2),name)
dialog set,@dlgtext(browserctl),javascript:document.getElementsByName('%3').items.(%5).remove(%4)
end
if %7
dialog select,%7
end
exit

:browserzoom
if %3
dialog select,%3
end
 dialog set,@dlgtext(browserctl),javascript:document.body.style.zoom='%2"%"';void(0);
 if %4
dialog select,%4
end
 exit
 
 :getattribute
 if %6
dialog select,%6
end
if @equal(@lower(%2),id)
%8 = @getdomreturn(@dlgtext(browserctl),"document.getElementById('"%3"')."%4)
end

if @equal(@lower(%2),tag)
%8 = @getdomreturn(@dlgtext(browserctl),"document.getElementsByTagName('"%3"').item("%5")."%4)
end

if @equal(@lower(%2),name)
%8 = @getdomreturn(@dlgtext(browserctl),"document.getElementsByName('"%3"').item("%5")."%4)
end
if %7
dialog select,%7
end

exit %8

:setattribute
if %7
dialog select,%7
end
if @equal(@lower(%2),id)
setdom @dlgtext(browserctl),"document.getElementById('"%3"')."%4,%5
end

if @equal(@lower(%2),tag)
setdom @dlgtext(browserctl),"document.getElementsByTagName('"%3"').item("%6")."%4,%5
end

if @equal(@lower(%2),name)
setdom @dlgtext(browserctl),"document.getElementsByName('"%3"').item("%6")."%4,%5
if %8
dialog select,%8
end
end
 
exit

:execcommand
if %3
dialog select,%3
end
dialog set,@dlgtext(browserctl),javascript:document.execCommand(%2);void(0);
if %4
dialog select,%4
end
exit

:getlargeattribute
if %6
dialog select,%6
end
%8 = @clipbrd()
if @equal(@lower(%2),id)
dialog set,@dlgtext(browserctl),javascript:window.clipboardData.setData('Text'"," document.getElementById('%3').%4); void(0);
end

if @equal(@lower(%2),tag)
dialog set,@dlgtext(browserctl),javascript:window.clipboardData.setData('Text'", "document.getElementsByTagName('%3').item(%5).%4); void(0);
end

if @equal(@lower(%2),name)
dialog set,@dlgtext(browserctl),javascript:window.clipboardData.setData('Text'"," document.getElementsByName('%3').item(%5).%4); void(0);
end
%9 = @clipbrd()
clipboard set,%8
if %7
dialog select,%7
end
exit %9

:inserthtml
if %3
dialog select,%3
end
dialog set,@dlgtext(browserctl),javascript:document.selection.createRange().pasteHTML('%2');void(0);
if %4
dialog select,%4
end
exit

:getbrowserID
     if %2
dialog select,%2
end
     %1 = @window(@dlgtext(),child)
     repeat
     %1 = @window(%1,next)
     if @null(%1)
     %1 = @window(%2,child)
     end
     %2 = %1
     until @equal(@winclass(%1),Internet Explorer_Server)
          if %3
dialog select,%3
end
     exit %1
     
     :createfocused
     if %2
dialog select,%2
end
       dialog set,@dlgtext(browserctl),"javascript:var elements = document.getElementsByTagName('*'); var count = elements.length; for (i=0; i<count; i++) {    elem = document.getElementsByTagName('*').item(i);    elem.focused = false;    elem.hasFocus = function() {        return this.focused;    };    elem.onfocus=function() {        this.focused=true;    };    elem.onblur=function() {        this.focused=false;    };void(0);}"
 if %3
dialog select,%3
end
   exit
   
   :getelementcount
   if %4
   dialog select,%4
   end
   if %5
   %5 = %%exitdialog
   else
   %%exitdialog = ""
   end
   
   %9 = %2
         option fieldsep,|
  list create,8
  list create,9
 %4 = @datetime()
 if @equal(@lower(%9),tag)
  dialog set,@dlgtext(browserctl),javascript:var elements = document.getElementsByTagName('%3'); var count = elements.length;document.cookie = 'vdsdata=|%4|'+count+'|;expires=Fri"," 26 Dec 2099 10:00:00 GMT';void(0);
 end
 if @equal(@lower(%9),id)
 dialog set,@dlgtext(browserctl),javascript:var elements = document.getElementById('%3'); var count = elements.length;document.cookie = 'vdsdata=|%4|'+count+'|;expires=Fri"," 26 Dec 2099 10:00:00 GMT';void(0);
 end
  if @equal(@lower(%9),name)
 dialog set,@dlgtext(browserctl),javascript:var elements = document.getElementsByName('%3'); var count = elements.length;document.cookie = 'vdsdata=|%4|'+count+'|;expires=Fri"," 26 Dec 2099 10:00:00 GMT';void(0);
 end
 %3 = @regread(curuser,Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,Cookies,0)
  list filelist,8,%3\*.*
  %%dom = @domsearchloop()
  if %%exitdialog
  dialog select,%%exitdialog
  end
  exit %%dom
 
  :setfocus
  if %5
  dialog select,%5
  end
  if @equal(@lower(%2),id)
dialog set,@dlgtext(browserctl),javascript:document.getElementById('%3').focus(); void(0);
end

if @equal(@lower(%2),tag)
dialog set,@dlgtext(browserctl),javascript:document.getElementsByTagName('%3').item(%4).focus(); void(0);
end

if @equal(@lower(%2),name)
dialog set,@dlgtext(browserctl),javascript:document.getElementsByName('%3').item(%4).focus(); void(0);
end
if %6
dialog select,%6
end
exit

[/b]
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Units All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group