Sign in to follow this  
Followers 0
NDog

Is GUICtrlSetTip with GUICtrlCreateGraphic possible?

3 posts in this topic

GUICtrlCreateGraphic and GUICtrlSetGraphic allow me to create a circle, change it to whatever color I like without using an external file.

I also however want a tip to appear when I hover the mouse over it as well, eg if it was red it would say red: file not found, or if green: file found etc.

This is what I would like to work, however it doesn't work

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)
$fmSNIP = GUICreate("Graphic Test", 790, 570, -1)
$picStatus = GUICtrlCreateGraphic(434, 549, 10, 10)
GUICtrlSetGraphic($picStatus,$GUI_GR_COLOR, 0x00FF00,0x00FF00) ;Green
GUICtrlSetGraphic($picStatus,$GUI_GR_ELLIPSE, 1,1, 8,8)
GUICtrlSetGraphic($picStatus,$GUI_GR_REFRESH)
GUICtrlSetTip(-1, "Green: Driver Exists")
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "FormClose") ; When the big X is clicked
While 1 ;On event mode GUI
    Sleep(100)
WEnd

Func FormClose()
    Exit
EndFunc

This is another way I have tried to use a label to get around it, however if you directly however over the graphic the tooltip does not appear.

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)
$fmSNIP = GUICreate("Graphic Test", 790, 570, -1)
$picStatus = GUICtrlCreateGraphic(434, 549, 10, 10)
$lbStatusLight = GUICtrlCreateLabel("", 425, 545, 220, 25)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "FormClose") ; When the big X is clicked
Status()
While 1 ;On event mode GUI
    Sleep(100)
WEnd
Func FormClose()
    Exit
EndFunc
Func Status()
$filepath = "c:\windows"
If FileExists($filepath) Then
GUICtrlSetGraphic($picStatus,$GUI_GR_COLOR, 0x00FF00,0x00FF00) ;Green
GUICtrlSetGraphic($picStatus,$GUI_GR_ELLIPSE, 1,1, 8,8)
GUICtrlSetGraphic($picStatus,$GUI_GR_REFRESH)
GUICtrlSetTip($lbStatusLight, "Green: Files exist")
ElseIf Not FileExists($filepath) Then
GUICtrlSetGraphic($picStatus,$GUI_GR_COLOR, 0xFF0000,0xFF0000) ;Red
GUICtrlSetGraphic($picStatus,$GUI_GR_ELLIPSE, 1,1, 8,8)
GUICtrlSetGraphic($picStatus,$GUI_GR_REFRESH)
GUICtrlSetTip($lbStatusLight, "Red: Files do not exist")
EndIf
EndFunc

I hope someone can help me :)

Thanks

Share this post


Link to post
Share on other sites



Create the label before the graphic

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
$fmSNIP = GUICreate("Graphic Test", 790, 570, -1)
$lbStatusLight = GUICtrlCreateLabel("", 425, 545, 220, 25)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$picStatus = GUICtrlCreateGraphic(434, 549, 10, 10)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "FormClose") ; When the big X is clicked
Status()
While 1 ;On event mode GUI
 Sleep(100)
WEnd
Func FormClose()
 Exit
EndFunc   ;==>FormClose
Func Status()
 $filepath = "c:windows"
 If FileExists($filepath) Then
  GUICtrlSetGraphic($picStatus, $GUI_GR_COLOR, 0x00FF00, 0x00FF00) ;Green
  GUICtrlSetGraphic($picStatus, $GUI_GR_ELLIPSE, 1, 1, 8, 8)
  GUICtrlSetGraphic($picStatus, $GUI_GR_REFRESH)
  GUICtrlSetTip($lbStatusLight, "Green: Files exist")
 ElseIf Not FileExists($filepath) Then
  GUICtrlSetGraphic($picStatus, $GUI_GR_COLOR, 0xFF0000, 0xFF0000) ;Red
  GUICtrlSetGraphic($picStatus, $GUI_GR_ELLIPSE, 1, 1, 8, 8)
  GUICtrlSetGraphic($picStatus, $GUI_GR_REFRESH)
  GUICtrlSetTip($lbStatusLight, "Red: Files do not exist")
 EndIf
EndFunc   ;==>Status

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Or you could do something like:

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
$fmSNIP = GUICreate("Graphic Test", 790, 570, -1)
$picStatus = GUICtrlCreateGraphic(434, 549, 10, 10)
GUICtrlSetGraphic($picStatus,$GUI_GR_COLOR, 0x00FF00,0x00FF00) ;Green
GUICtrlSetGraphic($picStatus,$GUI_GR_ELLIPSE, 1,1, 8,8)
GUICtrlSetGraphic($picStatus,$GUI_GR_REFRESH)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "FormClose") ; When the big X is clicked
While 1 ;On event mode GUI
$pos = GUIGetCursorInfo($fmSNIP)
While ($pos[0] >= 434 And $pos[0] <= 444) And ($pos[1] >= 549 And $pos[1] <= 559)
  $newPos = GUIGetCursorInfo()
  If $newPos[0] <> $pos[0] Or $newPos[1] <> $pos[1] Then
   ToolTip("Green: Driver Exists")
   $pos[0] = $newPos[0]
   $pos[1] = $newPos[1]
  EndIf
  Sleep(50)
WEnd
ToolTip("")
Sleep(50)
WEnd
Func FormClose()
    Exit
EndFunc

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