Jump to content

Who wants to help me learn enhanced gui building?


Recommended Posts

  • Moderators

Wombat.

Use the #region/#endregion directives to create foldable zones in your script. They are nestable - I have a 6000+ line script which is 17 lines folded and with no function more than 3 clicks away. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Coded after a long. Check the example #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <Const

makes me smile. it was me who initiated GUISetStyle() to be added to autoit functions many many years ago. the mods told me they doubt that anyone will ever need it. edit: pre gdi+ times times of c

well i have 10,000 line script in work and it starts immediately. it depends where you put the configuration stuff and how complex the gui is. but if you do it in a smart way, it starts immediately.

please, what works ?

PhoenixXL's script. You said it didn't work for you on XP. My bad, I missunderstood posts.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Link to post
Share on other sites

Wombat.

Use the #region/#endregion directives to create foldable zones in your script. They are nestable - I have a 6000+ line script which is 17 lines folded and with no function more than 3 clicks away. :)

M23

 

Thank you Melba23 :bye:

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites
please, what works ?
 WS_EX_TRANSPARENT style would make the window pass the mouse-clicks to the underlying window. The invisible window that holds the controls needs to be transparent otherwise clicks would get captured by the invisible window and the gaps on the layered window won't activate the underlying window.
 
If you still don't get my point, try the following code and click on the parts of the layered window that should activate the underlying window.
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <Array.au3>

Global Const $AC_SRC_ALPHA = 1
Global $iWidth, $iHeight, $hRegion
Global $___hNew_WndProc, $___pNew_WndProc, $___pOld_WndProc

_GDIPlus_Startup()

$s_Bitmap = @ScriptDir & "\GUI.png" ;http://img823.imageshack.us/img823/8938/ciik.png - link given by the OP at http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/#entry1102795
$hLayeredGUI = _GUICreate_Alpha("LayeredWin | Phoenix XL", $s_Bitmap, $iWidth, $iHeight)

GUISetState() ;show the main gui

;when the background color and the transcolor are the same of a layered GUI we recieve transparent background
;this would create an invisible window
$hControls_GUI = GUICreate("ControlGUI", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $hLayeredGUI)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hControls_GUI, 0xABCDEF, 230) ;set transparency to 230


;the close button you can use icon also
$iCloseButton = GUICtrlCreateLabel("X", 26, 30, 10, 10)
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)

;now lets create the so required controls to sync the user interaction
$iProgressBar = GUICtrlCreateProgress(80, 50, 360, 30)
GUICtrlSetData(-1, 20) ;set the initial position of the progress to 20


$iText = GUICtrlCreateLabel("You will get all the status updates and the information here...." & @CRLF & "Stay Tuned..", 80, 90, 279, 205)

GUISetState() ;show the controls window

Local $iMsg, $aInfo, $f_ClkThrough = False

Do

    $iMsg = GUIGetMsg(1)    ;use advanced method for there are multiple GUIs


    Switch $iMsg[1]
        Case $hControls_GUI ;msg is received from controls gui
            Switch $iMsg[0]

                Case $iCloseButton  ;close btn is clicked
                    ExitLoop

            EndSwitch

    EndSwitch




Until $iMsg[0] = $GUI_EVENT_CLOSE

_GDIPlus_Shutdown()
Exit


Func _WinSetClickThrough($hWin, $iCLickThrough = True)

    Local $iExStyle = GUIGetStyle($hWin)
    $iExStyle = $iExStyle[1]

    If $iCLickThrough Then
        $iExStyle = BitOR($iExStyle, $WS_EX_TRANSPARENT)
    Else
        $iExStyle = BitXOR($iExStyle, $WS_EX_TRANSPARENT)
    EndIf

    Return GUISetStyle(Default, $iExStyle)
EndFunc   ;==>_WinSetClickThrough



;I have not created the following functions..

Func _GUICreate_Alpha($sTitle, $sPath, ByRef $iWidth, ByRef $iHeight, $iX = -1, $iY = -1, $iOpacity = 255)
    Local $hGUI, $hImage
    $hImage = _GDIPlus_ImageLoadFromFile($sPath)
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED)

    SetBitmap($hGUI, $hImage, $iOpacity)

    _GDIPlus_ImageDispose($hImage)

    Return $hGUI
EndFunc   ;==>_GUICreate_Alpha

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   ;==>SetBitmap

The original script would allow click-through

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to post
Share on other sites

#region ; Includes
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <Array.au3>
#endregion ; Includes

Opt("GUIOnEventMode", 0)

#region;;;;;;GUI Section;;;;;;;
Global $sFile = "C:\Users\Wombat\Pictures\example2.png"

Global Const $AC_SRC_ALPHA = 1
Global $iWidth, $iHeight, $hRegion
Global $___hNew_WndProc, $___pNew_WndProc, $___pOld_WndProc

_GDIPlus_Startup()

$s_Bitmap = $sFile ;http://img823.imageshack.us/img823/8938/ciik.png - link given by the OP at http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/#entry1102795
$hLayeredGUI = _GUICreate_Alpha("End-Hancer", $s_Bitmap, $iWidth, $iHeight)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState() ;show the main gui

;when the background color and the transcolor are the same of a layered GUI we recieve transparent background
;this would create an invisible window
$hControls_GUI = GUICreate("ControlGUI", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $hLayeredGUI)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hControls_GUI, 0xABCDEF, 230) ;set transparency to 230

;the close button you can use icon also
$iCloseButton = GUICtrlCreateLabel("X", 175, 260, 10, 10)
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "CloseGUI")

;now lets create the so required controls to sync the user interaction
$iProgressBar = GUICtrlCreateProgress(200, 450, 360, 15)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetData(-1, 100) ;set the initial position of the progress to 20

#Region ; Menu
$iCheckUpdates = GUICtrlCreateLabel("Check For Updates", 250, 350, 140, 18)
GUICtrlSetFont(-1, 10, 1000, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "UpdateVersion")

$iGraphicsConfig = GUICtrlCreateLabel("Graphics Config", 425, 350, 115, 18)
GUICtrlSetFont(-1, 10, 1000, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "Opti_Options")

$iMLConfig = GUICtrlCreateLabel("Launcher Config", 575, 350, 160, 18)
GUICtrlSetFont(-1, 10, 1000, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "LauncherOptions")
#endregion ; Menu








;;;;;;;;;
GUISetState() ;show the controls window
;;;;;;;;;
Local $iMsg, $aInfo, $f_ClkThrough = False

Do

    $iMsg = GUIGetMsg(1) ;use advanced method for there are multiple GUIs


    Switch $iMsg[1]
        Case $hControls_GUI ;msg is received from controls gui
            Switch $iMsg[0]

                Case $iCloseButton ;close btn is clicked
                    ExitLoop


            EndSwitch

    EndSwitch



    $aInfo = GUIGetCursorInfo($hControls_GUI)
    If @error Then ContinueLoop

    ;enable clickthrough for the invisible control gui
    If $aInfo[4] = 0 And $f_ClkThrough = False Then
        _WinSetClickThrough($hControls_GUI)
        $f_ClkThrough = True

    ElseIf $aInfo[4] And $f_ClkThrough Then
        _WinSetClickThrough($hControls_GUI, False)
        $f_ClkThrough = False

    EndIf


Until $iMsg[0] = $GUI_EVENT_CLOSE


#region ;Version check and update
Func UpdateVersion()
  GUICtrlSetFont($iCheckUpdates, 10, 1000, 6, "MS Sans Serif")
EndFunc   ;==>UpdateVersion
#endregion ;Version check and update

#region ;About and help
Func AboutInfo()

EndFunc   ;==>AboutInfo

Func HelpInfo()

EndFunc   ;==>HelpInfo
#endregion ;About and help

#region ;Options section
Func LauncherOptions()

EndFunc

Func Opti_Options()

EndFunc
#endregion

Func CloseGUI()
GUIDelete("End-Hancer")
Exit
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func _WinSetClickThrough($hWin, $iCLickThrough = True)

    Local $iExStyle = GUIGetStyle($hWin)
    $iExStyle = $iExStyle[1]

    If $iCLickThrough Then
        $iExStyle = BitOR($iExStyle, $WS_EX_TRANSPARENT)
    Else
        $iExStyle = BitXOR($iExStyle, $WS_EX_TRANSPARENT)
    EndIf

    Return GUISetStyle(Default, $iExStyle)
EndFunc   ;==>_WinSetClickThrough



;I have not created the following functions..

Func _GUICreate_Alpha($sTitle, $sPath, ByRef $iWidth, ByRef $iHeight, $iX = -1, $iY = -1, $iOpacity = 255)
    Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hImage = _GDIPlus_ImageLoadFromFile($sPath)
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED)

    SetBitmap($hGUI, $hImage, $iOpacity)

    _GDIPlus_ImageDispose($hImage)

    Return $hGUI
EndFunc   ;==>_GUICreate_Alpha

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   ;==>SetBitmap
#endregion;;;;;;GUI Section;;;;;;;

 

 

Why do the SetOnEvent's for the labels not work???

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites

and:

GUICtrlSetOnEvent(-1, "CloseGUI")

.

and you cannot use guigetmsg() in on-event-mode

edit: for long scripts, on-event-mode is preferable.

edit: you make a well structured script. :thumbsup:

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

Opt("GUIOnEventMode", 1)
:)

When I set this to 1 the close function doesn't work, when i set it to 0 only the close function and the dragging function works

I'm super confused

AND:

and:

GUICtrlSetOnEvent(-1, "CloseGUI")
.

and you cannot use guigetmsg() in on-event-mode

explain please

edit: for long scripts, on-event-mode is preferable.

I'm using no-event-mode

edit: you make a well structured script. :thumbsup:

A lot of it was done by PheonixXL, I just try to keep the structure tight and easy to reference

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

 

So the script given by PheonixXL is coded for MessageLoopMode huh..... Ok, I'll see if I can convert it to OnEventMode then, though I haven't a clue how to. Lets see what I can come up with

Thank you btw

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites

#region ; Includes
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <Array.au3>
#endregion ; Includes

Opt("GUIOnEventMode", 1)

#region;;;;;;GUI Section;;;;;;;
Global $sFile = "C:\prog_res\Lab\test_res\ciik.png"

Global Const $AC_SRC_ALPHA = 1
Global $iWidth, $iHeight, $hRegion
Global $___hNew_WndProc, $___pNew_WndProc, $___pOld_WndProc

_GDIPlus_Startup()

$s_Bitmap = $sFile ;http://img823.imageshack.us/img823/8938/ciik.png - link given by the OP at http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/#entry1102795
$hLayeredGUI = _GUICreate_Alpha("End-Hancer", $s_Bitmap, $iWidth, $iHeight)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState() ;show the main gui

;when the background color and the transcolor are the same of a layered GUI we recieve transparent background
;this would create an invisible window
$hControls_GUI = GUICreate("ControlGUI", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $hLayeredGUI)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hControls_GUI, 0xABCDEF, 230) ;set transparency to 230

;the close button you can use icon also
$iCloseButton = GUICtrlCreateLabel("X", 175, 260, 10, 10)
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "CloseGUI")

;now lets create the so required controls to sync the user interaction
$iProgressBar = GUICtrlCreateProgress(200, 450, 360, 15)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetData(-1, 100) ;set the initial position of the progress to 20

#Region ; Menu
$iCheckUpdates = GUICtrlCreateLabel("Check For Updates", 250, 350, 140, 18)
GUICtrlSetFont(-1, 10, 1000, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "UpdateVersion")

$iGraphicsConfig = GUICtrlCreateLabel("Graphics Config", 425, 350, 115, 18)
GUICtrlSetFont(-1, 10, 1000, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "Opti_Options")

$iMLConfig = GUICtrlCreateLabel("Launcher Config", 575, 350, 160, 18)
GUICtrlSetFont(-1, 10, 1000, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetOnEvent(-1, "LauncherOptions")
#endregion ; Menu

;;;;;;;;;
GUISetState() ;show the controls window
;;;;;;;;;
Local $iMsg, $aInfo, $f_ClkThrough = False

While 1
    $aInfo = GUIGetCursorInfo($hControls_GUI)
    If @error Then ContinueLoop

    ;enable clickthrough for the invisible control gui
    If $aInfo[4] = 0 And $f_ClkThrough = False Then
        _WinSetClickThrough($hControls_GUI)
        $f_ClkThrough = True

    ElseIf $aInfo[4] And $f_ClkThrough Then
        _WinSetClickThrough($hControls_GUI, False)
        $f_ClkThrough = False

    EndIf
WEnd


#region ;Version check and update
Func UpdateVersion()
  GUICtrlSetFont($iCheckUpdates, 10, 1000, 6, "MS Sans Serif")
EndFunc   ;==>UpdateVersion
#endregion ;Version check and update

#region ;About and help
Func AboutInfo()

EndFunc   ;==>AboutInfo

Func HelpInfo()

EndFunc   ;==>HelpInfo
#endregion ;About and help

#region ;Options section
Func LauncherOptions()

EndFunc

Func Opti_Options()

EndFunc
#endregion

Func CloseGUI()
GUIDelete("End-Hancer")
Exit
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func _WinSetClickThrough($hWin, $iCLickThrough = True)

    Local $iExStyle = GUIGetStyle($hWin)
    $iExStyle = $iExStyle[1]

    If $iCLickThrough Then
        $iExStyle = BitOR($iExStyle, $WS_EX_TRANSPARENT)
    Else
        $iExStyle = BitXOR($iExStyle, $WS_EX_TRANSPARENT)
    EndIf

    Return GUISetStyle(Default, $iExStyle)
EndFunc   ;==>_WinSetClickThrough



;I have not created the following functions..

Func _GUICreate_Alpha($sTitle, $sPath, ByRef $iWidth, ByRef $iHeight, $iX = -1, $iY = -1, $iOpacity = 255)
    Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hImage = _GDIPlus_ImageLoadFromFile($sPath)
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED)

    SetBitmap($hGUI, $hImage, $iOpacity)

    _GDIPlus_ImageDispose($hImage)

    Return $hGUI
EndFunc   ;==>_GUICreate_Alpha

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   ;==>SetBitmap
#endregion;;;;;;GUI Section;;;;;;;

I cannot figure out why this doesn't work. I have the Opt("GUIOnEventMode", 1) set and I have the loop mode converted to a While 1 Func

What am I missing?

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites

.

instead of GUISetOnEvent, you need GUICtrlSetOnEvent for all the controls.

 

Pretend we didn't see that....

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites

I have a quick question...

When I add a Group control to this gui, clicking and dragging the group control drags the controls but not the entire gui.... How can I set it to drag the entire GUI? I've added $GUI_WS_EX_PARENTDRAG to both GUICreate's... all it does is add scrollbars at the bottom of the gui's without solving my issue

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites

$GUI_WS_EX_PARENTDRAG is an EXtended style. you must apply it to the ex style param of the gui and the ex style param of the control(s).

.

;http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/page-2#entry1104018
;Post #19
;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-79839.png
;by Wombat

;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575

$GUI=GUICreate("SLICER by Edano",130,17,1,0,0x80800000,0x100000);$WS_POPUP+$WS_BORDER;$GUI_WS_EX_PARENTDRAG
GUISetIcon(@SystemDir&"\shell32.dll",-45)
GUISetFont(8,1000,0,"Arial")
GUISetBkColor(0)
GUICtrlSetState(GUICtrlCreateLabel("",0,0,130,19),128)
GUICtrlSetBkColor(-1,0xFFFFFF)    ; by Edano
GUICtrlSetFont(GUICtrlCreateLabel("      SLICER",0,1,98,14,512,0x100000),9);,800,0,"Tahoma");ex_parentdrag
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetColor(-1,0xFFFFFF)
GUICtrlCreateIcon(@SystemDir&"\shell32.dll",-45,2,3,10,10)
GUICtrlSetCursor(GUICtrlCreateLabel("+",98,1,10,14,512,0x100000),0);ex_parentdrag
GUICtrlSetTip(-1,"Always on top")
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetColor(-1,0xFFFFFF)
;GUICtrlSetOnEvent(-1,"_Top")
GUICtrlSetFont(-1,11)
GUICtrlSetCursor(GUICtrlCreateLabel(Chr(150),108,1,10,14,513,0x100000),0);ex_parentdrag
;GUICtrlSetOnEvent(-1,"_Minimize");      "–"
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetColor(-1,0xFFFFFF)
;GUICtrlSetTip(-1,"Minimize")
GUICtrlSetFont(-1,10)
GUICtrlSetCursor(GUICtrlCreateLabel("x",118,1,12,14,513,0x100000),0);ex_parentdrag
GUICtrlSetBkColor(-1,0xFF0000)
;GUICtrlSetOnEvent(-1,"_Exit")
GUICtrlSetColor(-1,0xFFFFFF)
GUICtrlSetTip(-1,"Exit")
GUICtrlSetFont(-1,9)
GUICtrlSetBkColor(GUICtrlCreateLabel("",0,16,130,2,-1,0x100000),0xF20000);ex_parentdrag

GUISetState()

while sleep(20)
wend
Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

another way to make the entire gui movable for every control is:

.

;http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/page-2#entry1104018
;Post #19
;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-79839.png
;by Wombat

;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575

Opt("GUIOnEventMode",1)

$GUI=GUICreate("SLICER by Edano",130,17,1,0,0x80800000);,0x100000);$WS_POPUP+$WS_BORDER;$GUI_WS_EX_PARENTDRAG
GUISetIcon(@SystemDir&"\shell32.dll",-45)
GUISetFont(8,1000,0,"Arial")
GUISetBkColor(0)
GUICtrlSetState(GUICtrlCreateLabel("",0,0,130,19),128)
GUICtrlSetBkColor(-1,0xFFFFFF)    ; by Edano
GUICtrlSetFont(GUICtrlCreateLabel("      SLICER",0,1,98,14,512),9);,0x100000),9);,800,0,"Tahoma");ex_parentdrag
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetColor(-1,0xFFFFFF)
GUICtrlCreateIcon(@SystemDir&"\shell32.dll",-45,2,3,10,10)
GUICtrlSetCursor(GUICtrlCreateLabel("+",98,1,10,14,512),0);,0x100000),0);ex_parentdrag
GUICtrlSetTip(-1,"Always on top")
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetColor(-1,0xFFFFFF)
;GUICtrlSetOnEvent(-1,"_Top")
GUICtrlSetFont(-1,11)
GUICtrlSetCursor(GUICtrlCreateLabel(Chr(150),108,1,10,14,513),0);,0x100000),0);ex_parentdrag
;GUICtrlSetOnEvent(-1,"_Minimize");      "–"
GUICtrlSetBkColor(-1,0xFF0000)
GUICtrlSetColor(-1,0xFFFFFF)
;GUICtrlSetTip(-1,"Minimize")
GUICtrlSetFont(-1,10)
GUICtrlSetCursor(GUICtrlCreateLabel("x",118,1,12,14,513),0);,0x100000),0);ex_parentdrag
GUICtrlSetBkColor(-1,0xFF0000)
;GUICtrlSetOnEvent(-1,"_Exit")
GUICtrlSetColor(-1,0xFFFFFF)
GUICtrlSetTip(-1,"Exit")
GUICtrlSetFont(-1,9)
GUICtrlSetBkColor(GUICtrlCreateLabel("",0,16,130,2),0xF20000);,-1,0x100000),0xF20000);ex_parentdrag

GUISetOnEvent(-7,"_Drag")

GUISetState()

while sleep(20)
wend

Func _Drag()
    DllCall("user32.dll","int","SendMessage","hwnd",@GUI_WinHandle,"int",274,"int",0xF012,"int",0)
EndFunc

.

here the gui will move with the mouse as long as left mouse button is pressed over the gui ("-7"). (good for touch screens)

Edit: only in on-event-mode of course

 

Edit: sorry had to edit the code 100 times. should be ok now

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

#region ; Includes
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <Array.au3>
#endregion ; Includes

Opt("GUIOnEventMode", 1)

#region;;;;;;GUI Section;;;;;;;
Global $sFile = "C:\prog_res\Lab\test_res\ciik.png"

Global Const $AC_SRC_ALPHA = 1
Global $iWidth, $iHeight, $hRegion
Global $___hNew_WndProc, $___pNew_WndProc, $___pOld_WndProc

_GDIPlus_Startup()

$s_Bitmap = $sFile
$hLayeredGUI = _GUICreate_Alpha("End-Hancer", $s_Bitmap, $iWidth, $iHeight)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState() ;show the main gui

;when the background color and the transcolor are the same of a layered GUI we receive transparent background
;this would create an invisible window
$hControls_GUI = GUICreate("ControlGUI", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $hLayeredGUI)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hControls_GUI, 0xABCDEF, 230) ;set transparency to 230

;the close button you can use icon also
$iCloseButton = GUICtrlCreateLabel("X", 175, 260, 10, 10)
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "CloseGUI")

;now lets create the so required controls to sync the user interaction
$iProgressBar = GUICtrlCreateProgress(200, 450, 360, 15)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetData(-1, 100) ;set the initial position of the progress to 20

#Region ; Menu
Global $iCheckUpdates = GUICtrlCreateLabel("Check For Updates", 250, 350, 140, 18, BitOR($SS_SUNKEN,$WS_BORDER))
GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "UpdateVersion")

Global $iGraphicsConfig = GUICtrlCreateLabel("Graphics Config", 425, 350, 115, 18, BitOR($SS_SUNKEN,$WS_BORDER))
GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "Opti_Options")

Global $iMLConfig = GUICtrlCreateLabel("Launcher Config", 575, 350, 160, 18, BitOR($SS_SUNKEN,$WS_BORDER))
GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "LauncherOptions")
#endregion ; Menu

$iDataBox = GUICtrlCreateGroup("", 250, 450, 300, 200)

;;;;;;;;;
GUISetState() ;show the controls window
;;;;;;;;;
Local $iMsg, $aInfo, $f_ClkThrough = False

While 1
    $aInfo = GUIGetCursorInfo($hControls_GUI)
    If @error Then ContinueLoop

    ;enable clickthrough for the invisible control gui
    If $aInfo[4] = 0 And $f_ClkThrough = False Then
        _WinSetClickThrough($hControls_GUI)
        $f_ClkThrough = True

    ElseIf $aInfo[4] And $f_ClkThrough Then
        _WinSetClickThrough($hControls_GUI, False)
        $f_ClkThrough = False

    EndIf


WEnd


#region ;Version check and update
Func UpdateVersion()
    GUICtrlSetBkColor($iCheckUpdates,0x6E6E6E)
        GUICtrlSetBkColor($iMLConfig,0xABCDEF)
            GUICtrlSetBkColor($iGraphicsConfig,0xABCDEF)
EndFunc   ;==>UpdateVersion
#endregion ;Version check and update

#region ;About and help
Func AboutInfo()

EndFunc   ;==>AboutInfo

Func HelpInfo()

EndFunc   ;==>HelpInfo
#endregion ;About and help

#region ;Options section
Func LauncherOptions()
    GUICtrlSetBkColor($iMLConfig,0x6E6E6E)
        GUICtrlSetBkColor($iCheckUpdates,0xABCDEF)
            GUICtrlSetBkColor($iGraphicsConfig,0xABCDEF)
EndFunc

Func Opti_Options()
    GUICtrlSetBkColor($iGraphicsConfig,0x6E6E6E)
        GUICtrlSetBkColor($iMLConfig,0xABCDEF)
            GUICtrlSetBkColor($iCheckUpdates,0xABCDEF)
EndFunc
#endregion

Func CloseGUI()
GUIDelete("End-Hancer")
Exit
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func _WinSetClickThrough($hWin, $iCLickThrough = True)

    Local $iExStyle = GUIGetStyle($hWin)
    $iExStyle = $iExStyle[1]

    If $iCLickThrough Then
        $iExStyle = BitOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT))
    Else
        $iExStyle = BitOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT))
    EndIf

    Return GUISetStyle(Default, $iExStyle)
EndFunc   ;==>_WinSetClickThrough



;I have not created the following functions..

Func _GUICreate_Alpha($sTitle, $sPath, ByRef $iWidth, ByRef $iHeight, $iX = -1, $iY = -1, $iOpacity = 255)
    Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hImage = _GDIPlus_ImageLoadFromFile($sPath)
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED)

    SetBitmap($hGUI, $hImage, $iOpacity)

    _GDIPlus_ImageDispose($hImage)

    Return $hGUI
EndFunc   ;==>_GUICreate_Alpha

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   ;==>SetBitmap
#endregion;;;;;;GUI Section;;;;;;;

So I had to dd the $GUI_WS__EX_PARENTDRAG to

Func _WinSetClickThrough($hWin, $iCLickThrough = True)

    Local $iExStyle = GUIGetStyle($hWin)
    $iExStyle = $iExStyle[1]

    If $iCLickThrough Then
        $iExStyle = BitOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT))
    Else
        $iExStyle = BitOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT))
    EndIf

    Return GUISetStyle(Default, $iExStyle)
EndFunc   ;==>_WinSetClickThrough

because adding it anywhere else failed miserably..... Adding it as such in the above code made the control GUI drag the parent as it should.. BUT not the controls cannot be clicked on... is this a bug???

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

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

    No registered users viewing this page.

×
×
  • Create New...