Sign in to follow this  
Followers 0
HAL9000

TO BE OR NOT TO BE A NICE CHECKBOX

11 posts in this topic

#1 ·  Posted (edited)

check.ico

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

Local $msg, $x,$y,$z
$gui = GUICreate("TO BE OR NOT TO BE A NICE CHECKBOX") 
GUISetBkColor (0x0A659C)
GUICtrlCreateLabel ("Check or uncheck and click Run",10,12,200,30)
GUICtrlSetColor(-1, 0xe11cced)

$a = GUICtrlCreateGraphic(20, 50, 22, 22)
GUICtrlSetColor(-1, 0xe11cced)
$b = GUICtrlCreateIcon("check.ico","",23,52,16,16)
GUICtrlSetState( $b, $GUI_HIDE)
GUICtrlCreateLabel ("run regedit",50,52,100,30)
GUICtrlSetColor(-1, 0xe11cced)

$a1 = GUICtrlCreateGraphic(20, 80, 22, 22)
GUICtrlSetColor(-1, 0xe11cced)
$b1 = GUICtrlCreateIcon("check.ico","",23,82,16,16)
GUICtrlSetState( $b1, $GUI_HIDE)
GUICtrlCreateLabel ("run calc",50,82,100,30)
GUICtrlSetColor(-1, 0xe11cced)

$a2 = GUICtrlCreateGraphic(20, 110, 22, 22)
GUICtrlSetColor(-1, 0xe11cced)
$b2 = GUICtrlCreateIcon("check.ico","",23,112,16,16)
GUICtrlSetState( $b2, $GUI_HIDE)
GUICtrlCreateLabel ("run notepad",50,112,100,30)
GUICtrlSetColor(-1, 0xe11cced)

$run = GUICtrlCreateButton ("RUN",150,150,50,30)
GUICtrlSetColor(-1, 0x0A659C)

GUISetState(@SW_SHOW,$gui)
While 1
$msg = GUIGetMsg()

if $msg = $a then 
    $b = GUICtrlCreateIcon("check.ico","",23,52,16,16)
    GUICtrlSetState( $b, $GUI_ONTOP)
    $x =1
    endif
if $msg = $b then 
    GUICtrlSetColor(-1, 0xe11cced)
    GUICtrlDelete ( $b )
    $x =0
    endif
    
if $msg = $a1 then 
    $b1 = GUICtrlCreateIcon("check.ico","",23,82,16,16)
    GUICtrlSetState( $b1, $GUI_ONTOP)
    $y =1
    endif
if $msg = $b1 then 
    GUICtrlSetColor(-1, 0xe11cced)
    GUICtrlDelete ( $b1 )
    $y=0
    endif   

if $msg = $a2 then 
    $b2 = GUICtrlCreateIcon("check.ico","",23,112,16,16)
    GUICtrlSetState( $b2, $GUI_ONTOP)
    $z=1
    endif
if $msg = $b2 then 
    GUICtrlSetColor(-1, 0xe11cced)
    GUICtrlDelete ( $b2 )   
    $z=0
    endif

if $msg = $run and $x =1 then run ("regedit")
if $msg = $run and $y =1 then run ("calc")
if $msg = $run and $z =1 then run ("notepad")
If $msg = $GUI_EVENT_CLOSE Then Exit    
WEnd

check.ico

check.ico

Edited by HAL9000

Share this post


Link to post
Share on other sites



Very nice, I like the GUI...

Share this post


Link to post
Share on other sites

@HAL9000

I can't click on checkbox and the button run have some lines moving very fast like when you refresh it ....

Cheers, 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

#5 ·  Posted (edited)

@HAL9000

I can't click on checkbox and the button run have some lines moving very fast like when you refresh it ....

Cheers, FireFox.

perhaps you forgot to put the icon in the script directory

check.ico

http://www.megaupload.com/?d=1GFAGM6H

are you french?

mon français est pire que mon anglais

Edited by HAL9000

Share this post


Link to post
Share on other sites

@HAL9000

yep im french, ops forgot ico because I didnt see it... should be placed at top of topic :)

Looks nice :o

Cheers, 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

I like it, but why did you upload icon on megaupload?

It just only 14 kb

Attach it :)


Sorry 4 Bad English, I'm Indonesian...I'm really need 'Translator' for helping me posting in this forum (http://deeriee.wordpress.com)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@HAL9000

I liked this so much, I used UDFs to simplify the control creation and the logic of reading the check boxes

;original concept by HAL9000
;this version by ResNullius
;
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>


$gui = GUICreate("TO BE OR NOT TO BE A NICE CHECKBOX")
GUISetBkColor(0x0A659C)
GUICtrlCreateLabel("Check or uncheck and click Run", 10, 12, 200, 30)
GUICtrlSetColor(-1, 0xe11cced)
$a = _GuiCtrlIconCheckBox_Create("run regedit", 20, 50, 20, 20, "check.ico", 0xe11cced)

$b = _GuiCtrlIconCheckBox_Create("run calc", 20, 80, 20, 20, "check.ico", 0xe11cced)
_GuiCtrlIconCheckBox_SetFont($b, Default, 800, 3, "Courier")

$c = _GuiCtrlIconCheckBox_Create("run notepad", 20, 110, 20, 20, "check.ico")
_GuiCtrlIconCheckBox_SetFont($c, 30)

$d = _GuiCtrlIconCheckBox_Create("run paint", 20, 140, 40, 40, "check.ico")
_GuiCtrlIconCheckBox_SetFont($d, 20)

$run = GUICtrlCreateButton("RUN", 150, 180, 50, 30)
GUICtrlSetColor(-1, 0x0A659C)

GUISetState(@SW_SHOW, $gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $a, $b, $c, $d
            _IconCheckbox_Click($msg)
        Case $run
            If _IsIconCheckBox_Checked($a) Then Run("regedit")
            If _IsIconCheckBox_Checked($b) Then Run("calc")
            If _IsIconCheckBox_Checked($c) Then Run("notepad")
            If _IsIconCheckBox_Checked($d) Then Run("mspaint")
    EndSwitch

WEnd




Func _GuiCtrlIconCheckBox_Create($s_text, $i_left, $i_top, $i_width, $i_height, $s_iconFile, $i_color = Default)
    $h_tmpChk = GUICtrlCreateGraphic($i_left, $i_top, $i_width, $i_height)
    $h_tmpChkHidden = GUICtrlCreateCheckbox("", $i_left, $i_top)
    GUICtrlSetState(-1, $GUI_HIDE)
    $h_tmpIcon = GUICtrlCreateIcon($s_iconFile, "", $i_left + 3, $i_top + 2, $i_width - 6, $i_height - 6)
    GUICtrlSetState(-1, BitOR($GUI_HIDE, $GUI_DISABLE, $GUI_ONTOP))
    $h_tmpLabel = GUICtrlCreateLabel($s_text, $i_left + $i_width + 5, $i_top)
    _GuiCtrlIconCheckBox_SetFont($h_tmpChk)
    If $i_color = Default Then
        $i_color = _WinAPI_GetSysColor($COLOR_BTNTEXT)
    EndIf
    GUICtrlSetColor(-1, $i_color)
    GUICtrlSetColor($h_tmpChk, $i_color)
    Return $h_tmpChk
EndFunc ;==>_GuiCtrlIconCheckBox_Create


Func _GuiCtrlIconCheckBox_SetFont($h_tmpChk, $i_fontSize = Default, $i_fontWeight = Default, $i_fontAttribute = Default, $i_fontName = Default)
    $h_tmpLabel = $h_tmpChk + 3
    If $i_fontName = Default Then $i_fontName = ""
    GUICtrlSetFont($h_tmpLabel, $i_fontSize, $i_fontWeight, $i_fontAttribute, $i_fontName)
    $a_lblSize = _Control_GetTextSize($gui, "", GUICtrlGetHandle($h_tmpLabel))
    $a_chkPos = ControlGetPos($gui, "", GUICtrlGetHandle($h_tmpChk))
    $i_lblW = $a_lblSize[0]
    $i_lblH = $a_lblSize[1]
    $i_chkPosY = $a_chkPos[1]
    $i_chkH = $a_chkPos[3]
    $a_lblPos = ControlGetPos($gui, "", GUICtrlGetHandle($h_tmpLabel))
    If $i_lblH > $i_chkH Then
        ConsoleWrite("bigger" & @CRLF)
        GUICtrlSetPos($h_tmpLabel, $a_lblPos[0], $i_chkPosY - (($i_lblH - $i_chkH) / 2) - $i_chkH / 6, $i_lblW, $i_lblH)
    Else
        GUICtrlSetPos($h_tmpLabel, $a_lblPos[0], (($i_chkH - $i_lblH) / 2) + $i_chkPosY, $i_lblW, $i_lblH)
    EndIf
EndFunc ;==>_GuiCtrlIconCheckBox_SetFont



Func _IconCheckbox_Click($h_tmpChk)
    ConsoleWrite("clicked " & @CRLF)
    $h_tmpChkHidden = $h_tmpChk + 1
    $h_tmpIcon = $h_tmpChk + 2

    If BitAND(GUICtrlRead($h_tmpChkHidden), $GUI_UNCHECKED) Then
        GUICtrlSetState($h_tmpIcon, $GUI_SHOW)
        GUICtrlSetState($h_tmpChkHidden, $GUI_CHECKED)
    Else
        GUICtrlSetState($h_tmpIcon, $GUI_HIDE)
        GUICtrlSetState($h_tmpChkHidden, $GUI_UNCHECKED)
    EndIf
EndFunc ;==>_IconCheckbox_Click

Func _IsIconCheckBox_Checked($h_tmpChk)
    $h_tmpChkHidden = $h_tmpChk + 1
    If BitAND(GUICtrlRead($h_tmpChkHidden), $GUI_CHECKED) Then
;ConsoleWrite($h_tmpChk & " is checked" & @CRLF)
        Return True
    Else
;ConsoleWrite($h_tmpChk & " is UNchecked" & @CRLF)
        Return False
    EndIf
EndFunc ;==>_IsIconCheckBox_Checked


Func _Control_GetTextSize($hWin, $sWinText, $hCtrl, $iPad = 0)
;author: ResNullius, based on PaulIA/GaryFrost (listview udf)
;returns a array of Text Width & Height
    Local $hWnd, $hDC, $hFont, $iMaxW, $iMaxH, $tSize, $sText, $aCtrlSize[2] = [$iMaxW, $iMaxW]
    If Not IsHWnd($hCtrl) Then
        $hWnd = ControlGetHandle($hWin, $sWinText, $hCtrl)
    Else
        $hWnd = $hCtrl
    EndIf
    If IsHWnd($hWnd) Then
        $hFont = _SendMessage($hWnd, $WM_GETFONT)
        $hDC = _WinAPI_GetDC($hWnd)
        _WinAPI_SelectObject($hDC, $hFont)
        $sText = ControlGetText($hWin, $sWinText, $hCtrl)
        $tSize = _WinAPI_GetTextExtentPoint32($hDC, $sText & " ")
        If DllStructGetData($tSize, "X") > $iMaxW Then $iMaxW = DllStructGetData($tSize, "X") + $iPad
        If DllStructGetData($tSize, "Y") > $iMaxH Then $iMaxH = DllStructGetData($tSize, "Y") + $iPad
        $aCtrlSize[0] = $iMaxW
        $aCtrlSize[1] = $iMaxH
        _WinAPI_SelectObject($hDC, $hFont)
        _WinAPI_ReleaseDC($hWnd, $hDC)
        Return $aCtrlSize
    EndIf
    Return 0
EndFunc ;==>_Control_GetTextSize
Edited by ResNullius

Share this post


Link to post
Share on other sites

@HAL9000

I liked this so much, I used UDFs to simplify the control creation and the logic of reading the check boxes

good :)

Share this post


Link to post
Share on other sites

I like it.

Thanks for sharing

GreenCan


Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

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