⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ultragridwindowex.htc

📁 具备表头拖拽、交换列、排序、添加 、修改、删除、选择等等功能的。NET GRID
💻 HTC
📖 第 1 页 / 共 2 页
字号:
<PUBLIC:COMPONENT lightWeight=false>
<PUBLIC:DEFAULTS contentEditable=false tabStop=true/>

<PUBLIC:attach event="ondocumentready" onevent="initCoolWindowEx()" />
<PUBLIC:attach event="ondetach" onevent="cleanupCoolWindowEx()" />
<PUBLIC:attach event="onpropertychange" onevent="coolWindowExPropertyChange()" />

<PUBLIC:property name="left" value="0px" />
<PUBLIC:property name="top" value="0px" />
<PUBLIC:property name="height" value="200px" />
<PUBLIC:property name="width" value="250px" />
<PUBLIC:property name="windowType" value="DIALOG" />
<PUBLIC:property name="windowState" value="NORMAL" />
<PUBLIC:property name="menuState" value=false />
<PUBLIC:property name="src" value="" />
<PUBLIC:property name="windowCaption" value="" />

<PUBLIC:method   name="hideMenu" />

<script language="VBScript">

option explicit

dim imgTransparent
dim imgRestore
dim imgMinimize
dim imgMaximize
dim imgClose

dim objWindowCaption
dim objCaptionImage
dim objMinButton
dim objMaxButton
dim objCloseButton
dim objCurrentButton
dim objContentWindow
dim objMenu

dim objDrag
dim objResize
dim objWindowState

dim procRef
dim procRefUp
dim procRefMove

dim internalSettingProperties

class clsObjectCoords
	private v_orgX
	private v_orgY
	private v_orgLeft
	private v_orgTop
	private v_orgWidth
	private v_orgHeight
	private v_orgOffsetWidth
	private v_orgOffsetHeight
	private v_orgDirection
	private v_orgBorder
	private v_inAction
	private v_prevState

	public property Let orgX(vData)
		v_orgX = vData
	end property

	public property Get orgX
		orgX = v_orgX
	end property

	public property Let orgY(vData)
		v_orgY = vData
	end property

	public property Get orgY
		orgY = v_orgY
	end property

	public property Let orgLeft(vData)
		v_orgLeft = vData
	end property

	public property Get orgLeft
		orgLeft = v_orgLeft
	end property

	public property Let orgTop(vData)
		v_orgTop = vData
	end property

	public property Get orgTop
		orgTop = v_orgTop
	end property

	public property Let orgWidth(vData)
		v_orgWidth = vData
	end property

	public property Get orgWidth
		orgWidth = v_orgWidth
	end property

	public property Let orgHeight(vData)
		v_orgHeight = vData
	end property

	public property Get orgHeight
		orgHeight = v_orgHeight
	end property

	public property Let orgOffsetWidth(vData)
		v_orgOffsetWidth = vData
	end property

	public property Get orgOffsetWidth
		orgOffsetWidth = v_orgOffsetWidth
	end property

	public property Let orgOffsetHeight(vData)
		v_orgOffsetHeight = vData
	end property

	public property Get orgOffsetHeight
		orgOffsetHeight = v_orgOffsetHeight
	end property

	public property Let orgDirection(vData)
		v_orgDirection = vData
	end property

	public property Get orgDirection
		orgDirection = v_orgDirection
	end property

	public property Let orgBorder(vData)
		v_orgBorder = vData
	end property

	public property Get orgBorder
		orgBorder = v_orgBorder
	end property

	public property Let inAction(vData)
		v_inAction = vData
	end property

	public property Get inAction
		inAction = v_inAction
	end property

	public property Let prevState(vData)
		v_prevState = vData
	end property

	public property Get prevState
		prevState = v_prevState
	end property

end class

sub initCoolWindowEx()
	dim childElement, txtHTML

	set objDrag = new clsObjectCoords
	set objResize = new clsObjectCoords
	set objWindowState = new clsObjectCoords

	objDrag.inAction = false
	objResize.inAction = false
	objWindowState.orgBorder = element.parentElement.style.border

	with element.currentStyle
		imgTransparent = .transparentImageUrl
		imgRestore = .restoreImageUrl
		imgMinimize = .minimizeImageUrl
		imgMaximize = .maximizeImageUrl
		imgClose = .closeImageUrl
	end with

	for each childElement in element.children
		select case childElement.className
			case "captionImage"
				set objCaptionImage = childElement
				set objMenu = document.createElement("DIV")
				objMenu.className = "coolMenu"
				if windowType = "NORMAL" then txtHTML = "<div class=" & chr(34) & "coolMenuItem" & chr(34) & " style=" & chr(34) & "height: 18px; padding-top: 2px;" & chr(34) & " onclick=" & chr(34) & "vbscript: " & element.id & ".windowState='NORMAL'" & chr(34) & " enabled=" & chr(34) & "false" & chr(34) & "><img src=" & chr(34) & imgRestore & chr(34) & " width=" & chr(34) & "13" & chr(34) & " height=" & chr(34) & "11" & chr(34) & ">恢复</div>"
				txtHTML = txtHTML & "<div class=" & chr(34) & "coolMenuItem" & chr(34) & " style=" & chr(34) & "height: 18px; padding-top: 2px;" & chr(34) & " onclick=" & chr(34) & "vbscript: " & chr(34) & "><img src=" & chr(34) & imgTransparent & chr(34) & " width=" & chr(34) & "13" & chr(34) & " height=" & chr(34) & "11" & chr(34) & ">移动</div>"
				if windowType = "NORMAL" then txtHTML = txtHTML & "<div class=" & chr(34) & "coolMenuItem" & chr(34) & " style=" & chr(34) & "height: 18px; padding-top: 2px;" & chr(34) & " onclick=" & chr(34) & "vbscript: " & chr(34) & "><img src=" & chr(34) & imgTransparent & chr(34) & " width=" & chr(34) & "13" & chr(34) & " height=" & chr(34) & "11" & chr(34) & ">尺寸</div>"
				if windowType = "NORMAL" then txtHTML = txtHTML & "<div class=" & chr(34) & "coolMenuItem" & chr(34) & " style=" & chr(34) & "height: 18px; padding-top: 2px;" & chr(34) & " onclick=" & chr(34) & "vbscript: " & element.id & ".windowState='MINIMIZED'" & chr(34) & "><img src=" & chr(34) & imgMinimize & chr(34) & " width=" & chr(34) & "13" & chr(34) & " height=" & chr(34) & "11" & chr(34) & ">最小化</div>"
				if windowType = "NORMAL" then txtHTML = txtHTML & "<div class=" & chr(34) & "coolMenuItem" & chr(34) & " style=" & chr(34) & "height: 18px; padding-top: 2px;" & chr(34) & " onclick=" & chr(34) & "vbscript: " & element.id & ".windowState='MAXIMIZED'" & chr(34) & "><img src=" & chr(34) & imgMaximize & chr(34) & " width=" & chr(34) & "13" & chr(34) & " height=" & chr(34) & "11" & chr(34) & ">最大化</div>"
				if windowType = "NORMAL" then txtHTML = txtHTML & "<div class=" & chr(34) & "coolMenuDivider" & chr(34) & "></div>"
				txtHTML = txtHTML & "<div class=" & chr(34) & "coolMenuItem" & chr(34) & " style=" & chr(34) & "height: 18px; padding-top: 2px;" & chr(34) & " onclick=" & chr(34) & "vbscript: " & element.id & ".windowState='CLOSED'" & chr(34) & "><img src=" & chr(34) & imgClose & chr(34) & " width=" & chr(34) & "13" & chr(34) & " height=" & chr(34) & "11" & chr(34) & ">关闭</div>"
				objMenu.innerHTML = txtHTML
				window.document.body.insertBefore objMenu
			case "windowCaption"
				set objWindowCaption = childElement
				objWindowCaption.nowrap = true
			case "captionButton"
				if instr(childElement.id, "btnMin") <> 0 then
					set objMinButton = childElement
					objMinButton.title = "Minimize"
					objMinButton.children(0).setAttribute "src", imgMinimize
					if windowType <> "NORMAL" then objMinButton.style.display = "none"
				elseif instr(childElement.id, "btnMax") <> 0 then
					set objMaxButton = childElement
					objMaxButton.title = "Maximize"
					objMaxButton.children(0).setAttribute "src", imgMaximize
					if windowType <> "NORMAL" then objMaxButton.style.display = "none"
				elseif instr(childElement.id, "btnClose") <> 0 then
					set objCloseButton = childElement
					objCloseButton.title = "Close"
					objCloseButton.children(0).setAttribute "src", imgClose
				end if
			case "windowContent"
				set objContentWindow = childElement
		end select
	next

	with objCaptionImage
		.attachEvent "onmousedown", GetRef("captionImageOnMouseDown")
		.attachEvent "onmouseup", GetRef("captionImageOnMouseUp")
		.attachEvent "ondblclick", GetRef("captionImageOnDoubleClick")
		.attachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objWindowCaption
		.attachEvent "onmousedown", GetRef("captionOnMouseDown")
		.attachEvent "ondblclick", GetRef("captionOnDoubleClick")
		.attachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objMinButton
		.attachEvent "onmousedown", GetRef("buttonOnMouseDown")
		.attachEvent "onmouseup", GetRef("buttonOnMouseUp")
		.attachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objMaxButton
		.attachEvent "onmousedown", GetRef("buttonOnMouseDown")
		.attachEvent "onmouseup", GetRef("buttonOnMouseUp")
		.attachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objCloseButton
		.attachEvent "onmousedown", GetRef("buttonOnMouseDown")
		.attachEvent "onmouseup", GetRef("buttonOnMouseUp")
		.attachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objContentWindow
		.attachEvent "onload", GetRef("contentOnLoad")
		.attachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	attachEvent "onselectstart", GetRef("coolWindowOnSelect")
	attachEvent "onmousedown", GetRef("coolWindowOnMouseDown")
	attachEvent "onmouseup", GetRef("coolWindowOnMouseUp")
	attachEvent "onmousemove", GetRef("coolWindowOnMouseMove")
	attachEvent "onresize", GetRef("windowOnResize")
	attachEvent "oncontextmenu", GetRef("coolWindowHandleDown")

	set procRef = GetRef("parentWindowOnMouseDown")
	set procRefUp = GetRef("captionOnMouseUp")
	set procRefMove = GetRef("captionOnMouseMove")

	if windowState = "MAXIMIZED" then setWindowState

	objContentWindow.setAttribute "src", element.src
end sub

sub cleanupCoolWindowEx()
	objContentWindow.setAttribute "src", "about:blank"

	with objCaptionImage
		.detachEvent "onmousedown", GetRef("captionImageOnMouseDown")
		.detachEvent "onmouseup", GetRef("captionImageOnMouseUp")
		.detachEvent "ondblclick", GetRef("captionImageOnDoubleClick")
		.detachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objWindowCaption
		.detachEvent "onmousedown", GetRef("captionOnMouseDown")
		.detachEvent "ondblclick", GetRef("captionOnDoubleClick")
		.detachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objMinButton
		.detachEvent "onmousedown", GetRef("buttonOnMouseDown")
		.detachEvent "onmouseup", GetRef("buttonOnMouseUp")
		.detachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objMaxButton
		.detachEvent "onmousedown", GetRef("buttonOnMouseDown")
		.detachEvent "onmouseup", GetRef("buttonOnMouseUp")
		.detachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objCloseButton
		.detachEvent "onmousedown", GetRef("buttonOnMouseDown")
		.detachEvent "onmouseup", GetRef("buttonOnMouseUp")
		.detachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	with objContentWindow
		.detachEvent "onload", GetRef("contentOnLoad")
		.detachEvent "oncontextmenu", GetRef("coolWindowHandleDown")
	end with

	detachEvent "onselectstart", GetRef("coolWindowOnSelect")
	detachEvent "onmousedown", GetRef("coolWindowOnMouseDown")
	detachEvent "onmouseup", GetRef("coolWindowOnMouseUp")
	detachEvent "onmousemove", GetRef("coolWindowOnMouseMove")
	detachEvent "onresize", GetRef("windowOnResize")
	detachEvent "oncontextmenu", GetRef("coolWindowHandleDown")

	if not objWindowCaption is nothing then objWindowCaption.removeNode true
	set objWindowCaption = nothing
	if not objCaptionImage is nothing then objCaptionImage.removeNode true
	set objCaptionImage = nothing
	if not objMaxButton is nothing then objMaxButton.removeNode true
	set objMaxButton = nothing
	if not objCloseButton is nothing then objCloseButton.removeNode true
	set objCloseButton = nothing
	if not objContentWindow is nothing then objContentWindow.removeNode true
	set objContentWindow = nothing
	if not objMenu is nothing then objMenu.removeNode true
	set objMenu = nothing

	set procRef = nothing
	set procRefUp = nothing
	set procRefMove = nothing

	set objDrag = nothing
	set objResize = nothing
	set objWindowState = nothing
end sub

sub contentOnLoad
	dim strTitle
	on error resume next
	strTitle = window.event.srcElement.contentWindow.document.title
	if trim(element.windowCaption) <> "" then strTitle = element.windowCaption
	strTitle = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & strTitle
	objWindowCaption.innerHTML = strTitle
	on error goto 0
end sub

function coolWindowHandleDown
    with window.event
		if .srcElement is objWindowCaption or .srcElement is objCaptionImage then
			showMenu objMenu, .clientX, .clientY
			menuState = true
			.cancelBubble = true
			.returnValue = false
		end if
	end with
	coolWindowHandleDown = false
end function

function parentWindowOnMouseDown()
	dim el, clk
	if not window.event is nothing then
		with window.event
			set el = .srcElement
			if menuState then hideMenu
			if not el is nothing then
				if el.className = "coolMenuItem" then
					set clk = el.onclick
					if not clk is nothing then clk
					.returnValue = false
					.cancelBubble = true
				end if
			end if
		end with
	end if
	set el = nothing
	set clk = nothing
end function

function coolWindowOnMouseDown
	dim ev
	if menuState then hideMenu
	set ev = window.event
	if ev.srcElement is element then
		if ev.button = 1 and objResize.orgDirection <> "" then
			with objResize
				.inAction = true
				.orgX = ev.clientX
				.orgY = ev.clientY
				.orgTop = element.offsetTop
				.orgLeft = element.offsetLeft
				.orgHeight = element.offsetHeight
				.orgWidth = element.offsetWidth
			end with
			element.setCapture
			with ev
				.returnValue = false
				.cancelBubble = true
			end with
		end if
	end if
	set ev = nothing
end function

function coolWindowOnMouseUp
	if objResize.inAction then
		objResize.inAction = false
		element.releaseCapture
	end if
end function

function coolWindowOnMouseMove
	dim strCursor, intX, intL, intY, intT, cliX, cliY, btnWidth
	if objDrag.inAction then exit function
	if objResize.inAction then
		btnWidth = objCloseButton.offsetWidth
		with window.event
			cliX = .clientX
			cliY = .clientY
			.returnValue = false
			.cancelBubble = true
		end with
		with objResize
			if instr(.orgDirection, "e") <> 0 then
				intX = cint(.orgWidth + cliX - .orgX)
				if intX < 60 then intX = 60
				element.style.width = cstr(intX) & "px"
				intX = intX - 8
				objCloseButton.style.left = cstr(intX - btnWidth) & "px"
				objMaxButton.style.left = cstr(objCloseButton.offsetLeft - btnWidth - 2) & "px"
				objMinButton.style.left = cstr(objMaxButton.offsetLeft - btnWidth) & "px"
				objContentWindow.style.width = cstr(intX) & "px"
			end if
			if instr(.orgDirection, "s") <> 0 then
				intY = cint(.orgHeight + cliY - .orgY)
				if intY < 60 then intY = 60
				element.style.height = cstr(intY) & "px"
				objContentWindow.style.height = cstr(intY - objWindowCaption.offsetHeight - 10) & "px"
			end if
			if instr(.orgDirection, "w") <> 0 then
				intX = cint(.orgWidth - cliX + .orgX)
				intL = cint(.orgLeft + cliX - .orgX)
				if intX < 60 then
					intX = 60
					intL = .orgLeft + .orgWidth - 60
				end if
				element.style.left = cstr(intL) & "px"
				element.style.width = cstr(intX) & "px"
				intX = intX - 8
				objCloseButton.style.left = cstr(intX - btnWidth) & "px"
				objMaxButton.style.left = cstr(objCloseButton.offsetLeft - btnWidth - 2) & "px"
				objMinButton.style.left = cstr(objMaxButton.offsetLeft - btnWidth) & "px"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -