Jump to content

Recommended Posts

Posted (edited)

How do i create a simple image . gif that is clickable and gets picked up by the gui afterwards.

Let me start to tell, i feel very a shame i could not resolve this one. 

Found some interesting forum threats about solving it by making invisible labels over images. I tried to create an invisible label over the image to work around my inability.

I tried to look in the helpfile under $BS_BITMAP also about 30 minutes ago i tried alot of diffrend codes under _GDIPlus_ helpfile. 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Misc.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>

Global $hGUI1, $hGUI2 = 9999
Opt("GUIOnEventMode", 1)
maingui()

Func maingui()
    Global $hGUI1 = GUICreate("test v0.5", 340, 185, 0, 0)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")
    Global $MenuItem2 = GUICtrlCreateMenu("&Help")
    Global $MenuItem1 = GUICtrlCreateMenuItem("About test", $MenuItem2)
    GUICtrlSetOnEvent(-1, "On_Button")
    GUISetState(@SW_SHOW)

    While 1
        Sleep(10)
    WEnd
EndFunc

Func gui2()
    $hGUI2 = GUICreate("About Instalocker", 500, 213, Default, Default, $WS_POPUP)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")
GUICtrlCreatePic("matrix.gif", 0, 0, 500, 213) ; Change this into a valid picture u have
Global $button = GUICtrlCreateButton("Close", 0, 0, 100, 100)
GUICtrlSetOnEvent(-1, "On_Button")
    GUISetState()
EndFunc

Func On_Button()
    Switch @GUI_CtrlId
        Case $MenuItem1
            gui2()

        Case $button
            MsgBox(0, "You pressed on:", "button")
    EndSwitch
EndFunc

Func On_Close()
    Switch @GUI_WinHandle
        Case $hGUI1
            Exit
        Case $hGUI2
            GUIDelete($hGUI2)
    EndSwitch
EndFunc

Most definetly i overlooked something.

Edit: Updated the problematic version of the script

Edited by Flum
Posted

How do i create a simple image . gif that is clickable and gets picked up by the gui afterwards.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
Local $msg, $get, $Button
gui2()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            On_Close()
        Case $get
            Pic_Pressed()
        Case $Button
            MsgBox(0, "", " Button Pressed", 1)
    EndSwitch
        Sleep(130)
WEnd
Func gui2()
            $hGUI2 = GUICreate("About Instalock", 100, 143, -1, -1, $WS_POPUP)
            $get = GUICtrlCreatePic("c:\matrix.gif", 0, 0, 50, 80)
            $Button = GUICtrlCreateButton("test", 10, 90, 54, 54)
            GUISetState()
EndFunc   ;==>gui2
Func On_Close()
            Exit 0
EndFunc   ;==>On_Close
Func Pic_Pressed()
            MsgBox(0, "Info", "It is working?", 1)
EndFunc   ;==>Pic_Pressed
Posted

JoHanatCent,

Thanks for ur effort. I tried out the piece of code that u responded with. 

I noticed u are spamming line 29 the MsgBox when i complile. Im not sure if u where ment to do that? 

The image is still not clickable to use it as an on click case. Am i overlooking something here?

Posted (edited)

oke i just woke up fresh good morning, lets get this on the rails.   :sorcerer: I made a cut down version, of the problematic script i wrote. (First post) As u can see i am working with event mode & a double interface. 

The picture shows up behind the button and the button will become unusable. Any idea how that works?

Edited by Flum
Posted

Which do you want, a clickable picture, or one with a button on top? If you want the button to work, you need to disable the picture after creating it, see the help file.

GUICtrlSetState(-1, $gui_disable)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

  • Solution
Posted

BrewMan,

Thanks for Ur response. Really helpful to know u need to disable the picture to make the button to work.

I would also really like to know from you, how to make a picture directly clickable.

For now i solved it by putting the picture in the button with:

Global $button = GUICtrlCreateButton("Close", 0, 0, 500, 213, 0x8080) ; 0x8080 = $BS_BITMAP
    GUICtrlSetImage(-1, "matrix.bmp", -1)
    GUICtrlSetOnEvent(-1, "On_Close")

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...