Jump to content
Sign in to follow this  
scila1996

How to create a GUI Button as this ?

Recommended Posts

scila1996

Hi everyone 

 
I have one simple button GUIDE like this Image.
 

post-84392-0-41040400-1392651336_thumb.g

 

how to create one like this GUIDE.

Share this post


Link to post
Share on other sites
Melba23

scila1996,

In much the same way as the code I posted in your last thread: ;)

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

Opt("GuiOnEventMode", 1)

Global $fHover = False

$hGUI = GUICreate("AForm1", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$cLabel = GUICtrlCreateLabel("Button", 80, 80, 40, 40, BitOr($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetOnEvent($cLabel, "_Pressed")
GUICtrlSetBkColor($cLabel, 0xFFFFFF)

GUISetState()

While 1
    Sleep(10)
    $aCInfo = GUIGetCursorInfo($hGUI)
    If $aCInfo[4] = $cLabel And $fHover = False Then
        $fHover = True
        GUICtrlSetBkColor($cLabel, 0xCCCCFF)
    ElseIf $aCInfo[4] <> $cLabel And $fHover = True Then
        $fHover = False
        GUICtrlSetBkColor($cLabel, 0xFFFFFF)
    EndIf
WEnd

Func _Pressed()
    MsgBox($MB_SYSTEMMODAL, "Hi", "Pressed")
EndFunc

Func _Exit()
    Exit
EndFunc
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
scila1996

Thank M23 !
 
I have one small problem 
I created the following 1 GUILD 
 
When you move your mouse on the Run icon (shell32.dll, 25) 
 
---> Let's make this icon does not border the outside and white instead of blue background labels
 
post-84392-0-32944900-1392817424_thumb.p
 
remove white space around the logo Run
 

#include <GUIConstants.au3>

Opt("GuiOnEventMode", 1)
Global $l2
Global $taomoi = False
$Form1 = GUICreate("AForm1", 308, 193, 193, 115)
Global $testmau = GUICtrlCreateLabel("", 40, 80, 123, 50)
Global $Label2 = GUICtrlCreateLabel("Tray", 88, 85, 43, 50)
Global $Icon1 = GUICtrlCreateIcon("shell32.dll", 25, 48, 85, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)


GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

While 1
    Sleep(10)
        $aCInfo = GUIGetCursorInfo($Form1)
    If $aCInfo[4] = $Icon1 And $taomoi = False Then
        $taomoi = True
        GUICtrlSetStyle($testmau, $WS_BORDER, "")
        GUICtrlSetBkColor($testmau ,0x24DBD1)
        GUICtrlSetBkColor($Icon1, 0x24DBD1)
        GUICtrlSetBkColor($Label2, 0x24DBD1)
    ElseIf $aCInfo[4] <> $Icon1 And $taomoi = True Then
        $taomoi = False
        GUICtrlSetStyle($testmau, "", "")
        GUICtrlSetBkColor($testmau , Default)
        GUICtrlSetBkColor($Icon1, Default)
        GUICtrlSetBkColor($Label2, Default)
   EndIf
WEnd

Func _Exit()
    Exit
EndFunc
Edited by scila1996

Share this post


Link to post
Share on other sites
Melba23

scila1996,

Just make the $Label2 fit within $testmau - and if you set its background as transparent then you remove the need to colour it all: ;)

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

Opt("GuiOnEventMode", 1)

Global $taomoi = False

$Form1 = GUICreate("AForm1", 308, 193, 193, 115)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

Global $testmau = GUICtrlCreateLabel("", 40, 80, 123, 45)
Global $Label2 = GUICtrlCreateLabel("Tray", 88, 85, 43, 30) ; <<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetBkColor($Label2, $GUI_BKCOLOR_TRANSPARENT)        ; <<<<<<<<<<<<<<<<<<<<<<
Global $Icon1 = GUICtrlCreateIcon("shell32.dll", 25, 48, 85, 32, 32)

GUISetState(@SW_SHOW)

While 1
    Sleep(10)
        $aCInfo = GUIGetCursorInfo($Form1)
    If $aCInfo[4] = $Icon1 And $taomoi = False Then
        $taomoi = True
        GUICtrlSetStyle($testmau, $WS_BORDER, "")
        GUICtrlSetBkColor($testmau ,0x24DBD1)
    ElseIf $aCInfo[4] <> $Icon1 And $taomoi = True Then
        $taomoi = False
        GUICtrlSetStyle($testmau, "", "")
        GUICtrlSetBkColor($testmau , Default)
   EndIf
WEnd

Func _Exit()
    Exit
EndFunc
But I have no idea how to make the icon background transparent - and you cannot set the colour using GUICtrlSetBkColor. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
scila1996

Please do bother you a little bit more

:shifty:

post-84392-0-67363400-1392819994_thumb.p

 

How to Create ...

Edited by scila1996

Share this post


Link to post
Share on other sites
FireFox

Hi,
AFAIK, the GUICtrlCreateIcon does not handle transparency.
 
You can use the Icons UDF associated with CreatePic, which does the trick :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Icons.au3> ;http://www.autoitscript.com/forum/topic/92675-icons-udf/
 
Opt("GuiOnEventMode", 1)
 
Global $taomoi = False
 
$Form1 = GUICreate("AForm1", 308, 193, 193, 115)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
 
Global $testmau = GUICtrlCreateLabel("", 40, 80, 123, 45)
Global $Label2 = GUICtrlCreateLabel("Tray", 88, 85, 43, 30) ; <<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetBkColor($Label2, $GUI_BKCOLOR_TRANSPARENT) ; <<<<<<<<<<<<<<<<<<<<<<
;Global $Icon1 = GUICtrlCreateIcon("shell32.dll", 25, 48, 85, 32, 32)
 
Global $Icon1 = GUICtrlCreatePic('', 48, 85, 32, 32)
$hIcon = _Icons_Icon_Extract(@SystemDir & '\shell32.dll', 25 - 1, 32, 32)
$hBitmap = _Icons_Bitmap_CreateFromIcon($hIcon)
_SetHImage($Icon1, $hBitmap)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DestroyIcon($hIcon)
 
GUISetState(@SW_SHOW)
 
While 1
    Sleep(10)
    $aCInfo = GUIGetCursorInfo($Form1)
    If $aCInfo[4] = $Icon1 And $taomoi = False Then
        $taomoi = True
        GUICtrlSetStyle($testmau, $WS_BORDER, "")
        GUICtrlSetBkColor($testmau, 0x24DBD1)
    ElseIf $aCInfo[4] <> $Icon1 And $taomoi = True Then
        $taomoi = False
        GUICtrlSetStyle($testmau, "", "")
        GUICtrlSetBkColor($testmau, Default)
    EndIf
WEnd
 
Func _Exit()
    Exit
EndFunc   ;==>_Exit

_

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
scila1996
thank you ff 
 
It is perfect and to my liking 
 
Can you help me create buttons and icons are not shown in Figure
 
:thumbsup:

Share this post


Link to post
Share on other sites
FireFox

It's almost the same button as before, can you show us what you've tried so far ?


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
scila1996

It's almost the same button as before, can you show us what you've tried so far ?

 

Share this post


Link to post
Share on other sites
FireFox

You are not answering my question :(


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
scila1996
Sorry FF 
 
I want to create buttons and icons included in this document as
 
 
post-84392-0-42347400-1392825656_thumb.p

Share this post


Link to post
Share on other sites
FireFox

Then _GUICtrlButton_SetImage is what you need ;)

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Melba23

scila1996,

And here is an example of how it is used: :)

#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>

_Main()

Func _Main()

    Local $sAutoIt_Path = StringReplace(@AutoItExe, "AutoIt3.exe", "")
    ConsoleWrite($sAutoIt_Path & @CRLF)

    Local $sGreen = $sAutoIt_Path & "Examples\GUI\Advanced\Images\Green.bmp"
    Local $sBlue = $sAutoIt_Path & "Examples\GUI\Advanced\Images\Blue.bmp"
    Local $sRed = $sAutoIt_Path & "Examples\GUI\Advanced\Images\Red.bmp"
    Local $sIcon1 = $sAutoIt_Path & "Icons\au3.ico"
    Local $sIcon2 = $sAutoIt_Path & "Icons\au3script_v10.ico"
    Local $btn1, $btn2, $btn3, $btn4, $msg
    Local $hImagebtn1, $hImagebtn2, $hImagebtn3, $hImagebtn4
    Local $label1

    ;Caveat: Minimum Operating Systems: Windows XP

    Local $hGUI = GUICreate("Button Imagelists", 500, 300)

    $label1 = GUICtrlCreateLabel("", 150, 30, 340, 250)
    GUICtrlSetFont(-1, 12)

    $msg = "The 'Changer' button shows what can be done.  " & @CRLF
    $msg &= "It displays Blue normally," & @CRLF
    $msg &= "but changes to Red when the cursor is over it. " & @CRLF
    $msg &= "Pressing changes it to Green." & @CRLF
    $msg &= "When disabled it shows Red, " & @CRLF
    $msg &= "and when focused (use the Tab key)" & @CRLF
    $msg &= "it switches between 2 icons."
    GUICtrlSetData($label1, $msg)

    ;multi state image Bitmap
    $btn1 = GUICtrlCreateButton("Changer", 30, 30, 90, 32)
    GUICtrlSetTip(-1, "Multi state bitmap imagelist")
    $hImagebtn1 = _GUIImageList_Create(24, 24, 5, 5)
    _GUIImageList_AddBitmap($hImagebtn1, $sBlue)  ;1 - Normal
    _GUIImageList_AddBitmap($hImagebtn1, $sRed)   ;2 - Hot
    _GUIImageList_AddBitmap($hImagebtn1, $sGreen) ;3 - Pressed
    _GUIImageList_AddBitmap($hImagebtn1, $sRed)   ;4 - Disabled
    _GUIImageList_AddIcon($hImagebtn1, $sIcon1)   ;5 - Focus Switch - possibly Vista only for the switch
    _GUIImageList_AddIcon($hImagebtn1, $sIcon2)   ;6 - Focus Switch
    _GUICtrlButton_SetImageList($btn1, $hImagebtn1)

    ;single state image Bitmap
    $btn2 = GUICtrlCreateButton("Disable", 30, 70, 90, 32)
    GUICtrlSetTip(-1, "Single bitmap imagelist")
    $hImagebtn2 = _GUIImageList_Create(24, 24, 5, 3)
    _GUIImageList_AddBitmap($hImagebtn2, $sRed);1 - Normal
    _GUICtrlButton_SetImageList($btn2, $hImagebtn2)

    ;single state image Icon
    $btn3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40)
    GUICtrlSetTip(-1, "Single icon imagelist")
    $hImagebtn3 = _GUIImageList_Create(32, 32, 5, 3)
    _GUIImageList_AddIcon($hImagebtn3, "shell32.dll", 47, True)
    _GUICtrlButton_SetImageList($btn3, $hImagebtn3)

    ;single state image Bitmap with overlay text
    $btn4 = GUICtrlCreateButton("Help", 30, 160, 90, 32)
    GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text")
    GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS")
    $hImagebtn4 = _GUIImageList_Create(90, 32, 5, 3)
    _GUIImageList_AddBitmap($hImagebtn4, $sRed)
    _GUICtrlButton_SetImageList($btn4, $hImagebtn4, 4)

    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $btn1
                GUICtrlSetState($btn4, $GUI_FOCUS)
            Case $btn2
                GUICtrlSetState($btn1, $GUI_DISABLE)
            Case $btn3
                GUICtrlSetState($btn1, $GUI_ENABLE)
            Case $btn4
                MsgBox(0, "", "Hi!")
        EndSwitch
    WEnd
EndFunc   ;==>_Main
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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.