Sign in to follow this  
Followers 0
Seminko

GUI with semi-transparent shadows

8 posts in this topic

Hey fellas,

I have this GUI

$Form1 = GUICreate("", 300, 200, -1, -1, $WS_POPUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Pic1 = GUICtrlCreatePic("F:\Excel shit\WebTarget\GUI_Small copy.jpg", 0, 0, 300, 200)
GUICtrlSetOnEvent(-1, "Form1Close")
$Label1 = GUICtrlCreateLabel($CurrentBalance & $FinalResultOvertime, 4, 80, 292, 76, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 30, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x00295d)
$button1 = GUICtrlCreateButton("Enter", 110, 80, 75, 20)
GuiCtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_HIDE))
GUICtrlSetOnEvent(-1, "Form1Close")
GUISetState(@SW_SHOW)

What I need is the $Pic1 to be a PNG image with semi-transparent shadows around. I googled and found out I am supposed to use GDI+.

Unfortunately, I have no idea as to how to update my GUI code.

Could someone help pls?

Thanks

Share this post


Link to post
Share on other sites



Have a look to the first example (>Display images from memory in controls) in the File to Base64 String Code Generator topic.

Instead of using a bitmap from the binary string you can load a PNG image.

 

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hez UEZ,

that example is pretty overwhelming.

What of your example do I need? I suppose this:

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global $hBitmap, $hGUI
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap(>>>path to an image<<<)
$Form1 = GUICreate("", 300, 200, -1, -1, $WS_POPUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Pic1 = GUICtrlCreatePic(>>>path to an image<<<, 0, 0, 300, 200)
GUICtrlSetOnEvent(-1, "Form1Close")
$Label1 = GUICtrlCreateLabel($CurrentBalance & $FinalResultOvertime, 4, 80, 292, 76, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 30, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x00295d)
$button1 = GUICtrlCreateButton("Enter", 110, 80, 75, 20)
GuiCtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_HIDE))
GUICtrlSetOnEvent(-1, "Form1Close")
GUISetState(@SW_SHOW)
_WinAPI_DisplayTransparentBitmapInGUI($hBitmap, $hGUI)

Func Form1Close()
   _GDIPlus_BitmapDispose($hImage)
   _GDIPlus_Shutdown()
   GuiDelete($Form1)
EndFunc

I won't be reading the image from memory (at least I guess I won't for the time being).

Edited by Seminko

Share this post


Link to post
Share on other sites

This is my example from other forum.

http://autoit-script.ru/index.php?topic=5090.msg36976#msg36976

 

#Include <APIConstants.au3>
#Include <ComboConstants.au3>
#Include <GDIPlus.au3>
#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>

Global Const $SC_DRAGMOVE = 0xF012

_GDIPlus_Startup()
$hPng = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\1660807.png')
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng)
$hParent = GUICreate('', 579, 293, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
_WinAPI_UpdateLayeredWindowEx($hParent, -1, -1, $hBitmap, 255, 1)
_GDIPlus_ImageDispose($hPng)
_GDIPlus_Shutdown()

$hForm = GUICreate('', 563, 180, -1, -1, $WS_POPUP, -1, $hParent)
GUISetBkColor(0x314B89)
GUICtrlCreatePic(@ScriptDir & '\1660807.bmp', 0, 0, 563, 180)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateCombo('Option1', 270, 8, 285, 140, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, 'Option2|Option3|Option4', 'Option1')
$Label = GUICtrlCreateLabel('Loading...', 10, 74, 60, 14)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$Button = GUICtrlCreateButton('Exit', 476, 150, 80, 23)

GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
WM_MOVE($hParent, $WM_MOVE, 0, 0)
GUISetState(@SW_SHOW, $hParent)
GUISetState(@SW_SHOW, $hForm)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            Exit
        Case $Label
            _SendMessage($hParent, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndSwitch
WEnd

Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hParent

            Local $Pos = WinGetPos($hParent)

            If IsArray($Pos) Then
                WinMove($hForm, '', $Pos[0] + 13, $Pos[1] + 100)
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOVE

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            _SendMessage($hParent, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
        Case $hParent
            Return $HTCAPTION
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST

Transparent.zip

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

 

Thanks man, I figured it out thanks to you!

 

If you could help me further. I don't do all the Switch / Case / Endswitch thing. I want my script to run in the background and when a hotkey is pressed I want the GUI to show up. So everytime the function is called my script runs GUICreate and when done the script runs GUIDelete, which is not ideal, obviously. Is there a way for the gui to be hidden and called and not to be created everytime? I mean will that help with speed or it doesn't matter?

Edited by Seminko

Share this post


Link to post
Share on other sites

WinSetState(), GUISetState()?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

WinSetState(), GUISetState()?

 

Thanks man, unfortunately, that doesn't make the script any faster than GUIDelete, GUICreate

Share this post


Link to post
Share on other sites

I'm not sure what you mean by doesn't make it faster.  But I'll assure you of this... if you have controls with your GUI, it certainly does make the rendering many times faster.

Just on logic alone:

GUICreate()

GUICtrlCreate()

etc...

GUISetState()

Vs. just:

GUISetState()


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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