Jump to content

Trying to use GUICtrlSetTip with GUICtrlCreateGraphic


Recommended Posts

I am using GUICtrlCreateGraphic to create a box, then setting the box background to red or green to show a status. I will have many of these, and would like to use GUICtrlSetTip to allow a popup tip explaining the item description. I've done this using gifs, but would rather use graphic as it appears faster and as functional as I need. Only problem is I don't get the tip popup on the graphic box. I've tried with and without $GUI_Disable as seen on Bit[0] Can't figure out what's going on. Any ideas?

#include <StaticConstants.au3>
#include <GUIConstants.au3>
$Form1 = GUICreate("BitTest", 618, 148, 193, 125)
GUISetBkColor(0xFFFFFF)
Dim $BitBox[8]
$BitBox[0] = GUICtrlCreateGraphic(270, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor($BitBox[0], 0x00ff00)
GUICtrlSetState($BitBox[0],$GUI_Disable)
GUICtrlSetTip($BitBox[0], " ","Bit-0",2,1)
$BitBox[1] = GUICtrlCreateGraphic(290, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip($BitBox[1], " ","Bit-1",2,1)
$BitBox[2] = GUICtrlCreateGraphic(310, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip($BitBox[2], " ","Bit-2",1,1)
$BitBox[3] = GUICtrlCreateGraphic(330, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip($BitBox[3], " ","Bit-3",2,1)
$BitBox[4] = GUICtrlCreateGraphic(350, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip($BitBox[4], "Bit-4",1,1)
$BitBox[5] = GUICtrlCreateGraphic(370, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip($BitBox[5], "Bit-5",1,1)
$BitBox[6] = GUICtrlCreateGraphic(390, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip($BitBox[6], "Bit-6",1,1)
$BitBox[7] = GUICtrlCreateGraphic(410, 120, 20, 20,$SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip($BitBox[7], "Bit-7",13,1)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd
Link to comment
Share on other sites

By giving the graphic the style $SS_SUNKEN you are giving it that style alone and removing the default styles.

Try setting the style to

BitOr($SS_NOTIFY, $SS_SUNKEN)

If you need to disable the graphics then the tooltips won't show but here is one way you could still show tooltips

#include <StaticConstants.au3>
#include <GUIConstants.au3>
#include <windowsconstants.au3>

Global Const $WM_MOUSEMOVE = 0x0200
Global $lastShowtip = -1
$Form1 = GUICreate("BitTest", 618, 148, 193, 125)
GUISetBkColor(0xFFFFFF)
Dim $BitBox[8]
$BitBox[0] = GUICtrlCreateGraphic(270, 120, 20, 20, $SS_SUNKEN)
GUICtrlSetBkColor($BitBox[0], 0x00ff00)
GUICtrlSetState(-1, $GUI_Disable)
$BitBox[1] = GUICtrlCreateGraphic(290, 120, 20, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip(-1,"Bit-1")
GUICtrlSetState(-1,$GUI_Disable)
$BitBox[2] = GUICtrlCreateGraphic(310, 120, 20, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
$BitBox[3] = GUICtrlCreateGraphic(330, 120, 20, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetState(-1,$GUI_Disable)
$BitBox[4] = GUICtrlCreateGraphic(350, 120, 20, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
$BitBox[5] = GUICtrlCreateGraphic(370, 120, 20, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
$BitBox[6] = GUICtrlCreateGraphic(390, 120, 20, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1, 0x00ff00)
$BitBox[7] = GUICtrlCreateGraphic(410, 120, 20, 20,BitOr($SS_NOTIFY, $SS_SUNKEN))
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetTip(-1,"bit-7")
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MOUSEMOVE
            checkmouseover()
    EndSwitch
WEnd


Func checkmouseover()
    Local $mp = GUIGetCursorInfo()
    Local $wp = WinGetPos($Form1)
    Local $showtip = -1
    For $n = 0 To 7
        If $mp[4] = $BitBox[$n] Then
            $showtip = $n
            ExitLoop
        EndIf       
    Next

    If $showtip <> $lastShowtip Then
        
        If $showtip <> -1 Then
            AdlibDisable()
            ToolTip("Bit-" & $showtip, $mp[0] + $wp[0], $mp[1] + $wp[1])
            AdlibEnable("killtip", 2000);however long you want the tooltip to show
        EndIf
        $lastShowtip = $showtip
    EndIf

EndFunc ;==>checkmouseover

Func killtip()
    ToolTip("")
    AdlibDisable()
EndFunc ;==>killtime
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Martin saves the day agian. It was in fact the missing $SS_NOTIFY causing the problem. I didn't notice adding a param would remove the defaults. I didn't need to disable the control, but thought it may have bearing on the non-display issue. I figured there would be a simple fix, just couldn't seem to see it. Thanks again!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...