Jump to content

Recommended Posts

Posted (edited)

Hey,

Another problem :)

I'm trying to create a GUI (image based) with a fixed height and a custom width (100 for example)

But it just stays 1 x 1 pxl.

The image I am using is a 0x000000 1 by 1 pxl png file (bg.png)

Does anyone know why it is not resizing?

Rawox.

#include <GDIPlus.au3>
#include <GuiComboBox.au3>
#Include <Constants.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <_MouseHover.au3>
#include <Misc.au3>

Global Const $AC_SRC_ALPHA = 1
HotKeySet ( "{ESC}", "exitProg" )

$Developer = "Rawox"
$Title = "Smaryl"
$Version = "1.02"
$Website = "http://rawox.deviantart.com"
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\bg.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
$width = 100
$height = 100

$GUI = GUICreate ( $Title, $width, $height, 0, 0, $WS_POPUP, $WS_EX_LAYERED )
$Bmp = SetBitmap($GUI, $hImage, 0)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState ( )
WinSetOnTop($GUI, "", 1)
For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImage, $i)
Next

$controlGui = GUICreate ( "ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI )
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height )
GUICtrlSetState ( -1, $GUI_DISABLE )
GUISetState()

While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd

Func exitProg()
    GUIDelete ( $controlGui )
    For $i = 255 To 0 Step -10
        SetBitmap($GUI, $hImage, $i)
    Next
    _WinAPI_DeleteObject($hImage)
    _GDIPlus_Shutdown()
    Exit
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc

Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
    $aRet = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "", _
            "string", $sCmd, _
            "string", $sArg, _
            "string", $sFolder, _
            "int", $rState)
    If @error Then Return 0

    $RetVal = $aRet[0]
    If $RetVal > 32 Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc
Edited by Rawox

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
×
×
  • Create New...