Jump to content
Sign in to follow this  
realkiller

gui problem using button

Recommended Posts

realkiller

if i run the gui witout the selfmade button everyting go's fine but if i run the gui with the selfmade button the gui turns black and wont respond anyone got a solution? thx adv

#include <A3LGDIPlus.au3> 
#include <GuiCombo.au3>
#Include <File.au3>
#include <Array.au3>
#include <GUIConstants.au3>
Opt("MustDeclareVars", 0)
Opt("TrayIconHide", 0)

Global Const $AC_SRC_ALPHA      = 1
Global Const $ULW_ALPHA         = 2
Global $old_string = "", $runthis = ""
Global $launchDir = @DesktopDir


_GDIP_Startup()
$pngSrc = @scriptdir&"\Remote IT GUI.png"
$hImage = _GDIP_ImageLoadFromFile($pngSrc)
$width =  _GDIP_ImageGetWidth ($hImage)
$height = _GDIP_ImageGetHeight($hImage)
$GUI = GUICreate("Remote IT", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)



SetBitMap($GUI, $hImage, 0)


GUISetState()

for $i = 0 to 255 step 10
    SetBitMap($GUI, $hImage, $i)
next


$ic = GUICtrlCreatePic("1.jpg",0,0,100,23)
GUICtrlSetState(-1, $GUI_DISABLE)
$b = GUICtrlCreatePic("2.jpg",0,0,100,23)
GUICtrlSetState(-1,$GUI_HIDE)
$2 =  GUICtrlCreatePic("3.jpg",0,0,100,23)
GUICtrlSetState(-1,$GUI_HIDE)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")


$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
    $msg = GUIGetMsg()
        $c = GUIGetCursorInfo($GUI)
    If $c[4] = $ic Then
        GUICtrlSetState( $b, $GUI_SHOW)
        GUICtrlSetState( $ic, $GUI_HIDE)
        $c = GUIGetCursorInfo($GUI)
            While $c[4] = $b
                If GUIGetMsg() = $b Then Do_Function()
                $c = GUIGetCursorInfo($GUI)
            WEnd
        GUICtrlSetState( $2, $GUI_HIDE)
        GUICtrlSetState( $b, $GUI_HIDE)
        GUICtrlSetState( $ic, $GUI_SHOW)
        EndIf
    Select
        
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd



AdlibDisable ()
if $runthis <> "" then 
    if fileexists($launchDir & "\" & $runthis) then 
        beep(1000,50)
        beep(2000,50)
        _ShellExecute($runthis, "", $launchDir)
    EndIf
EndIf
GUIDelete($controlGui)
for $i = 255 to 0 step -10
    SetBitMap($GUI, $hImage, $i)
next
_API_DeleteObject($hImage)
_GDIP_Shutdown()






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  = _API_GetDC(0)
  $hMemDC  = _API_CreateCompatibleDC($hScrDC)
  $hBitmap = _GDIP_BitmapCreateHBITMAPFromBitmap($hImage)
  $hOld    = _API_SelectObject($hMemDC, $hBitmap)
  $tSize   = DllStructCreate($tagSIZE)
  $pSize   = DllStructGetPtr($tSize  )
  DllStructSetData($tSize, "X", _GDIP_ImageGetWidth ($hImage))
  DllStructSetData($tSize, "Y", _GDIP_ImageGetHeight($hImage))
  $tSource = DllStructCreate($tagPOINT)
  $pSource = DllStructGetPtr($tSource)
  $tBlend  = DllStructCreate($tagBLENDFUNCTION)
  $pBlend  = DllStructGetPtr($tBlend)
  DllStructSetData($tBlend, "Alpha" , $iOpacity    )
  DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
  _API_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
  _API_ReleaseDC   (0, $hScrDC)
  _API_SelectObject($hMemDC, $hOld)
  _API_DeleteObject($hBitmap)
  _API_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

Func Do_Function()
    GUICtrlSetState( $2, $GUI_SHOW)
    MsgBox(0x0, "tset", "OK.....    ", 3)
EndFunc

post-8019-1194749586_thumb.png

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.