Sign in to follow this  
Followers 0
ADSs

PNG Pics Actions

11 posts in this topic

Hi! my Problem is that i'm trying to make a GUI that looks Good, i searched for iPad icons... Of course they are PNGs and it have transparent Pixels, so after searching the best way to add does PNG icons in my GUI, i found it, But this Icons are actually Buttons.

So how can i make this PNG icons Clickable, OnEvent or whatever, i Tried GuiRegisterMSg, but i noticed that it doesn't support multiple Controls Func separably.

anyway to know if a PNG is clicked and which one?

Here is a pic of the GUI, Don't let it Die

Thanks

Share this post


Link to post
Share on other sites



The third example of guictrlcreatepic show you

how embed a png, but i don't find any function for make it clickable...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

I think you have a couple of choices here. You could convert the icons into bitmap or jpeg format with just enough of the background to suffice. Another idea using example #3 as mentioned by wakillon above, then using a combination of MouseGetPos and _IsPressed you could create "hot spots" on your GUI. The icons of course would serve no purpose other than guiding the user to the hot spot. If I were very determined about using the png's and making them "clickable" I would go the extra mile and find an open source png dll to use. For example, the Portable Network Graphics Homepage could prove helpful in this area.

Share this post


Link to post
Share on other sites

ADSs,

You might like to look at Malkey's UDF to report when your mouse is clicked within a certain area of the screen.

I have used it with great success to make certain areas of a background pic control act as different buttons. Might be just what you need. ;)

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

Personally I've always converted images to high quality *.ico's. When used on a standard UI the transperancy looks good, but I don't know how well they work on top of other images.

There might be restrictions ico files under some versions of windows, but it's worth investigating.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It should work but the image appears larger than it is ! Posted Image

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Opt ( "MouseCoordMode", 2 );1=absolute, 0=relative, 2=client
Global $hGUI, $hGraphic, $hImage, $hGraphic, $_PngWidth, $_PngHeight, $_PngXPos =30, $_PngYPos =30, $_RightBorderPos, $_DownBorderPos

_GUI ( )

While 1
    $msg = GUIGetMsg ( )
    Switch $msg
        Case $GUI_EVENT_CLOSE
            _GDIPlus_GraphicsDispose ( $hGraphic )
            _GDIPlus_Shutdown ( )
            Exit
        Case $GUI_EVENT_MOUSEMOVE
            $aPos = MouseGetPos ( )
            ToolTip ( "Mouse Position X:  " & $aPos[0] & "   Y: " & $aPos[1] & @CRLF )
        Case $GUI_EVENT_PRIMARYUP
            $aPos = MouseGetPos ( )
            If _MouseOverPng ( $aPos[0], $aPos[1] ) Then
                ToolTip ( "" )
                MsgBox ( 0, "", "Clicked in Png" & @Crlf & $aPos[0] & @Crlf & $aPos[1] )
            EndIf
    EndSwitch
    Sleep ( 10 )
WEnd

Func _GUI ( )
    $hGUI = GUICreate ( "Show PNG", 600, 600 )
    _GDIPlus_StartUp ( )
    $hImage   = _GDIPlus_ImageLoadFromFile ( @ProgramFilesDir & '\AutoIt3\Examples\GUI\Torus.png' )
    $_PngWidth = _GDIPlus_ImageGetWidth ( $hImage )
    ConsoleWrite ( "$_PngWidth : " & $_PngWidth & @Crlf )
    $_PngHeight = _GDIPlus_ImageGetHeight ($hImage)
    ConsoleWrite ( "$_PngHeight : " & $_PngHeight & @Crlf )
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ( $hGUI )
    _GDIPlus_GraphicsDrawImage ( $hGraphic, $hImage, $_PngXPos, $_PngYPos )
    $_RightBorderPos = $_PngXPos + $_PngWidth
    ConsoleWrite ( ' so $_xp must be between ' & $_PngXPos & ' and ' & $_RightBorderPos  & @Crlf )
    $_DownBorderPos = $_PngYPos + $_PngHeight
    ConsoleWrite ( ' so $_Yp must be between ' & $_PngYPos & ' and ' & $_DownBorderPos  & @Crlf )
    GUIRegisterMsg ( $WM_PAINT, "MY_WM_PAINT" )
    GUISetState()   
EndFunc

Func MY_WM_PAINT ( $hWnd, $Msg, $wParam, $lParam )
    _WinAPI_RedrawWindow ( $hGUI, $_PngXPos, $_PngYPos, $RDW_UPDATENOW )
    _GDIPlus_GraphicsDrawImage ( $hGraphic, $hImage, $_PngXPos, $_PngYPos )
    _WinAPI_RedrawWindow ( $hGUI, $_PngXPos, $_PngYPos, $RDW_VALIDATE )
    Return $GUI_RUNDEFMSG
EndFunc

Func _MouseOverPng ( $_xP, $_Yp )
    If $_xP >= $_PngXPos And $_xP <= $_RightBorderPos And $_Yp >= $_PngYPos And $_YP <= $_DownBorderPos Then Return 1
EndFunc

I had to miss something ?

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

I know it can be boring seeing someone forcing something over and over but here...

#include "GIFAnimation.au3"


Global $hGUI = GUICreate("Example", 500, 500)

Global $pPNG
Global $hPNG = _GUICtrlCreateGIF(_PNG(), "", 100, 100, $pPNG)
GUICtrlSetTip($hPNG, "I'm a PNG")

GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $hPNG
            MsgBox(0, 'Aha!', 'PNG cicked')
    EndSwitch
WEnd


Func _PNG()
    Local $Wow64
    If @AutoItX64 Then $Wow64 = "\Wow6432Node"
    Return RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Torus.png"
EndFunc   ;==>_PNG

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

@trancexx

my GIFAnimation.au3 is dated of august but your script give me :

: ERROR: _GUICtrlCreateGIF() called with wrong number of args.
Global $hPNG = _GUICtrlCreateGIF(_PNG(), "", 100, 100, $pPNG)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Program Files\AutoIt3\Include\GIFAnimation.au3(24,144) : REF: definition of _GUICtrlCreateGIF().
Func _GUICtrlCreateGIF($sFileName, $iLeft, $iTop, ByRef $aGIFArrayOfIconHandles, ByRef $hGIFThread, ByRef $iTransparency, ByRef $tCurrentFrame)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrateur\Local Settings\Temp\Test_054.au3 - 1 error(s), 0 warning(s)
!>19:16:33 AU3Check ended.rc:2
+>19:16:33 AutoIt3Wrapper Finished
>Exit code: 0    Time: 0.211

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanks all for the help, i will test trancexx method first.

Let's see if work on my GUI. BTW does it work OnEvent?

EDIT: IT WORKED! Thanks it worked perfectly, your func act exactly as a Normal GUICtrlCreate With Hides and everything. I Think you Func should be more famous, i Looked everywhere and did not find it. Also Autoit should start to Support PNG since it is a Pain to work with PNGs except with your UDF

Edited by ADSs

Share this post


Link to post
Share on other sites

Thanks all for the help, i will test trancexx method first.

Let's see if work on my GUI. BTW does it work OnEvent?

EDIT: IT WORKED! Thanks it worked perfectly, your func act exactly as a Normal GUICtrlCreate With Hides and everything. I Think you Func should be more famous, i Looked everywhere and did not find it. Also Autoit should start to Support PNG since it is a Pain to work with PNGs except with your UDF

Fame and glory, that's what I'm after. Don't tell anyone I told you that. ;)

@wakillon, there are 31 days in August. Try second half.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Too funny ! I died laughing !


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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