Jump to content

Help with creating icon button...


Madza91
 Share

Recommended Posts

Hello, i want to made button with icon, but to be something like toolbar button...

To made one icon and when over it with cursor to show button behind that icon...

i maded this but bugged... i need help to fix that...

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$GUI = GUICreate("My GUI")
$ic = GUICtrlCreateIcon(@ScriptDir & "\asd.ico", -1, 120, 120, 16, 16)
GUICtrlSetState(-1, $GUI_DISABLE)
$b = GUICtrlCreateButton("", 116, 116, 24, 24, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1,$GUI_HIDE)
$Label1 = GUICtrlCreateLabel("0", 88, 24, 36, 17)
GUISetState()

While 1
    $m = GUIGetMsg()
    If $m = -3 then Exit
    $c = GUIGetCursorInfo($GUI)
    If $c[4] = $ic Then
        If BitAND(GUICtrlGetState($B), $GUI_HIDE ) = $GUI_HIDE Then
        GUICtrlSetState($b, $GUI_SHOW)
        GUICtrlSetData($Label1,Random(100,200,1))
        EndIf
    Sleep(100)
        $c = GUIGetCursorInfo($GUI)
            While $c[4] = $b
                If GUIGetMsg() = $b Then Do_Function()
                $c = GUIGetCursorInfo($GUI)
            WEnd
        GUICtrlSetState( $b, $GUI_HIDE)
    EndIf
WEnd

Func Do_Function()
    MsgBox(0x0, "tset", "OK.....    ", 3)
EndFunc

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

I know for that, but its ugly :P

Pls help with this ;/

Edited by n3nE

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

$Btn_Fav = GUICtrlCreateButtonWithIcon("&Favorites", 5, $Top, 65, 65, 44, "shell32.dll", $GUI_DOCKALL + $GUI_DOCKVCENTER)

Func GUICtrlCreateButtonWithIcon($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum, $BIDLL = "shell32.dll", $BIresizing = -1, $BIstyle = 0)
Local $XS_btnx
    GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + 5, 16, 16)
    If $BIresizing > -1 Then GUICtrlSetResizing(-1, $BIresizing) ; $GUI_DOCKALL + $GUI_DOCKVCENTER)
    GUICtrlSetState( -1, $GUI_DISABLE)
    $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS)
    If $BIresizing > -1 Then GUICtrlSetResizing(-1, $BIresizing)
    Return $XS_btnx
EndFunc

I know for that, but its ugly :P

Pls help with this ;/

Link to comment
Share on other sites

Oh, i want to be hiden that button and when set cursor over icon to show button...

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

Oh, i want to be hiden that button and when set cursor over icon to show button...

I think you have to remember that when the cursor is over the button the id of the control under the cursor could be the button or the icon.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$GUI = GUICreate("My GUI")
$ic = GUICtrlCreateIcon(@ScriptDir & "\\asd.ico", -1, 120, 120, 16, 16)
GUICtrlSetState(-1, $GUI_DISABLE)
$b = GUICtrlCreateButton("", 116, 116, 24, 24, $WS_CLIPSIBLINGS)
GUICtrlSetState(-1, $GUI_HIDE)
$Label1 = GUICtrlCreateLabel("0", 88, 24, 36, 17)
GUISetState()
$state1 = False
While 1
    $m = GUIGetMsg()
    If $m = -3 Then Exit
    checkbutton()
    
WEnd

Func Do_Function()
    MsgBox(0x0, "tset", "OK.....    ", 3)
EndFunc  ;==>Do_Function

Func checkbutton()
    
$c = GUIGetCursorInfo($GUI)
    If $c[4] = $ic or $c[4] = $ic Then
        If BitAND(GUICtrlGetState($b), $GUI_HIDE) = $GUI_HIDE Then
            GUICtrlSetState($b, $GUI_SHOW)
            GUICtrlSetData($Label1, Random(100, 200, 1))
            
        EndIf
        $c = GUIGetCursorInfo($GUI)
        While $c[4] = $b or $c[4] = $ic
            $msg = GUIGetMsg() 
            if $msg = $b or $msg = $ic Then Do_Function()
            $c = GUIGetCursorInfo($GUI)
        WEnd
    Else
        If BitAND(GUICtrlGetState($b), $GUI_SHOW) = $GUI_SHOW Then
        GUICtrlSetState($b, $GUI_HIDE)
        EndIf
        Sleep(100)
        
        
    EndIf   
EndFunc
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

Oh yes... ;/

Thank you, you are very helpful : )))

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

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...