[已解决]应用Checkbox上的一点麻烦
本帖最后由 lancaogen1999 于 2010-4-14 20:17 编辑下面一段代码运行后料表3和料表4都会不停的闪烁,
如果加了sleep语句之后程序会反应迟钝,是不是我的用法不对,
请问各位大大这个问题怎么解决,谢谢啦!
#include <Excel.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("料表转换v2.0 by slowly.liu & yf.bai", 625, 443, 192, 124)
GUICtrlCreateLabel("请选择料表:", 64, 40, 150, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表1", 64, 88, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表2", 64, 144, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox2 = GUICtrlCreateCheckbox("料表4", 45, 256, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox1= GUICtrlCreateCheckbox("料表3", 45, 200, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Inputlb1 = GUICtrlCreateInput("", 170, 88, 321, 25)
$Inputlb2 = GUICtrlCreateInput("", 170, 144, 321, 25)
$Inputlb3 = GUICtrlCreateInput("", 170, 200, 321, 25)
$Inputlb4 = GUICtrlCreateInput("", 170, 256, 321, 25)
$Button1 = GUICtrlCreateButton("浏览", 536, 88, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("浏览", 536, 144, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("浏览", 536, 200, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button4 = GUICtrlCreateButton("浏览", 536, 256, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$OK = GUICtrlCreateButton("转换", 128, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
$Exit = GUICtrlCreateButton("退出", 376, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
If GUICtrlRead($Checkbox1)=$GUI_UNCHECKED Then
GUICtrlSetState($Inputlb3,$GUI_DISABLE)
GUICtrlSetState($Button3,$GUI_DISABLE)
GUICtrlSetState($Inputlb4,$GUI_DISABLE)
GUICtrlSetState($Button4,$GUI_DISABLE)
Else
GUICtrlSetState($Inputlb3,$GUI_ENABLE)
GUICtrlSetState($Button3,$GUI_ENABLE)
EndIf
If GUICtrlRead($Checkbox2)=$GUI_UNCHECKED Then
GUICtrlSetState($Inputlb4,$GUI_DISABLE)
GUICtrlSetState($Button4,$GUI_DISABLE)
Else
GUICtrlSetState($Inputlb3,$GUI_ENABLE)
GUICtrlSetState($Button3,$GUI_ENABLE)
GUICtrlSetState($Inputlb4,$GUI_ENABLE)
GUICtrlSetState($Button4,$GUI_ENABLE)
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Exit
Exit
Case $Button1
$var1 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
GUICtrlSetData($Inputlb1,$var1)
$lb1=_ExcelBookOpen($var1)
$gs= _ExcelBookOpen(@ScriptDir & "\Α.bak")
Case $Button2
$var2 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
Case $Button3
$var3 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
Case $Button4
$var4 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
EndSwitch
WEnd 为什么没人回复呢?是我的问题太简单了吗? #include <Excel.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("料表转换v2.0 by slowly.liu & yf.bai", 625, 443, 192, 124)
GUICtrlCreateLabel("请选择料表:", 64, 40, 150, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表1", 64, 88, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表2", 64, 144, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox2 = GUICtrlCreateCheckbox("料表4", 45, 256, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox1 = GUICtrlCreateCheckbox("料表3", 45, 200, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Inputlb1 = GUICtrlCreateInput("", 170, 88, 321, 25)
$Inputlb2 = GUICtrlCreateInput("", 170, 144, 321, 25)
$Inputlb3 = GUICtrlCreateInput("", 170, 200, 321, 25)
$Inputlb4 = GUICtrlCreateInput("", 170, 256, 321, 25)
$Button1 = GUICtrlCreateButton("浏览", 536, 88, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("浏览", 536, 144, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("浏览", 536, 200, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button4 = GUICtrlCreateButton("浏览", 536, 256, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$OK = GUICtrlCreateButton("转换", 128, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
$Exit = GUICtrlCreateButton("退出", 376, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlSetState($Inputlb3, $GUI_DISABLE)
GUICtrlSetState($Button3, $GUI_DISABLE)
GUICtrlSetState($Inputlb4, $GUI_DISABLE)
GUICtrlSetState($Button4, $GUI_DISABLE)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Exit
Exit
Case $Checkbox1
If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then
GUICtrlSetState($Inputlb3, $GUI_DISABLE)
GUICtrlSetState($Button3, $GUI_DISABLE)
Else
GUICtrlSetState($Inputlb3, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
Case $Checkbox2
If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED Then
GUICtrlSetState($Inputlb4, $GUI_DISABLE)
GUICtrlSetState($Button4, $GUI_DISABLE)
Else
GUICtrlSetState($Inputlb4, $GUI_ENABLE)
GUICtrlSetState($Button4, $GUI_ENABLE)
EndIf
Case $Button1
$var1 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
GUICtrlSetData($Inputlb1, $var1)
$lb1 = _ExcelBookOpen($var1)
$gs = _ExcelBookOpen(@ScriptDir & "\Α.bak")
Case $Button2
$var2 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
Case $Button3
$var3 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
Case $Button4
$var4 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
If @error Then
ExitLoop
EndIf
EndSwitch
WEnd 好长哦,看着头有点大了。 谢谢afan,我有点朦胧的明白了。:face (33):
页:
[1]