找回密码
 加入
搜索
查看: 4398|回复: 5

[GUI管理] 【已解决】GUICtrlSetGraphic在显示窗口之后的绘图显示不出来?

  [复制链接]
发表于 2010-5-3 13:33:27 | 显示全部楼层 |阅读模式
本帖最后由 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金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-5-3 21:40:30 | 显示全部楼层
回复 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
发表于 2010-5-4 03:09:21 | 显示全部楼层
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
发表于 2010-5-4 16:47:10 | 显示全部楼层
$GUI_GR_REFRESH可行的,不过这个控件有BUG,多用几次可能崩溃了
 楼主| 发表于 2010-5-4 19:46:24 | 显示全部楼层
谢谢pusofalse ,问题解决
刚开始我想到的也是二楼的方法,不过窗口会闪烁
还有一个方法,就是设置Graphic的背景色即可刷新
发表于 2011-5-6 08:49:03 | 显示全部楼层
学习~~~~~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-8 04:48 , Processed in 0.079125 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表