【已解决】GUICtrlSetGraphic在显示窗口之后的绘图显示不出来?
本帖最后由 myloveqmx 于 2010-5-4 19:46 编辑在用GUICtrlSetGraphic绘图的时候,如果放在初始化窗口的时候可以显示(即放在:GUISetState(@SW_SHOW)之前),但如果绘图的语句放在这句的后面就显示不出来,不清楚是什么原因?#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Graphic1 = GUICtrlCreateGraphic(16, 16, 249, 183)
;GUICtrlSetGraphic($Graphic1, $GUI_GR_COLOR, 0xFF0000, 0x008000)
;GUICtrlSetGraphic($Graphic1, $GUI_GR_RECT, 14, 13, 217, 159)
$Button1 = GUICtrlCreateButton("画图", 48, 232, 97, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetGraphic($Graphic1, $GUI_GR_COLOR, 0xFF0000, 0x008000)
GUICtrlSetGraphic($Graphic1, $GUI_GR_RECT, 14, 13, 217, 159)
EndSwitch
WEnd 回复 1# myloveqmx
这种问题不知道为什么,好是要重画窗口才能显示
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Graphic1 = GUICtrlCreateGraphic(16, 16, 249, 183)
;~ GUICtrlSetGraphic($Graphic1, $GUI_GR_COLOR, 0xFF0000, 0x008000)
;~ GUICtrlSetGraphic($Graphic1, $GUI_GR_RECT, 14, 13, 217, 159)
$Button1 = GUICtrlCreateButton("画图", 48, 232, 97, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetGraphic($Graphic1, $GUI_GR_COLOR, 0xFF0000, 0x008000)
GUICtrlSetGraphic($Graphic1, $GUI_GR_RECT, 14, 13, 217, 159)
GUISetState (@SW_HIDE,$Form1)
GUISetState (@SW_SHOW,$Form1)
EndSwitch
WEnd
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH) $GUI_GR_REFRESH可行的,不过这个控件有BUG,多用几次可能崩溃了 谢谢pusofalse ,问题解决
刚开始我想到的也是二楼的方法,不过窗口会闪烁
还有一个方法,就是设置Graphic的背景色即可刷新 学习~~~~~~
页:
[1]