Jump to content
Sign in to follow this  
polihale

GUICtrlCreatePic refresh issue

Recommended Posts

polihale

Hi everyone,

This is my first post. I've been using AutoIt for two years and never needed support until now (a credit to the authors). Glad I found this forum; didn't know until today it existed.

My issue is refreshing images that were created with GUICtrlCreatePic. I've search this site for an answer and found lots of related issues, but I still don't know what's going on.

I use GUICtrlCreatePic to draw an image. It works. Later on, I re-draw a new image over the old one, again using GUICtrlCreatePic. But the new image doesn't appear. If I minimize the application and then maximize it (forcing Windows XP to refresh it), the proper image appears.

How do I tell Windows to forcibly refresh the GUI?

Here is the .AU3 file along with some images for testing: test.zip package

I'm sure it's something simple. Thanks for the help.

Christopher

Share this post


Link to post
Share on other sites
GaryFrost

#include <GUIConstants.au3>
GUICreate("Test",300,150,10,10)

$ChangeButton = GuiCtrlCreateButton("Change Color",50, 50, 125, 33)
$PanelColor = 1
$pic = GUICtrlCreatePic("",210,50,50,50)

GUISetState()

While 1
   $MSG = GUIGetMsg()
   Select

      Case $MSG = $GUI_EVENT_CLOSE
         Exit

      Case $MSG = $ChangeButton
          $PanelColor = $PanelColor + 1
          if $PanelColor = 4 then $PanelColor = 1
          if $PanelColor = 1 then
             GUICtrlSetImage($pic, @ScriptDir & "\red.jpg")
             GUICtrlCreateLabel('Red  ',220,110)
          endif
          if $PanelColor = 2 then
             GUICtrlSetImage($pic, @ScriptDir & "\grey.jpg")
             GUICtrlCreateLabel('Grey  ',220,110)
          endif
          if $PanelColor = 3 then
             GUICtrlSetImage($pic, @ScriptDir & "\yellow.jpg")
             GUICtrlCreateLabel('Yellow',220,110)
          endif

   EndSelect
Wend


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
jpm

#include <GUIConstants.au3>
GUICreate("Test",300,150,10,10)

$ChangeButton = GuiCtrlCreateButton("Change Color",50, 50, 125, 33)
$PanelColor = 1
           $pic=  GUICtrlCreatePic("red.jpg",210,50,50,50)

GUISetState()

While 1
   $MSG = GUIGetMsg()
   Select

      Case $MSG = $GUI_EVENT_CLOSE
         Exit

      Case $MSG = $ChangeButton
          $PanelColor = $PanelColor + 1
          if $PanelColor = 4 then $PanelColor = 1
          if $PanelColor = 1 then
             GUICtrlSetImage($pic,"red.jpg")
             GUICtrlCreateLabel('Red  ',220,110)
          endif
          if $PanelColor = 2 then
             GUICtrlSetImage($pic,"grey.jpg")
             GUICtrlCreateLabel('Grey  ',220,110)
          endif
          if $PanelColor = 3 then
             GUICtrlSetImage($pic,"yellow.jpg")
             GUICtrlCreateLabel('Yellow',220,110)
          endif

   EndSelect
Wend

You need to setimage not to recreate it :whistle:

Share this post


Link to post
Share on other sites
polihale

I figured it was something simple like that. Thanks. Works great now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.