Sign in to follow this  
Followers 0
Richard

text in GUICtrlCreateGraphic

7 posts in this topic

Is it possible to display text in a GUICtrlCreateGraphic control

without first creating a GUICtrlCreateLabel?

Richard

Share this post


Link to post
Share on other sites



I already did ,and there seems to be no(direct) way to print text in a graphic control.

So I tried with a label control - it displays - but the rest behind does not.

Try commenting out the GUICtrlCreateLabel line and the rest displays.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

$a = GUICreate("test GUICtrlCreateGraphic", 400, 400)
$x = GUICtrlCreateGraphic(0,0, 400, 400)
GUISetState(@SW_SHOW)

GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x4f00ff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 180, 180)
GUICtrlSetGraphic ( -1, $GUI_GR_REFRESH )  ; show what is drawn

GUICtrlCreateLabel("label", 125, 120, 30)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlSetGraphic ( $x, $GUI_GR_REFRESH )  ; show what is drawn
sleep(900)

GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 1)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000)  ; size before color
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 250, 150)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 250, 350)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 380, 350)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 350, 350)

GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 250, 2, 5)

GUICtrlSetGraphic ( -1, $GUI_GR_REFRESH )   ; show what is drawn

While 1
  $msg = GUIGetMsg()

  Select
      Case $msg = $GUI_EVENT_CLOSE
           ExitLoop
  EndSelect
WEnd

If you wish to know what you can do with a GUI graphic control, see in the help file this function: GUICtrlSetGraphic.

GUICtrlSetGraphic
(Click the blue link for the documentation.)

Share this post


Link to post
Share on other sites

I'm using Windows 7 and can't reproduce the issue, commenting the label or not. This means I can't give you a direct solution. I did find this helpful remark in the help file on GUICtrlCreateGraphic:

Graphic control can be clicked so they should not overlap with other controls. If overlap is needed it is important to disable the graphic control : GuiCtrlSetState(-1,$GUI_DISABLE).

I'll let someone else assist you further now.

Posted Image

Share this post


Link to post
Share on other sites

What do they mean by -can be clicked?

I'm using Windows 7 and can't reproduce the issue, commenting the label or not. This means I can't give you a direct solution. I did find this helpful remark in the help file on GUICtrlCreateGraphic:

Graphic control can be clicked so they should not overlap with other controls. If overlap is needed it is important to disable the graphic control : GuiCtrlSetState(-1,$GUI_DISABLE).

I'll let someone else assist you further now.

Posted Image

Share this post


Link to post
Share on other sites

That it registers a mouse click when you click your mouse on the control. It seems to conflict with control overlapping, and that's why the control should be disabled (so that it can't be clicked anymore.)

Share this post


Link to post
Share on other sites

I found the solution myself - see code.

the problem was using -1 as handle in the GUICtrlSetGraphic statements, which tried to apply the instructions

to the label control in stead of the graphics control.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

$a = GUICreate("test GUICtrlCreateGraphic", 400, 400)
$x = GUICtrlCreateGraphic(0,0, 400, 400)
GUISetState(@SW_SHOW)

GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x4f00ff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 180, 180)
GUICtrlSetGraphic ( -1, $GUI_GR_REFRESH )  ; show what is drawn

sleep(300)
GUICtrlCreateLabel("label", 125, 120, 30)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
sleep(300)
GUICtrlSetGraphic($x, $GUI_GR_PENSIZE, 1)
GUICtrlSetGraphic($x, $GUI_GR_COLOR, 0x000000)  ; size before color
GUICtrlSetGraphic($x, $GUI_GR_MOVE, 250, 150)
GUICtrlSetGraphic($x, $GUI_GR_LINE, 250, 350)
GUICtrlSetGraphic($x, $GUI_GR_LINE, 380, 350)
GUICtrlSetGraphic($x, $GUI_GR_MOVE, 350, 350)

GUICtrlSetGraphic($x, $GUI_GR_RECT, 350, 250, 2, 5)

GUICtrlSetGraphic ( $x, $GUI_GR_REFRESH )   ; show what is drawn


While 1
  $msg = GUIGetMsg()

  Select
      Case $msg = $GUI_EVENT_CLOSE
           ExitLoop
  EndSelect
WEnd

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  
Followers 0