Jump to content

Round Button


Jam00
 Share

Recommended Posts

Someone knows how to create a round button or a Round Pic can do? So I want the button only responds when you on the rounds, and not only in the rectangle of the Pic's. Do not wonder about the spelling, it is only via Google translate! 'm German

Link to comment
Share on other sites

Someone knows how to create a round button or a Round Pic can do? So I want the button only responds when you on the rounds, and not only in the rectangle of the Pic's. Do not wonder about the spelling, it is only via Google translate! 'm German

You could do it like this, but I think there should be a simpler way.

post-3602-1233771726_thumb.gif

post-3602-1233771707_thumb.gif

#include <GUIConstantsEx.au3>
   #include <WindowsConstants.au3>
   #include <misc.au3>
   Global $butoff = True
   $gui = GUICreate("round button",400,400,400,400)
   GUISetState()
   $gui2 = GUICreate("ytfty",48,48,480,480,$WS_POPUP,-1,$gui)
   WinSetTrans($gui2,"",0)
   $pic = GUICtrlCreatePic("btn003.gif", 0, 0, 48, 48)
   GUISetState()
   GUISwitch($Gui)
   GUIRegisterMsg($WM_MOVE,"dog")
   WinActivate($gui)
   While 1
       $msg = GUIGetMsg()
       If $msg = -3 Then Exit
       $cp = GUIGetCursorInfo()
       if IsArray($cp) Then
       If $cp[4] = $pic Then
           If $butoff Then
               GUICtrlSetImage($pic, "btn002.gif")
           Else
               GUICtrlSetImage($pic, "btn003.gif")
           EndIf
       Else
           If $butoff Then
               GUICtrlSetImage($pic, "btn002.gif")
           Else
               GUICtrlSetImage($pic, "btn003.gif")
           EndIf
           
       EndIf
       EndIf
       If $msg = $pic Then
           
           WinActivate($gui)
           If $butoff Then
               
               While _IsPressed("01")
                   Sleep(30)
               WEnd
               GUICtrlSetImage($pic, "btn002.gif")
           Else
               While _IsPressed("01")
                   Sleep(30)
               WEnd
               GUICtrlSetImage($pic, "btn003.gif")
           EndIf
           $butoff = Not $butoff
       EndIf
   
   WEnd
   
   Func dog($hWnd,$iMsg,$Wparam,$Lparam)
       Local $wp = WinGetPos($gui)
       WinMove($gui2,"",$wp[0] + 80,$wp[1] + 80)
   EndFunc
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

  • Moderators

Jam00,

Try this. It draws a filled circle within a graphic control and then uses the colour under the cursor to decide if it was clicked on the round part or not:

#include <GUIConstantsEx.au3>

$hWin = GUICreate("Test", 200, 200)

$hGraphic = GUICtrlCreateGraphic(90, 90 , 21, 21)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFF0000, 0xFF0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 10, 10, 10, 0, 360)

GUISetState()

While 1
    
    $iMsg = GUIGetMsg()
    
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hGraphic
            Local $aInfo = GUIGetCursorInfo($hWin)
            $iOldPCM = Opt("PixelCoordMode", 2)
            Local $iColour = PixelGetColor($aInfo[0], $aInfo[1], $hWin)
            Opt("PixelCoordMode", $iOldPCM)
            If $iColour = 0xff0000 Then MsgBox(0, "", "Hit")
    EndSwitch
    
WEnd

You need to set the PixelCoordMode to "relative" - and I think it is good practice to reset it afterwards.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

@Melba23

Okay, it's good, but what do I do if the button and the background color are not?

@martin

This is a little Kompliezierter because I must once again look a bit more accurate!

Edited by Jam00
Link to comment
Share on other sites

  • Moderators

Jam00,

If you do not click on the button colour - which you choose when you create it - then nothing happens at all, just like a normal button!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Jam00,

If you do not click on the button colour - which you choose when you create it - then nothing happens at all, just like a normal button!

M23

Looks like a good approach Melba, and a lot simpler than my suggestion. But instead of saying

If $iColour = 0xff0000 Then MsgBox(0, "", "Hit")

maybe it would be more versatile to have

If $iColour <> $GuiBkCol Then MsgBox(0, "", "Hit")

That way you could get the gui colour say by testing a pixel at 1,1 in the client area, and you could have images with giffs with transparent bits, or icons so you wouldn't be limited to drawing the button in your script.

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

I have but one pic in the background, and there are the distinctive colors! So the background image is available in different colors-blue and the button will be colored red, can I somehow make it to the not just a color but is looking for an areas of color?

I have the image uploaded times because you see what I mean and it will be up in the corner 2 Round button! A reddish-colored, and one in oronge colors

EDIT:

Here's the script:

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

#Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\Hendrik\Favoriten\Eigene Dateien\AutoIt\Übungen\XSkin\Oberfläche\XSkin.kxf
$Titel = "INC"
$Form2 = GUICreate($Titel, 555, 532, 303, 219,$WS_POPUP)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Data\1.bmp", 0, 0, 555, 532, $WS_CLIPSIBLINGS)
$Label1 = GUICtrlCreateLabel("   "& $Titel, 0, 0, 555, 32,$WS_EX_TRANSPARENT, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor (-1,0xFF0A000)
GUICtrlSetFont (-1,12,550,0,"Arial")
$Icon1 = GUICtrlCreateIcon("", 0, 489, 3, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon2 = GUICtrlCreateIcon("", 0, 519, 3, 32, 32, $SS_NOTIFY)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_Ecken($Form2,0,0,10,10)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd
Func _Ecken($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3)
    If $XS_ret[0] Then
        $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
    EndIf
EndFunc  ;==>_GuiRoundCorners

post-45800-1233783740_thumb.png

Edited by Jam00
Link to comment
Share on other sites

  • Moderators

Jam00,

Es tut mir leid, but your GUI does not display on my Vista system. :-(

Martin has a good point. If you were to create .gifs with transparent backgrounds to use as buttons then the problem of the GUI background colour would vanish. At the moment I want to watch the football on the television - I will see if I can produce an example for you tomorrow.

Gute Nacht und bis Morgen.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Here some code to play with ....

..... a solution using a rounded child GUI and a flat button.

br, Reinhard

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



Example()

Func Example()
    $mainGUI = GUICreate("My round GUI Button",200,200,100,100);,$WS_POPUP); will create a dialog box that when displayed is centered
    GUISetState()
    
    $Button1 = GUICtrlCreateButton("Btn1", 30,30, 50, 50)
    
    
    $subGUI  = GUICreate("",60,60,90,60,BitOr($WS_CHILD,$WS_TABSTOP,$DS_MODALFRAME),-1,$mainGUI)
    GUISetBkColor(0xFFE0C0)
    $Button2 = GUICtrlCreateButton("Btn2", -5,-5, 70, 70,$BS_FLAT )
    GUICtrlSetBkColor(-1,0xFFE0C0)
    _GuiRoundCorners($subGUI, 0, 0, 50, 50)
    
    GUISetState()    ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button1
                MsgBox(0, 'Testing', 'Button 1 was pressed') 
            Case $msg = $button2
                MsgBox(0, 'Testing', 'Button 2 was pressed')
        EndSelect
    WEnd
EndFunc  ;==>Example

Func _GUIRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3);Written by GaFrost
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3)
    If $XS_ret[0]Then
        $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
    EndIf
EndFunc
Link to comment
Share on other sites

A re-worked Melba23 example without the colour reference

This is a good example of the use of the functions I just posted at

http://www.autoitscript.com/forum/index.ph...st&p=639786

using the _PointInEllipse() function.

The circluar area where the red spot is, is the target shape (area) to see if the point that was clicked is within.

#include <GUIConstantsEx.au3>

$hWin = GUICreate("Test", 200, 200)

$hGraphic = GUICtrlCreateGraphic(90, 90, 21, 21)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFF0000, 0xFF0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 10, 10, 10, 0, 360)

GUISetState()

While 1

    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hGraphic
            Opt("MouseCoordMode", 2)
            $aPos = MouseGetPos()
            If _PointInEllipse($aPos[0], $aPos[1], 90, 90, 21, 21) Then MsgBox(0, "", "Hit")
    EndSwitch

WEnd

Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
    Local $bInside = False, $a = $w / 2, $b = $h / 2
    Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
    $c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position
    $c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position
    $dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
    If $dist <= $w Then $bInside = Not $bInside
    Return $bInside
EndFunc  ;==>_PointInEllipse
Link to comment
Share on other sites

  • Moderators

Malkey,

I like that a lot. Must go and look at your other post now!

M23

Edit:

Jam00,

Malkey's code works even if you have a picture over top. So what you need to do is get a .gif with a transparent background (I have attached one as an example) and place it over the top of the graphic. That way both the GUI background colour and the .gif button colour are irrelevant as you can see from the example. Looks like a pretty good solution to me:

#include <GUIConstantsEx.au3>

$hWin = GUICreate("Test", 200, 200)
    GUISetBkColor( 0x00FF00, $hWin)

$hGraphic = GUICtrlCreateGraphic(90, 90, 21, 21)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 10, 10, 10, 0, 360)

GUICtrlCreatePic("button.gif", 90,90,21,21)

GUISetState()

While 1

    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hGraphic
            $iOldOpt = Opt("MouseCoordMode", 2)
            $aPos = MouseGetPos()
            If _PointInEllipse($aPos[0], $aPos[1], 90, 90, 21, 21) Then MsgBox(0, "", "Hit")
            Opt("MouseCoordMode", $iOldOpt )
    EndSwitch

WEnd

Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
    Local $bInside = False, $a = $w / 2, $b = $h / 2
    Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
    $c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position
    $c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position
    $dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
    If $dist <= $w Then $bInside = Not $bInside
    Return $bInside
EndFunc ;==>_PointInEllipse

The only other thing I have changed in the script is to reset the MouseCoordMode once we have finished with the relative mouse coords. If this is not done, there could be problems the next time a Mouse function is used - as I know from bitter experience!

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

@ReFran

Okay, that's nice, but how can I determine which button is made about?

@Melba23 & @Malkey

This is very beautiful! But how can I get the picture transparent, to me it somehow does not, so I've tried:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hWin = GUICreate("Test", 200, 200)
    GUISetBkColor( 0x00FF00, $hWin)

$hGraphic = GUICtrlCreateGraphic(90, 90, 21, 21)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 10, 10, 10, 0, 360,$WS_EX_TRANSPARENT)
GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)

$Pic = GUICtrlCreatePic("button.gif", 90,90,21,21,$WS_EX_TRANSPARENT)
GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
GUISetState()

While 1

    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hGraphic
            $iOldOpt = Opt("MouseCoordMode", 2)
            $aPos = MouseGetPos()
            If _PointInEllipse($aPos[0], $aPos[1], 90, 90, 21, 21) Then MsgBox(0, "", "Hit")
            Opt("MouseCoordMode", $iOldOpt )
    EndSwitch

WEnd

Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
    Local $bInside = False, $a = $w / 2, $b = $h / 2
    Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
    $c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position
    $c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position
    $dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
    If $dist <= $w Then $bInside = Not $bInside
    Return $bInside
EndFunc;==>_PointInEllipse
Link to comment
Share on other sites

Malkey,

I like that a lot. Must go and look at your other post now!

M23

Edit:

Jam00,

Malkey's code works even if you have a picture over top. So what you need to do is get a .gif with a transparent background (I have attached one as an example) and place it over the top of the graphic. That way both the GUI background colour and the .gif button colour are irrelevant as you can see from the example. Looks like a pretty good solution to me:

#include <GUIConstantsEx.au3>

$hWin = GUICreate("Test", 200, 200)
    GUISetBkColor( 0x00FF00, $hWin)

$hGraphic = GUICtrlCreateGraphic(90, 90, 21, 21)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 10, 10, 10, 0, 360)

GUICtrlCreatePic("button.gif", 90,90,21,21)

GUISetState()

While 1

    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hGraphic
            $iOldOpt = Opt("MouseCoordMode", 2)
            $aPos = MouseGetPos()
            If _PointInEllipse($aPos[0], $aPos[1], 90, 90, 21, 21) Then MsgBox(0, "", "Hit")
            Opt("MouseCoordMode", $iOldOpt )
    EndSwitch

WEnd

Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
    Local $bInside = False, $a = $w / 2, $b = $h / 2
    Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
    $c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position
    $c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position
    $dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
    If $dist <= $w Then $bInside = Not $bInside
    Return $bInside
EndFunc;==>_PointInEllipse

The only other thing I have changed in the script is to reset the MouseCoordMode once we have finished with the relative mouse coords. If this is not done, there could be problems the next time a Mouse function is used - as I know from bitter experience!

M23

Tidying up the unnecessary code, this works also. The corners of the image are not clickable. Only the circular area is clickable.

I lke the unintrusive method of enabling and disabling the "MouseCoordMode" , if it can not be placed at the top of the script for some reason.

CODE
#include <GUIConstantsEx.au3>

$hWin = GUICreate("Test", 200, 200)

GUISetBkColor(0x00FF00, $hWin)

$hPic = GUICtrlCreatePic("button.gif", 90, 90, 21, 21)

GUISetState()

While 1

$iMsg = GUIGetMsg()

Switch $iMsg

Case $GUI_EVENT_CLOSE

Exit

Case $hPic

$iOldOpt = Opt("MouseCoordMode", 2)

$aPos = MouseGetPos()

If _PointInEllipse($aPos[0], $aPos[1], 90, 90, 21, 21) Then MsgBox(0, "", "Hit")

Opt("MouseCoordMode", $iOldOpt)

EndSwitch

WEnd

Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)

Local $bInside = False, $a = $w / 2, $b = $h / 2

Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b

$c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position

$c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position

$dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5

If $dist <= $w Then $bInside = Not $bInside

Return $bInside

EndFunc ;==>_PointInEllipse

Link to comment
Share on other sites

  • Moderators

Malkey,

I just popped into the thread to do exactly what you have just done! I was looking at your code more closely and realised that the graphic was just a visual aid and not a requirement.

I hesitate to say "great minds", but we were certainly "thinking alike"!

Jam00,

The .gif has a transparent background, so it should appear as a round button on any background - it certainly does on my machine. If that is not what you mean, can you explain again what you mean by "get the picture transparent".

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Jam00,

But it is transparent for me! I presume you are using XP while I am on Vista - perhaps that is the difference. Can you get hold of any other .gifs with a transparent background to try? Perhaps mine did not travel well (joke!).

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

how can this be wrong?

EDIT:

Okay, if you're in XP does not work, somebody has an idea how I achieved it?

It's nothing to do with XP. Can you post the code you are using to get the non-transparent button?

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

Hmm ... would be really funny, because I have the latest (3.3)

And in the German forum say the picture could not transperent!

I've got it now with icon, so we have a look!

You are really great! In the German forum could not!

Link to comment
Share on other sites

  • Moderators

martin,

I have just come back to find you here - glad to have another brain to help!

Do you get a transparent .gif when you display it? I could only think that there was an XP theme messing with the display - I use Vista, but as basic a display as I can get away with.

I am afraid that my knowledge of graphic formats is not very deep. I understand .bmps quite well, and the differences between them, .jpg, .gif, .png, etc, but little about this kind of problem. Any help you can give would be much appreciated - I am always happy to learn :-)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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