Jump to content
Peterson_Unatted

Button does not work, appears inactive

Recommended Posts

Peterson_Unatted

Hi, great community. It's been no more than two years since I used Autoit for almost everything, I usually use it for all my scripts.
Now I come to your aid because I find it difficult to find a solution to my problem, in the following code I can not ACTIVATE THE COMBOBOX and the BUTTON.
I am exhausted, I read many codes but I can not find an answer ..
I hope you can help me...:sweating:

#include <Constants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
Global Const $STM_SETIMAGER = 0x0172

#Region DE CONFIGURACIÓN DE LA PLANTILLA



$dir = @ScriptDir
$dir_ANT = StringLeft($dir, StringInStr($dir, "\", 0, -1) - 1)
Global $backimage = ($dir_ANT & "\CUSTOM\IMAGES\WALLPAPER.jpg")

_GDIPlus_Startup()
Global $hBmp = _GDIPlus_BitmapCreateFromFile($backimage)
Global $iW = _GDIPlus_ImageGetWidth($hBmp), $iH = _GDIPlus_ImageGetHeight($hBmp)

Global $Form_1 = GUICreate("PETERSON UNATTED SWPI", 1024, 768, -1, -1)

Global $idPic = GUICtrlCreatePic("", -8, 0, $iW, $iH, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE))

GLOBAL $Button1 = GUICtrlCreateButton("SALIR", 20, 700, 105, 41, BitOR($BS_DEFPUSHBUTTON, $BS_CENTER, $BS_PUSHLIKE, $BS_FLAT))
GUICtrlSetOnEvent(-1, "_CERRARPUTO")
GUICtrlSetTip(-1, "CERRAR APLICACIÃ’N")
$Combo1 = GUICtrlCreateCombo("Combo1", 296, 216, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))


Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
Global $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGER, $IMAGE_BITMAP, $hHBitmap)

If $hB Then _WinAPI_DeleteObject($hB)

GUISetState(@SW_SHOWMAXIMIZED)

#EndRegion DE CONFIGURACIÓN DE LA PLANTILLA

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIRegisterMsg($WM_SIZE, "")
            _WinAPI_DeleteObject($hHBitmap)
            _GDIPlus_BitmapDispose($hBmp)
            _GDIPlus_Shutdown()
            GUIDelete()
            Exit
        Case $Button1
            _CERRARPUTO


    EndSwitch
WEnd

Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $aSize = ControlGetPos($hWnd, "", $idPic)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($aSize[2], $aSize[3])
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetInterpolationMode($hContext, 5)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, 0, 0, $aSize[2], $aSize[3])
    _GDIPlus_GraphicsDispose($hContext)
    Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    Local $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGER, $IMAGE_BITMAP, $hHBitmap)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_SIZE
Func _CERRARPUTO()

    GUIDelete()
    Exit
EndFunc   ;==>_CERRARPUTO


The button is to close the form, since later deactivate the closing x

GUISOURCE.AU3

Share this post


Link to post
Share on other sites
Peterson_Unatted

Thanks for your quick response Jos.
Still, it still does not work, I'm going to try to disarm the code and re-read it to see if I can find something. But I think there's something I'm missing in this code.
I leave an image so that they see what happens, the button and the combobox only work in a non-dynamic form, that is, a form where the image does not have the parameters $ iW $ iH, which is what I manage to make the image adapt to the size changes of the form.

 

vista.jpg

Share this post


Link to post
Share on other sites
Jos

It probably works as I don't have the original image, so when running the script, things work fine and can't reproduce your issue without it.
Please post a total set of script and image that we can run and reproduce your issue.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Zedna

Directly from Helpfile for GUICtrlCreatePic():

Quote

If a picture is set as a background picture the other controls will overlap, so it is important to disable the pic control: GUICtrlSetState(-1, $GUI_DISABLE).

 

Fixed part of your code:

Global $idPic = GUICtrlCreatePic("", -8, 0, $iW, $iH, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE))
GUICtrlSetState(-1, $GUI_DISABLE)

 

Share this post


Link to post
Share on other sites
Peterson_Unatted

Gracias a ambos, pude lograrlo, me faltaba ese ajuste " GUICtrlSetState(-1, $GUI_DISABLE)" y sin "()" la función no hubiese sido llamada. Muchas gracias.:D:D

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

×