新手学习中问个GUI的问题, 寻求帮助!!
新手学习中,今天想弄个GUI,上面加上button,可以工作,但为什么我加了背景图片后点button就没有反应了.贴上代码望高手指教#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
main( )
Func main ( )
Local $gui, $background, $pic, $msg,$qqbutton
#Region ### START Koda GUI section ### Form=
$gui = GUICreate("Entermainment", 400, 400)
; background picture
$background = GUICtrlCreatePic("D:\background.jpg", 0, 0, 400, 400)
$qqbutton = GUICtrlCreateButton("登陆", 80, 50, 90, 50,$WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(0, "", "Dialog minimized", 2)
Case $msg = $qqbutton
MsgBox(0, "Default button clicked","sucess")
EndSelect
WEnd
EndFunc 如果把" $background = GUICtrlCreatePic("D:\background.jpg", 0, 0, 400, 400)" 这行注释掉,button就可以点击.这是为什么?怎么解决。谢谢 GUICreate('Afan-图片背景按钮例子')
$Button1 = GUICtrlCreateButton('按钮', 150, 270, 100, 25)
GUICtrlCreatePic(RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & "\Examples\GUI\msoobe.jpg", 0, 0, 400, 400, 0x04000000)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
MsgBox(0, 0, 'ok')
EndSwitch
WEndafan以前帖子里的东西。。我留了一份 本帖最后由 lxz 于 2010-4-23 06:57 编辑
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
Local $gui, $background, $pic, $msg,$qqbutton
#Region ### START Koda GUI section ### Form=
$gui = GUICreate("Entermainment", 400, 400)
; background picture
$qqbutton = GUICtrlCreateButton("登陆", 80, 50, 90, 50)
$background = GUICtrlCreatePic("D:\background.jpg", 0, 0, 400, 400, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(0, "", "Dialog minimized", 2)
Case $msg = $qqbutton
MsgBox(0, "Default button clicked","sucess")
EndSelect
WEnd
本帖最后由 newuser 于 2010-4-23 08:58 编辑
回复 1# 想回到从前
注意GuiCtrlCreatePIC()的语法:
以下是我帮你找的帮助资料,希望你能理解,其实我也不很理解,跟着学习!$background = GUICtrlCreatePic("F:\儿子背景照片\080402069.jpg", 0, 0, 400, 400, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
;$SS_NOTIFY:使按钮发送 BN_KILLFOCUS(取消焦点) 与 BN_SETFOCUS(设置焦点) 通知消息到父窗口. 注意不论按钮是否有这个样式,都能发送 BN_CLICKED 单击通知消息.
;要获取 BN_DBLCLK 双击通知消息, 按钮必须有 BS_RADIOBUTTON 或 BS_OWNERDRAW 样式.
;$WS_GROUP:指定控件组的第一个控件.控件组由第一个控件和其后定义的所有控件组成,一直到下一个控件带有 WS_GROUP 样式为止.
;$WS_CLIPSIBLINGS:剪辑子窗口相互对齐; 也就是说, 当某一子窗口收到 WM_PAINT 消息时, 此样式将剪辑所有其他子窗口重叠区域
;并更新子窗口. 如果未指定子窗口重叠, 这是有可能的, 在需绘制客户区域子窗口时, 只绘制客户区域临近的子窗口.我的理解是他起了作用:
$SS_NOTIFY:使按钮发送 BN_KILLFOCUS(取消焦点) 与 BN_SETFOCUS(设置焦点) 通知消息到父窗口. 注意不论按钮是否有这个样式,都能发送 BN_CLICKED 单击通知消息.---按钮可以获得焦点,而如果背景PIC控件不这样设置,BUTTON控件就无法获得焦点,自然就无法响应! 只需要在第11行加入GUICtrlSetState(-1,$gui_DISABLE)即可#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
main( )
Func main ( )
Local $gui, $background, $pic, $msg,$qqbutton
#Region ### START Koda GUI section ### Form=
$gui = GUICreate("Entermainment", 400, 400)
; background picture
$background = GUICtrlCreatePic("D:\background.jpg", 0, 0, 400, 400)
GUICtrlSetState(-1,$gui_DISABLE)
$qqbutton = GUICtrlCreateButton("登陆", 80, 50, 90, 50,$WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(0, "", "Dialog minimized", 2)
Case $msg = $qqbutton
MsgBox(0, "Default button clicked","sucess")
EndSelect
WEnd
EndFunc 回复 1# 想回到从前
我觉得还是三笑的做法更容易理解:
GuiCtrlSetState(-1,$gui_DISABLE):-1本例指PIC控件,如果该行放到BUTTON控件下一行就是指
BUTTON,$gui_DISABLE是把控件变成灰色不可用。 超级感谢大家的帮助....呵呵谢谢:face (22): 回复 7# 想回到从前
那还不赶快[已解决] ,呵呵!
页:
[1]