本帖最后由 happytc 于 2011-5-3 08:12 编辑
下面的代码,利用附件的IconDock.au3文件,当Dock栏出来后,右键点击,想出来DockConfig()函数绘的窗口,结果出来个空窗口,比较奇怪的事,当把该函数中的下面语句去掉注释后,一切就正常了
;MsgBox(0,0,"0k")
现在我没有想出问题出在那里了
#include <GuiConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
#include "IconDock.au3"
HotKeySet("{ESC}", "_Exit")
Global $iIconSizeMin = 48
Global $iIconSizeMax = 96
Global $aIcon[8] = [7]
$aIcon[1] = @WindowsDir & "\explorer.exe"
$aIcon[2] = @SystemDir & "\taskmgr.exe"
$aIcon[3] = @SystemDir & "\write.exe"
$aIcon[4] = @SystemDir & "\notepad.exe"
$aIcon[5] = @SystemDir & "\osk.exe"
$aIcon[6] = @SystemDir & "\charmap.exe"
$aIcon[7] = @SystemDir & "\mspaint.exe"
Global $hIconDock = _IconDock_Create(0, @DesktopHeight - $iIconSizeMax - $iIconSizeMin, @DesktopWidth, $iIconSizeMax + $iIconSizeMin, BitOR($IconDock_Align_Horizontal, $IconDock_Center), $IconDock_Up, $iIconSizeMin, $iIconSizeMax, True)
_IconDock_BeginUpdate($hIconDock)
For $i = 1 To $aIcon[0]
_IconDock_IconAddFile($hIconDock, $aIcon[$i], 0, "_EventFunction", $IconDock_RBUTTONDOWN)
Next
_IconDock_EndUpdate($hIconDock)
While 1
Sleep(100)
WEnd
Func _EventFunction($hID, $iIconIndex, $iEventMsg)
Switch $hID
Case $hIconDock
Switch $iEventMsg
Case $IconDock_RBUTTONDOWN
Local $moved = DockMoveBar($hIconDock)
If $moved = False Then ; If $moved = true the bar was moved - don't open options.
DockConfig()
EndIf
EndSwitch
EndSwitch
EndFunc
Func DockConfig()
Local $hwdDock, $HRadio, $VRadio, $OKButton, $CancelButton, $msg
$hwdDock = GUICreate("Dock Config", 280, 150)
GUICtrlCreateLabel("IconSizeMin:", 10, 13, 80, 20)
GUICtrlCreateLabel("IconSizeMax:", 10, 43, 80, 20)
GUICtrlCreateLabel("Orientation:", 10, 83, 80, 20)
$HRadio = GUICtrlCreateRadio("Horizontal", 100, 80, 100, 20)
$VRadio = GUICtrlCreateRadio("Vertical", 200, 80, 100, 20)
$OKButton = GUICtrlCreateButton("OK", 50, 120, 50, 20)
$CancelButton = GUICtrlCreateButton("Cancel", 160, 120, 50, 20)
GUISetState()
;MsgBox(0,0,"0k")
While True
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE, $CancelButton
ExitLoop
Case $OKButton
MsgBox(0,"pressed", "Pressed OK Button")
ExitLoop
EndSwitch
Sleep(20)
WEnd
GUIDelete($hwdDock)
EndFunc
Func DockMoveBar($hwdGuiBar)
Local $PosDiff[2], $WinPos, $WinPos2, $MousePos, $dll, $moved
$dll = DllOpen("user32.dll")
While 1
$MousePos = MouseGetPos()
$WinPos = WinGetPos($hwdGuiBar)
$PosDiff[0] = $WinPos[0] - $MousePos[0]
$PosDiff[1] = $WinPos[1] - $MousePos[1]
While _IsPressed("02", $dll)
$MousePos = MouseGetPos()
WinMove($hwdGuiBar, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
WEnd
Sleep(10)
ExitLoop
WEnd
$WinPos2 = WinGetPos($hwdGuiBar, "")
If ($WinPos[0] < $WinPos2[0] - 3) Or ($WinPos[1] < $WinPos2[1] - 3) Or ($WinPos[0] > $WinPos2[0] + 3) Or ($WinPos[1] > $WinPos2[1] + 3) Then
$moved = True ; If the window was moved, don't run program on return.
Else
$moved = False
EndIf
Sleep(10)
Return $moved
EndFunc
Func _Exit()
_IconDock_Destroy($hIconDock)
Exit
EndFunc
|