' $c32  DL  11/25/13 Update again to put back the old comments for c26 and c23.  Fixed precopy_nt.bat so hopefully this file won't get edited anymore on developer machines
' $c31  DL  11/15/13 Updated the swhtmlinterface version to 23
' $c30  OS8 03/21/12 Added getFontSize for customize settings. 
' $c29  N36 10/10/12 Modified the comment of Last submission 
' $c28  N36 08/13/12 SPR 663244 : Added methods to get previous tip and current tip index 
' $c27  GLK 01/25/12 Changed SwHtmlInterface. 20 back to 20; Prj 18170 change 5010 to whichCommand
' $c26  JPS 04/14/11 Updating to SwHtmlControl.SwHtmlInterface.20 for SW2012 Beta1 . Not sure where all the previous submission comments are... but it was SwHtmlControl.SwHtmlInterface.19 prior to this submission. Also fixing old comment as PEL overwrote 16 with 17...
' $c25  PEL 02/20/08 Update to .17.
' $c24  JPS 11/17/07 Added call to new RunInternalCommand function.
' $c23  JPS 03/05/07 Updating to SwHtmlControl.SwHtmlInterface.16 for SW2008 Beta1. Replaced all individual CreateObject calls with getSWHtmlControl().
' $c22  JPS 01/15/07 Added GetSWVersionString
' $c21  JPS 07/21/06 Removed call to .NET component since it is no longer used and we werent using it anyway
' $c20  JPS 05/14/06 Added scan3D 
' $c19  JPS 04/12/06 Added call to GetWelcomePageNews
' $c18  JPS 03/28/06 Added a few more news feed functions for handling the options page.
' $c17  JPS 03/20/06 Added updateFeedDataVB
' $c16  JPS 03/16/06 Moved this file from welcomepage folder to taskpane\common
' $c15  JPS 02/24/06 Updated comment.
' $c14  JPS 02/08/06 Updated control version from 14 to 15 for SW2007
' $c13	JPS 09/22/05 SPR 280522. Added isX64.
' $c12  JPS 04/11/05 Updated control version from 13 to 14 for SW2006
' $c11  JPS 04/06/05 Updated control version from 13 to 14 for SW2006
' $c10  JPS 02/25/05 Added getSeatType and OnWhatsInstalledPage call.
' $c9   JPS 07/09/04 Added getCollapseState and GetCollapsedItems and added call to SetCollapseState for remembering collapse/expand states of group boxes.
' $c8   JPS 05/21/04 Added call to OnSubscriptionServicesPage in doCommand.
' $c7   JPS 05/10/04 Added call to OnPrint3D in doCommand.
' $c6   JPS 04/26/04 Added calls to OnCosmosXpress and OnMoldflowXpress.
' $c5   JPS 04/23/04 Return error text if GetPageText fails.
' $c4   JPS 02/26/04 Added GetCurrentTipOfTheDay.
' $c3   JPS 02/26/04 Added GetNextTipOfTheDay and GetPageText.
' $c2   JPS 01/14/04 SPR 202517. Updated control version.
' $c1   JPS 12/05/03 Created.
' 
' 
'  Copyright 2004 SolidWorks Corporation.  All rights reserved.
' 
'  No part of these files may be reproduced or used outside of the SolidWorks product
'  for any purpose, without the express written permission of SolidWorks Corporation.
' 
' 
' 

function getSWHtmlControl()

	Set pSWHtmlControl = CreateObject("SwHtmlControl.SwHtmlInterface.23")	'' UPDATE THIS VALUE EACH MAJOR REV OF SW !!!!!!

	if (pSWHtmlControl is nothing) then
		MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. "
		exit function
	end if

    Set getSWHtmlControl = pSWHtmlControl

end function
' This is the function used to make various calls into SolidWorks.
function doCommand(whichCommand, arg)
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim theRecentFiles
		
	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then
		exit function
	end if
	   
	if (whichCommand = 0) then
		pSWHtmlControl.FileOpenDialog
	elseif (whichCommand = 1) then
		pSWHtmlControl.FileNewDialog
	elseif (whichCommand = 2) then
		'MsgBox("Opening file")
		'MsgBox(arg)
		pSWHtmlControl.OpenRecentFile(arg)
	elseif (whichCommand = 3) then
		pSWHtmlControl.OpenHTMLHelp(arg)
		'MsgBox(theRecentFiles)
		'pSWHtmlControl.GetUserPreferenceToggle(1)
	elseif (whichCommand = 5000) then
		pSWHtmlControl.OnCosmosXpress
	elseif (whichCommand = 5001) then
		pSWHtmlControl.OnMoldflowXpress
	elseif (whichCommand = 5002) then
		pSWHtmlControl.OnPrint3D
	elseif (whichCommand = 5003) then
		pSWHtmlControl.OnSubscriptionServicesPage
	elseif (whichCommand = 5004) then
		pSWHtmlControl.SetCollapseState(arg)
	elseif (whichCommand = 5008) then
		pSWHtmlControl.OnWhatsInstalledPage

	else
		pSWHtmlControl.RunInternalCommand whichCommand, arg   ' Handle other calls generically so we don't have to continually expose
                                                                ' new methods on swHtmlControl which are simply for internal use anyway.
                                                                ' SW Developers, simply modify auAm_c::Command() function with new 'whichCommand' support.
	end if

End function
	
function getRecentFiles()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim theRecentFiles
	'MsgBox(getRecentFiles)

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		getRecentFiles = ""
	else
		getRecentFiles = pSWHtmlControl.GetRecentFiles()
	end if

	'MsgBox(getRecentFiles)

End function

function getVertical()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		getVertical = 0
	else
		retval = pSWHtmlControl.GetVertical
	end if

	getVertical = retval

	'MsgBox(retval)

End function

function getFontSize()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		getFontSize= 0
	else
		retval = pSWHtmlControl.GetFontSize
	end if

	getFontSize = retval

	'MsgBox(retval)

End function


function GetNextTipOfTheDay()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetNextTipOfTheDay = ""
	else
		retval = pSWHtmlControl.GetNextTipOfTheDay
	end if

	GetNextTipOfTheDay = retval

	'MsgBox(retval)

End function

function GetPrevTipOfTheDay()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetPrevTipOfTheDay = ""
	else
		retval = pSWHtmlControl.GetPrevTipOfTheDay
	end if

	GetPrevTipOfTheDay = retval

	'MsgBox(retval)

End function

function GetCurrentTODIndex()
    On Error Resume Next
    Dim pSWHtmlControl
    Dim retval
    
    Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetCurrentTODIndex = ""
	else
		retval = pSWHtmlControl.GetCurrentTODIndex
	end if

	GetCurrentTODIndex = retval
	
End function 


function GetCurrentTipOfTheDay()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetCurrentTipOfTheDay = ""
	else
		retval = pSWHtmlControl.GetCurrentTipOfTheDay
	end if

	GetCurrentTipOfTheDay = retval

	'MsgBox(retval)

End function


function GetPageText()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetPageText = ""
	else
		retval = pSWHtmlControl.GetWelcomeResources
	end if

	if (retval = "") then
		GetPageText = "Error"		' Need to set some kind of value or else it is undefined when it gets back to the javascript code
	else
		GetPageText = retval
	end if

	'MsgBox(GetPageText)

End function

function GetFeedPageText()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetFeedPageText = ""
	else
		retval = pSWHtmlControl.GetFeedResources
	end if

	if (retval = "") then
		GetFeedPageText = "Error"		' Need to set some kind of value or else it is undefined when it gets back to the javascript code
	else
		GetFeedPageText = retval
	end if

	'MsgBox(GetFeedPageText)

End function

function getCollapseState(arg)
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		getCollapseState = ""
	else
		retval = pSWHtmlControl.GetCollapseState(arg)
	end if

	getCollapseState = retval

End function

function GetCollapsedItems()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetCollapsedItems = ""
	else
		retval = pSWHtmlControl.GetCollapsedItems
	end if

	if (retval = "") then
		GetCollapsedItems = "None"		' Need to set some kind of value or else it is undefined when it gets back to the javascript code
	else
		GetCollapsedItems = retval
	end if

	''''MsgBox(GetCollapsedItems)

End function

function getUserExperienceLevel()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		getUserExperienceLevel = 0
	else
		retval = pSWHtmlControl.GetUserExperienceLevel
	end if

	getUserExperienceLevel = retval

	'MsgBox(retval)

End function

function getSeatType()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		getSeatType = 0
	else
		retval = pSWHtmlControl.GetSeatType
	end if

	getSeatType = retval

	'MsgBox(retval)

End function

function isX64()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		retval = 0
	else
		retval = pSWHtmlControl.IsX64
	end if

	isX64 = retval

	'MsgBox(retval)

End function


function updateFeedDataVB()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		retval = 0
	else
		retval = 0          'pSWHtmlControl.GetWelcomePageNews        ' Not using anymore with new XML methods. Only called for debugging anyway.
	end if

	if (retval = "") then
		updateFeedDataVB = ""		' Need to set some kind of value or else it is undefined when it gets back to the javascript code
	else
		updateFeedDataVB = retval
	end if

	'MsgBox(updateFeedDataVB)

End function

function showFeedOptionsPageVB()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		retval = 0
	else
		retval = pSWHtmlControl.ShowFeedOptions
	end if

'	MsgBox(retval)
	if (retval = "") then
		showFeedOptionsPageVB = "error"		' Need to set some kind of value or else it is undefined when it gets back to the javascript code
	else
		showFeedOptionsPageVB = retval
	end if


End function

function setNumFeedItemsPerSection(arg)
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		retval = 0
	else
		pSWHtmlControl.SetNumFeedItemsPerSection(arg)
	end if

End function

function setNewsFeedChoiceVB(feedId, isOn)
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		retval = 0
	else
		pSWHtmlControl.SetNewsFeedChoice feedId, isOn
	end if


End function

function scan3D()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		retval = 0
	else
		retval = pSWHtmlControl.LaunchScanStudio
	end if

	scan3D = retval

End function

function GetSWVersionString()
	
	On Error Resume Next
	Dim pSWHtmlControl
	Dim retval

	Set pSWHtmlControl = getSWHtmlControl()

	if (pSWHtmlControl is nothing) then  
		''''MsgBox "Error obtaining SwHtmlControl interface. 'swHTMLControl.dll' must be registered. SPR 162520 will get this registered for everyone, or see JPS."
		GetSWVersionString = ""
	else
		retval = pSWHtmlControl.GetSWVersion
	end if

	GetSWVersionString = retval

	'MsgBox(retval)

End function
