Jump to content
Sign in to follow this  

Labels losing click functionality when bmp added to form.

Recommended Posts

I am having a problem with part of a script that uses bmp resources from a dll to display background images. I have made a function using code from Here that create a picture container and adds a bmp as a background image. The form has labels that perform actions when clicked the trouble is after loading the bmp the labels no longer function.

I think it may be something to do with the order of the controls but can't figure out how to send the bmp to the background, is it possible?.


#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1)
Dim $Icofile = @SystemDir & '\shell32.dll', $BackGrd

$Form2 = GUICreate("Form2", 285, 157, 219, 150)
Create_BMP($BackGrd, 14351, 0, 0, 284, 156)
$Label1 = GUICtrlCreateLabel("Google", 40, 56, 38, 17)
GUICtrlSetOnEvent(-1, 'lbl_clicked')
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor(-1, 0)
$Label2 = GUICtrlCreateLabel("AutoIt", 40, 76, 32, 17)
GUICtrlSetOnEvent(-1, 'lbl_clicked')
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor(-1, 0)


While 1

Func lbl_clicked()
    Switch @GUI_CtrlId
        Case $Label1
            MsgBox(0, '', 'Googling')
        Case $Label2
            MsgBox(0, '', 'Getting Help')
EndFunc  ;==>lbl_clicked

Func Create_BMP($Ctrl_ID, $iBMP, $iLeft = 0, $iTop = 0, $iWidth = 0, $iHeight = 0); Load BMP from a dll ($Ctrl_ID = Control ID to be created, $iBMP = Index of BMP in dll, $ileft & $iTop = Left & Top pos, $iWidth & $iHeight = Width & Height of pic container)
    Local $hBmp = 0
    $Ctrl_ID = GUICtrlCreatePic('', $iLeft, $iTop, $iWidth, $iHeight); Create the Picture container.
    $hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary($Icofile), $iBMP, $IMAGE_BITMAP, $iWidth, $iHeight, $LR_DEFAULTCOLOR); Load the BMP
    GUICtrlSendMsg($Ctrl_ID, 0x0172, $IMAGE_BITMAP, $hBmp); Load the bmp into the container.
EndFunc  ;==>Create_BMP

Func DoExit()
EndFunc  ;==>DoExit

Share this post

Link to post
Share on other sites

set the state of the BMP to disabled.


Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver: - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  

  • Create New...