Jump to content

Help !!! transperency on Lbls and Icons


Recommended Posts

Hi

i have some problemes in gettings my Lables and icons to be transperent,

i can make my labels transperent with guictrlsetbgkcolor(-1,"-2") but then the texts look weird. As it is to thick

i can't get my icons to be transpent either Plz Plz Plz some help me

Ps. is there any way i can change the default push button to the currenly active button?

#cs*****************************************
Proxy_Switch.au3 by Krabbe
Created with ISN AutoIt Studio v. 0.94 BETA
Created with ISN Form Studio 2 for ISN AutoIt Studio
Script Version: 1.0
Last Modified: 21-11-2013
Script Function:
Enable and Disable proxy settings in IE as user don't normaly know the path

#ce*****************************************

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
#Include <GuiButton.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <IE.au3>

Global $WlanInf[7]
Global $LanInf[7]
Global $PXYSVR = "proxy.intranet.ap"
Global $PXYPRT = "80"
Global $RegKeyLoc = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Global $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20
Global $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
Global $hImage = @Scriptdir& "\Images\hGUI1.png"
Global $cImage = @Scriptdir& "\Images\cGUI.gif"
Global $hGUI, $cGUI, $BtnEnableDisable, $BtnExit
Global $LblCurrentConnect, $LblCurrentState, $LblSuggestSetting
Global $RegGetProxyCurAdr, $RegGetProxyState

#cs==========$WlanInf============   #cs==========$LanInf=============
| [0] = Name                    |   | [0] = Name                    |
| [1] = MacAdress               |   | [1] = MacAdress               |
| [2] = Connect True/False      |   | [2] = Connect True/False      |
| [3] = Connected 2 Domain name |   | [3] = Connected 2 Domain name |
| [4] = Your Computer Domain    |   | [4] = Your Computer Domain    |
| [5] = IpAdress                |   | [5] = IpAdress                |
| [6] = Gateway                 |   | [6] = Gateway                 |
#ce==============================   #ce==============================
;====================================== Start GDI Magic ================================

_GDIPlus_Startup()                                ; Initialize GDI+ library
$hImage = _GDIPlus_ImageLoadFromFile($hImage) ; Main GUI Bckg Img
$width = _GDIPlus_ImageGetWidth($hImage)          ; Img Width  | GUI Width
$height = _GDIPlus_ImageGetHeight($hImage)        ; Img Height | GUI Height


_MainUI()

Func _MainUI()
Global $hGUI = GUICreate("MSI Recovery Image Finder", $width, $height, -1, -1, $WS_POPUP,$WS_EX_LAYERED)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState(@SW_SHOW,$hGUI)
 For $i = 0 To 240 Step 10
   SetBitmap($hGUI, $hImage, $i)
   Sleep(10)
 Next

Global $cGUI = GUICreate('childgui', $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD,$GUI_WS_EX_PARENTDRAG), $hGUI)
$ChildBckg = GUICtrlCreatePic($cImage, 0, 0, $width, $height)
GUICtrlSetBkColor($ChildBckg, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState($ChildBckg, $GUI_DISABLE)

Global $BtnEnable = GUICtrlCreateButton("Enable",75,85,60,20,$BS_DEFPUSHBUTTON,-1)
GUICtrlSetFont(-1,8,400,0,"Constantia")

Global $BtnDisable = GUICtrlCreateButton("Disable",165,85,60,20,$BS_DEFPUSHBUTTON,-1)
GUICtrlSetFont(-1,8,400,0,"Constantia")

Global $LblCurrentSetting = GUICtrlCreateLabel("",226,35,42,15,-1,-1)
GUICtrlSetFont($LblCurrentSetting,8,400,0,"Constantia")

Global $LblSuggestSetting = GUICtrlCreateLabel("",226,50,42,15,-1,-1)
GUICtrlSetFont($LblSuggestSetting,8,400,0,"Constantia")

Global $LblCurrentConnect = GUICtrlCreateLabel("proxy.intranet.ap:80",173,65,95,15,-1,-1)
GUICtrlSetFont($LblCurrentConnect,8,100,0,"Constantia")
;~ GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)

Global $IcnExit = GUICtrlCreateIcon("imageres.dll",98,267,10,16,16,-1,-1)
GUICtrlSetBkColor($IcnExit,$GUI_BKCOLOR_TRANSPARENT)

Global $IcnHelp = GUICtrlCreateIcon("imageres.dll",99,249,10,16,16,-1,-1)
GUICtrlSetBkColor($IcnHelp,0x373737)

_GetCurrentProxyState()
_GetActiveSSID()
GUISetState(@SW_SHOW,$cGUI)




    
While 1

_ChkIfProxyStateChanged()
$nMsg = GUIGetMsg()
    Switch $nMsg
        
        Case $GUI_EVENT_CLOSE, $IcnExit
            Exit
        
        Case $IcnHelp
            MsgBox(16,"Help","Coming Soon")
            
        Case $BtnEnable
            $RegWriteProxyEnable = RegWrite($RegKeyLoc, "ProxyEnable", "REG_DWORD", "1")
            DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
            $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
            If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") =  Failed  >Error code: ' & @error & @crlf) ;### Debug Console
            BitAND(GUICtrlSetState($BtnDisable,$GUI_ENABLE),GUICtrlSetState($BtnEnable,$GUI_DISABLE))
            BitAND(GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr),GUICtrlSetData($LblCurrentSetting,"Enabled"))
            
            
        Case $BtnDisable
            $RegWriteProxyDisable = RegWrite($RegKeyLoc, "ProxyEnable", "REG_DWORD", "0")
            DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
            $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
            If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") =  Failed  >Error code: ' & @error & @crlf) ;### Debug Console
            BitAND(GUICtrlSetState($BtnDisable,$GUI_DISABLE),GUICtrlSetState($BtnEnable,$GUI_ENABLE))
            BitAND(GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr),GUICtrlSetData($LblCurrentSetting,"Disabled"))
            
    EndSwitch
WEnd
EndFunc

Func _GetCurrentProxyState()
$RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") =  Failed  >Error code: ' & @error & @crlf) ;### Debug Console
ConsoleWrite('$RegGetProxyCurAdr = ' & $RegGetProxyCurAdr & '   >Error code: ' & @error & @crlf) ;### Debug Console
;~ If $RegGetProxyCurAdr <> "proxy.intranet.ap:80" Then
;~      $RegWriteProxyAdr = RegWrite($RegKeyLoc, "ProxyServer", "REG_SZ", $PXYSVR & ":" & $PXYPRT)
;~      DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
;~      $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
;~      GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
;~  Else
;~      $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
;~      GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
;~ EndIf
$RegGetProxyState = RegRead($RegKeyLoc,"ProxyEnable")
ConsoleWrite('$RegGetProxyState = ' & $RegGetProxyState & ' >Error code: ' & @error & @crlf) ;### Debug Console
If $RegGetProxyState = 0 Then BitAND(GUICtrlSetData($LblCurrentState,"Disabled"),GUICtrlSetState($BtnEnable,$GUI_ENABLE),GUICtrlSetState($BtnDisable,$GUI_DISABLE))
If $RegGetProxyState = 1 Then BitAND(GUICtrlSetData($LblCurrentState,"Enabled"),GUICtrlSetState($BtnEnable,$GUI_DISABLE),GUICtrlSetState($BtnDisable,$GUI_ENABLE))
EndFunc

Func _ChkIfProxyStateChanged()
$RegGetProxyState = RegRead($RegKeyLoc,"ProxyEnable")
ConsoleWrite('Current Proxy State = ' & $RegGetProxyState & '   >Error code: ' & @error & @crlf)

; If user changes proxy manualy while the prg is running
If GUICtrlRead($LblCurrentSetting)="Enabled" And $RegGetProxyState = 0 Then
        GUICtrlSetState($BtnDisable,$GUI_DISABLE)
        GUICtrlSetState($BtnEnable,$GUI_ENABLE)
        GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
        GUICtrlSetData($LblCurrentSetting,"Disabled")
EndIf

; If user changes proxy manualy while the prg is running    
If GUICtrlRead($LblCurrentSetting)="Disabled" And $RegGetProxyState = 1 Then
        GUICtrlSetState($BtnDisable,$GUI_ENABLE)
        GUICtrlSetState($BtnEnable,$GUI_DISABLE)
        GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
        GUICtrlSetData($LblCurrentSetting,"Enabled")
EndIf

EndFunc

Func _GetActiveSSID()
Global $Output = "", $colItems = "", $colItems1 = ""

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
   For $objItem In $colItems
    If StringInStr($objItem.Caption,"Intel") Then
        If $objItem.NetConnectionID = "Wireless Network Connection" Then
            $WlanInf[0] = $objItem.Description
            $WlanInf[1] = $objItem.MACAddress
            $WlanInf[2] = $objItem.NetEnabled
        ElseIf  $objItem.NetConnectionID = "Local Area Connection" Then
            $LanInf[0] = $objItem.Description
            $LanInf[1] = $objItem.MACAddress
            $LanInf[2] = $objItem.NetEnabled
        EndIf
        $Output=""
    EndIf
   Next
Else
   Msgbox(0,"WMI Output ERROR","No WMI Objects Found for class: " & "Win32_NetworkAdapter",2)
   SetError(1,0,"Error in WMI Win32_NetworkAdapter")
Endif

$colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems1) then
   For $objItem In $colItems1
    If StringInStr($objItem.Caption,"Intel") <> 0 Then
        If BitAND($WlanInf[1] = $objItem.MACAddress, $WlanInf[0] = $objItem.Description) Then
            $WlanInf[3] = $objItem.DNSDomain
            $WlanInf[4] = $objItem.DNSDomainSuffixSearchOrder(0)
            $WlanInf[5] = $objItem.IPAddress(0)
            $WlanInf[6] = $objItem.DefaultIPGateway(0)
        ElseIf BitAND($LanInf[1] = $objItem.MACAddress, $LanInf[0] = $objItem.Description) Then
            $LanInf[3] = $objItem.DNSDomain
            $LanInf[4] = $objItem.DNSDomainSuffixSearchOrder(0)
            $LanInf[5] = $objItem.IPAddress(0)
            $LanInf[6] = $objItem.DefaultIPGateway(0)
        EndIf 
    EndIf
   Next
Else
   Msgbox(0,"WMI Output ERROR","No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration",2)
   SetError(2,0,"Error in WMI Win32_NetworkAdapterConfiguration")
Endif

If $LanInf[3] <> "intranet.ap" Then 
    GUICtrlSetData($LblSuggestSetting,"Disabled")
Else
    GUICtrlSetData($LblSuggestSetting,"Enabled")
EndIf

EndFunc  

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $hGUI) 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", 1)
    _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

post-62798-0-26861300-1385380029_thumb.p

post-62798-0-79065300-1385380038_thumb.g

Edited by islandspapand
Link to post
Share on other sites
Ps. is there any way i can change the default push button to the currenly active button?

 

You can use the button style $BS_DEFPUSHBUTTON

Your main problem is the graphic part, that is how your GUI should look. Then can you provide an image of how your GUI should look ?

Regards :)

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

Thanks allot,

I was thinking that i want both Buttons to have $bs_defpushbutton, so the enabled button is the default push.

What sould i do to change between the Buttons as i guess there ONLY can Be One default push.

Picture of disired GUI add'ed (still with the grey around the icons and Labels that i wish to remove)
 

post-62798-0-46032900-1385384145_thumb.p

Edited by islandspapand
Link to post
Share on other sites

Graphics part

Here we go

#include-once
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>

Global $hImage = @ScriptDir & "\Images\hGUI1.png"

_GDIPlus_Startup() ; Initialize GDI+ library
$hImage = _GDIPlus_ImageLoadFromFile($hImage) ; Main GUI Bckg Img
$width = _GDIPlus_ImageGetWidth($hImage) ; Img Width  | GUI Width
$height = _GDIPlus_ImageGetHeight($hImage) ; Img Height | GUI Height


_MainUI()

Func _MainUI()
    Global $hGUI = GUICreate("MSI Recovery Image Finder", $width, $height, -1, -1, $WS_POPUP,$WS_EX_LAYERED)
    GUISetState(@SW_SHOW, $hGUI)

    Global $cGUI = GUICreate('childgui', $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI)
    GUISetBkColor(0xFFFFFF)
    _WinAPI_SetLayeredWindowAttributes($cGUI, 0xFFFFFF)

    Global $BtnDisable = GUICtrlCreateButton("Disable", 165, 85, 60, 20)
    GUICtrlSetFont(-1, 8, 400, 0, "Constantia")

    Global $BtnEnable = GUICtrlCreateButton("Enable", 75, 85, 60, 20)
    GUICtrlSetFont(-1, 8, 400, 0, "Constantia")

    GUICtrlSetDefBkColor($GUI_BKCOLOR_TRANSPARENT)

    Global $LblCurrentSetting = GUICtrlCreateLabel("Enabled", 226, 40, 42, 15, -1, -1)
    Global $LblSuggestSetting = GUICtrlCreateLabel("Enabled", 226, 52, 42, 15, -1, -1)


    Global $LblCurrentConnect = GUICtrlCreateLabel("proxy.intranet.ap:80", 173, 65, 95, 15)
    GUICtrlSetFont($LblCurrentConnect, 8, 100, 0, "Constantia")
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    Global $IcnExit = GUICtrlCreateIcon("imageres.dll", 98, 267, 10, 16, 16, BitOR($SS_ICON, $SS_NOTIFY))
    Global $IcnHelp = GUICtrlCreateIcon("imageres.dll", 99, 249, 10, 16, 16, $BS_ICON)

    GUISetState(@SW_SHOW, $cGUI)

    For $i = 0 To 240 Step 10
        SetBitmap($hGUI, $hImage, $i)
        Sleep(10)
    Next


    While 1

        $nMsg = GUIGetMsg()
        Switch $nMsg

            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $GUI_EVENT_PRIMARYDOWN
                _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) ;SC_DRAGMOVE = 0xF012

            Case $BtnEnable
                GUICtrlSetState($BtnEnable, $GUI_DISABLE)
                GUICtrlSetState($BtnDisable, $GUI_ENABLE)
                GUICtrlSetState($BtnDisable, $GUI_FOCUS)


            Case $BtnDisable
                GUICtrlSetState($BtnDisable, $GUI_DISABLE)
                GUICtrlSetState($BtnEnable, $GUI_ENABLE)
                GUICtrlSetState($BtnEnable, $GUI_FOCUS)

        EndSwitch
    WEnd

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

EndFunc   ;==>_MainUI

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", 1)
    _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 

Regards :)

Phoenix XL

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

Thank you sooooooooooooo much Phoenix XL :D

i was playing around with the     GUISetBkColor(0xABCDEF)   _WinAPI_SetLayeredWindowAttributes($cGUI, 0xABCDEF) could just not get it to work :P

Could you expaind this part to me?

    

        Case $GUI_EVENT_PRIMARYDOWN
                _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) ;SC_DRAGMOVE = 0xF012

if i want the blue around the labels to dissaper then i sould just change to the same color as my background?

Edited by islandspapand
Link to post
Share on other sites

The painting occurs with respect to the bkcolor of the layered window.

I have modified the code (the bkcolor and a bit cleanup), check it by yourself.

_SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) ;SC_DRAGMOVE = 0xF012

 

It is responsible to move the GUI whenever you drag the main GUI(instead of hittesting, this is preferred).

Regards :)

Phoenix XL

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

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.

  • Similar Content

    • By UEZ
      I'm searching for a way to set an icon for a system menu entry in the console window. I can add / remove entries but I didn't find a way to set an icon for the entry I made.
      Example:
      #AutoIt3Wrapper_Change2CUI=y #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WindowsConstants.au3> Global $id_Test = 5000 Global $hConsole = HWnd(DllCall("kernel32.dll", "hwnd", "GetConsoleWindow")[0]) If Not $hConsole Then Exit HotKeySet("{ESC}", "_Exit") Global $hSysmenu = _GUICtrlMenu_GetSystemMenu($hConsole) Global $iCount = _GUICtrlMenu_GetItemCount ($hSysmenu) _GUICtrlMenu_InsertMenuItem($hSysmenu, $iCount, "Test", $id_Test) _GDIPlus_Startup() $hBitmap_GDI = _GDIPlus_BitmapCreateFromMemory(_Test(), True) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hBitmap_GDI = ' & $hBitmap_GDI & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $hBmp1 = _WinAPI_CreateSolidBitmap($hConsole, 0xFF0000, 16, 16) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hBmp1 = ' & $hBmp1 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $hBmp2 = _WinAPI_CreateSolidBitmap($hConsole, 0x00FF00, 16, 16) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hBmp2 = ' & $hBmp2 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;ConsoleWrite(_GUICtrlMenu_SetItemBmp($hSysmenu, $id_Test, $hBitmap_GDI, False) & @CRLF) ConsoleWrite(_GUICtrlMenu_SetItemBitmaps($hSysmenu, $id_Test, $hBmp1, $hBmp2, False) & ", " & @error & @CRLF) ;_GUICtrlMenu_SetItemBmp($hSysmenu, $id_Test, 8, False) ;set the default close icon _GDIPlus_Shutdown() Do Sleep(1000) Until False Func _Exit() ConsoleWrite("Bye..." & @CRLF) _GUICtrlMenu_DeleteMenu ($hSysmenu, $id_Test, False) _WinAPI_DeleteObject($hBitmap_GDI) _WinAPI_DeleteObject($hBmp1) _WinAPI_DeleteObject($hBmp2) Exit EndFunc ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2020-06-05 Func _Test($bSaveBinary = False, $sSavePath = @ScriptDir) Local $Test $Test &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA3XAAAN1wFCKJt4AAADKElEQVQ4yz2RT2gcdRTHP7+Z36y7yzZZdvJv22i0rBpiAwnWCMZrUCGIBxEvpQSEHAQhePLkyUKg6Em9iZCcahH0pFYxkIqiIdHKYmPUUHcDmU2TuJnZzc7s/H7PQ5M8ePAu7/M+X56y1hKGYY+IOEDqOI6TzWY1gFIKEcF1XRzHUWmaJnF8bHBy5pfbnz9fb0hBh2F4bm5ubjWKogudTqdVqVT0/Py853kehUKBQqHA2tqaVKtVfenS2P6HH396PDri9D9+cdC/8dkXNW2t9fb29spRFPmtVqtULBaVMYZ8Pk82m8X3farVKjdv3qCn+FbpnFuXfNpQkkwlX33z3RtaKYXW2mqtcV1XtNZks9kzQCaTIeNp4sSh8rAnzSe0HO5bt1arHR51y79pEcEYo05Aylp7OqOUIk0TRp+aYO5Ki3B3VR3s70pictzZGlC5jHW0UgprLVEU4Xke29vbLCwsoLXGcRRxYjk/2MtLz2X4/tvbaO3y9XoPlUe7CI7VAMYYPM+jXC5jrcUYAwipUeSzHhV/k59+bFK5OMytOxco9ezQTQ2A4ujoqDQ+Ph4sLS2JiNiDgwM5PDyQ3SCQ/5ptubv6rsy9XJIfvnxbNv/8W+7d+9deu/aeTE9PB2EYljSAiKje3l7SNCUIAkDQXp77f3zE4uJ1Xnv9KoWRK+zs1DlfHiCXy2OtBcA5AdDpdHBdl4F+n77BEdz2z3zw/iKvvHqVZ194h0wmz0B/Ca094jjmtE4NEBFarRa7jfvkHgqp/rrKxOQzjF6+wtY/u4g9Jo5TfL+EiGCtxVqLFhGUUhhjsNZgrcvqrU948rFhKlNvEkUdtNvBoFEqPVtUSqGUQiulaDabtNttPC/D5t3fqTU0Y5dfpNFogFhEOLsaxzHtdpsgCNT6+rrSSZIwOztrhoeH' $Test &= 'qdfrRmutJp6e4q+tKsbYs3in7+7r65OhoSE9MzNjkiRBt9ttkiRxjTHkcjl3bGxMPYhjSdP0rLvdLt1uF9d1BcDzPHdyclL0yspKuLGxcT0IgkeKxaINgsADXBFxAefEQB4ImNT3/W4Yhk6z2awtLy9H/wPnrsNEnFPl4QAAAABJRU5ErkJggg==' Local $bString = _WinAPI_Base64Decode($Test) If @error Then Return SetError(1, 0, 0) $bString = Binary($bString) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\AutoSave_16x16_04.png", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_Test Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc ;==>_WinAPI_Base64Decode  
      You must compile and run it to see the menu entry in the console window.

       
      Any idea?
    • By Jemboy
      Recently I was working on a script with icons using GuiCtrkCreatIcon.
      I decided to change the sub folder name of the icons to a more meaning name, however made a typo.

      I tested the .exe on my test computer and it worked flawlessly (because both icon folder where on my test computer) 😁
      But after I installed the script on the intended computers , I got chaos!😵
      Zooming into the problem, I discovered, that because the icons could not be found, the ControlID were returned with a value of 0
      and thus played havoc within the GuiGetMsg() switch/case statement.
      I have been able to reproduce this  (see example)
      #include <GUIConstantsEx.au3> ;============================================================================================================ ; PLEASE, do not save this example in the example folder: C:\Program Files (x86)\AutoIt3\Examples\Helpfile ;============================================================================================================ Example() Func Example() GUICreate(" My GUI Icons", 250, 250) $Icon1 = GUICtrlCreateIcon("shell32.dll", 10, 20, 20) $Icon2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 20, 40, 32, 32) $Icon3 = GUICtrlCreateIcon("shell32.dll", 7, 20, 75, 32, 32) GUISetState(@SW_SHOW) ;$Icon2 = -1 ; ==> When this line is uncommented the script "works", so -1 could be a potential fix. ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Icon2 Beep (500,500) EndSwitch WEnd GUIDelete() EndFunc ;==>Example If you save the above script outside the Autoit example folder and run it, it will keep beeping because GuiCtrlCreatIcon did not find horse.ani and return $Icon2=0.
      At the moment GUICtrlCreateIcon () only returns the conntrolID on success and 0 on failure.
      I would like to propose a return of -1 on failure, so a existing and working script won't go awry when the icon can not be found.
       
    • By dimm
      Is it possible to compile script without any icon resources included?
      When I make exe it uses default system icon of current OS even if I compile as console application.
      On other versions of Windows it looks a little strange

       
      Update:
      It seems that the only way is remove icons from exe after compilation using resource editors like ResHacker.

       
      another bad solution:
      Using corrupted 35 bytes icon file. Windows can't load it and shows default system icon.
      #pragma compile(Icon, broken.ico) broken.ico
    • By FrancescoDiMuro
      Good evening everyone
      First, I want to apologize with you for the title not very clear, but I thought a little bit on which title to set at the thread, and this is the one that came in mind.
      Now, let me explain what I'm trying to understand.

      I am making an application ( with n clients ), with an SQLite Database, which has a Main form, and n sub-forms... 
      Since these sub-forms are called several times, because they are used to add or update records to the Database, I put the code that generates the GUI of these sub-forms in Functions.
      There are two sub-forms which are "treated" as two main forms, since even them have n sub-forms, which perform various tasks.
      Where am I stucked?

      For the Main form I created a Status Bar, in order to display messages ( add/delete/update/search results ), and it works perfectly with all the forms which don't have other sub-forms.
      For the two forms, which indeed have n sub-forms, I created two separated Status Bars, which are (re)created everytime I call the function that then displays the form.
      Practically, I can't set icons to these two Status Bars, and I don't know why.
      I'm really sorry that I don't feel clear enough, so, here you are an example of what I am saying.
      I recreated exactly what my script does:
      #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $frmSubForm, _ $txtSubFormField, _ $sbSubFormStatusBar, _ $objSB_IconError = _WinAPI_LoadShell32Icon(109), _ $objSB_IconInformation = _WinAPI_LoadShell32Icon(277) #Region ### START Koda GUI section ### Form= $frmMainForm = GUICreate("Main Form", 300, 300, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") $sbMainStatusBar = _GUICtrlStatusBar_Create($frmMainForm) $btnCreateSubForm = GUICtrlCreateButton("Create Sub Form", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "GenerateSubForm") GUICtrlSetFont(-1, 10, 400, 0, "Arial") _GUICtrlStatusBar_SetSimple($sbMainStatusBar) _GUICtrlStatusBar_SetText($sbMainStatusBar, "") GUISetState(@SW_SHOW, $frmMainForm) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func ExitApplication() Exit EndFunc Func GenerateSubForm() #Region ### START Koda GUI section ### Form= $frmSubForm = GUICreate("Sub-Form", 300, 300, -1, -1, -1, -1, $frmMainForm) GUISetOnEvent($GUI_EVENT_CLOSE, "DeleteSubForm") $txtSubFormField = GUICtrlCreateInput("", 0, 0, 100, 20) $btnCheckSubFormField = GUICtrlCreateButton("Check Field", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "CheckSubFormField") GUICtrlSetFont(-1, 10, 400, 0, "Arial") $sbSubFormStatusBar = _GUICtrlStatusBar_Create($frmSubForm) _GUICtrlStatusBar_SetSimple($sbSubFormStatusBar) _GUICtrlStatusBar_SetText($sbSubFormStatusBar, "") GUISetState(@SW_SHOW, $frmSubForm) GUISetState(@SW_DISABLE, $frmMainForm) #EndRegion ### END Koda GUI section ### EndFunc Func DeleteSubForm() ; Declared Globally => $frmSubForm GUIDelete($frmSubForm) GUISetState(@SW_ENABLE, $frmMainForm) EndFunc Func WriteToStatusBar($sbStatusBar, $objSB_Icon, $strText) _GUICtrlStatusBar_SetIcon($sbStatusBar, 0, $objSB_Icon) _GUICtrlStatusBar_SetText($sbStatusBar, $strText) ConsoleWrite("Icon Handle: " & $objSB_Icon & @CRLF) EndFunc Func CheckSubFormField() ; Declared Globally => $txtSubFormField If GUICtrlRead($txtSubFormField) = "" Then ; Declared Globally => $sbStatusBar WriteToStatusBar($sbSubFormStatusBar, $objSB_IconError, "Field NOK.") Else WriteToStatusBar($sbSubFormStatusBar, $objSB_IconInformation, "Field OK.") EndIf EndFunc The text is set, but icon is not.
      Could someone please tell me why?
      Thanks everyone in advance  

      Best Regards.
    • By buymeapc
      Hi all,
      I'm trying to create a listview with subitem icons and I achieved this by simply rearranging the order of the columns, so that the first column is in the middle, thus appearing as a subitem with an icon - this method prevents the "icon clipping" that happens when using subitem icons in a listview. My issue is that when I select a row that does not have an icon, the space where the icon would be is white. Is there a way to make this transparent, so it looks like the entire row is selected?
      Here's an example - click the second listview item/row to see a blank space where the icon would be.
      #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> _Main() Func _Main() Local $hGui, $listview, $hImage Local $iLV_EXStyle_NoChecks = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_HEADERDRAGDROP) $hGui = GUICreate("Listview Test With Icons", 400, 300) $listview = GUICtrlCreateListView("Col 1|Col 2|Col 3", 2, 2, 394, 268, BitOR($LVS_REPORT, $LVS_SHAREIMAGELISTS)) _GUICtrlListView_SetExtendedListViewStyle($listview, $iLV_EXStyle_NoChecks) GUISetState() ; Create the image list $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) _GUICtrlListView_SetImageList($listview, $hImage, 1) ; Set the order so the first column is moved to the middle, ; acting like a subitem with an icon _GUICtrlListView_SetColumnOrder($listview, "1|0|2") ; Add the items GUICtrlCreateListViewItem("Item1|Item2|Item3", $listview) GUICtrlCreateListViewItem("Item4|Item5|Item6", $listview) ; Set an icon for just the first item _GUICtrlListView_SetItemImage($listview, 0, 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main  
×
×
  • Create New...