Jump to content

Who wants to help me learn enhanced gui building?


Wombat
 Share

Recommended Posts

It's not a bug, it is just the way it works when you do that.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It's not a bug, it is just the way it works when you do that.

 

So is there no way, with the current code i have, to enable parentdrag for the controls GUI? Would I need to rewrite the way the code works to gain this function and not lose the ability to use the labels as buttons?

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 comment
Share on other sites

So is there no way, with the current code i have, to enable parentdrag for the controls GUI? Would I need to rewrite the way the code works to gain this function and not lose the ability to use the labels as buttons?

.

i don't think it's the dragging. if i remove the styles from your script, the controls are still disabled.

i try to find out what you changed from your last posting, but i find no difference. there must be something other wrong

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

Link to comment
Share on other sites

i found it !

;http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/page-2
;Post #40
;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

#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
GUISetOnEvent(-7,"_Drag")

;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)
GUICtrlSetBkColor(-1,0)
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, $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;;;;;;;

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

.

here was the error:

If $iCLickThrough Then
        $iExStyle = BitOR($iExStyle, $WS_EX_TRANSPARENT)
    Else
        $iExStyle = BitXOR($iExStyle, $WS_EX_TRANSPARENT);;;;;; you had  BitOR($iExStyle, $WS_EX_TRANSPARENT)
    EndIf
Edited by Edano

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

Link to comment
Share on other sites

this is your script again with ex-parentdrag

#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 = BitXOR($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;;;;;;;

you simply forgot the "X" in BitXOr (probably you copied and pasted the line)

the script above this script is with guisetonevent drag, both work fine now.

E :)

Edited by Edano

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

Link to comment
Share on other sites

this is your script again with ex-parentdrag

#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 = BitXOR($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;;;;;;;

you simply forgot the "X" in BitXOr (probably you copied and pasted the line)

the script above this script is with guisetonevent drag, both work fine now.

E :)

 

it still isn't working... the controls gui isn't dragging the .png gui :(

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 comment
Share on other sites

hi wombat

now i am beginning to get confused. what do you want to achieve ? your last question was to enable the control gui again, and i did it. now you want the control gui to move ? then you have to apply the ex_parentdrag style to the control gui and all controls that are supposed to drag it (that's what i said above). like this:

.

;http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/page-3
;Post #47
;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

#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 = "ciik.png";C:\prog_res\Lab\test_res\

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,$GUI_WS_EX_PARENTDRAG), $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,-1,$GUI_WS_EX_PARENTDRAG)
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,-1,$GUI_WS_EX_PARENTDRAG)
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),$GUI_WS_EX_PARENTDRAG)
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),$GUI_WS_EX_PARENTDRAG)
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),$GUI_WS_EX_PARENTDRAG)
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 = BitXOR($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;;;;;;;

.

but now you want the controls to move the parent gui ?

ok, then i ask for your entire concept, because: why don't you put everything in one gui ?

there are more possibilities to move two windows synchronously. you could for example register the gui message "WM_MOVE". or you could add some code to the _Drag() function i gave you:

.

Func _Drag()
    DllCall("user32.dll","int","SendMessage","hwnd",@GUI_WinHandle,"int",274,"int",0xF012,"int",0)
;====> if @gui_winhandle=controlgui then move parent gui (winmove) or similar
EndFunc

.

or there is _WinApi_SetParent(). and much more.

this is all up to you, but it depends on the concept. you should play around a bit with all the tools i gave you and think about the entire concept, so you don't reach a point where you get stuck. sometimes it's good to step back and simplify things instead of making it even more complicated (ockham's razor). basically, you can do (nearly) everything with AutoIt in one or the other way.

cheers E. :)

Edited by Edano

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

Link to comment
Share on other sites

Thanks Edano, I believe I miscommunicated what I was trying to achieve. I want the child gui to drag the parent so that it appears as one consistent gui when its really two... I'll take your code and suggestions and head back to the workshop :)

Edit: I actually think the solution would be to condense the code into one gui and not use two....

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 comment
Share on other sites

Thanks Edano, I believe I miscommunicated what I was trying to achieve. I want the child gui to drag the parent so that it appears as one consistent gui when its really two... I'll take your code and suggestions and head back to the workshop :)

Edit: I actually think the solution would be to condense the code into one gui and not use two....

.

sounds good :)

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...