Jump to content

How to using Transparent GUICtrlCreateInput?


Recommended Posts

input.png?dl=1
 
use font Download

use png Download

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

Global Const $FR_PRIVATE      = 0x10

HotKeySet("ESC", "_Exit")

_GDIPlus_Startup()

;https://www.dropbox.com/s/j3jh9kluew5i5an/input.png
Local $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\input.png")

;https://www.dropbox.com/s/5oydb9tmb21gwlx/HANSomaM.ttf
_WinAPI_AddFontResourceEx(@ScriptDir & '\HANSomaM.ttf', $FR_PRIVATE)
Global $mFontname = _WinAPI_GetFontResourceInfo(@ScriptDir & '\HANSomaM.ttf',1)


$BackGroundGUI = GUICreate("", 400, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetState(@SW_SHOW,$BackGroundGUI)
SetBitmap($BackGroundGUI,$hBitmap,255)


$ControlGUI = GUICreate("", 400, 300, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD),$BackGroundGUI)
GUISetBkColor(0x003842, $ControlGUI) ;0x003842
_WinAPI_SetLayeredWindowAttributes($ControlGUI, 0x003842, 255)
GUISetState(@SW_SHOW,$ControlGUI)


GUICtrlCreateInput("test text 1 ", 50, 35,284,20,-1,0) ; Transparent Input Can Cursor and Can Clicked!!!
GUIctrlSetBkColor(-1,0x003842)
GUICtrlSetFont(-1, 11, 400, 0, $mFontname, 4)
GUICtrlSetColor(-1,0xffffff)

GUICtrlCreateInput("test text 2", 50, 80,284,20,-1,0)  ; Transparent Input Can Cursor and Can Clicked!!!
GUIctrlSetBkColor(-1,0x003842)
GUICtrlSetFont(-1, 11, 400, 0, $mFontname, 4)
GUICtrlSetColor(-1,0xffffff)

GUICtrlCreateInput("", 50, 80+42,284,20,-1,0)         ; not Transparent Input Can Cursor and Can Clicked!!!
;~ GUIctrlSetBkColor(-1,0x003842)
GUICtrlSetFont(-1, 11, 400, 0, $mFontname, 4)
;~ GUICtrlSetColor(-1,0xffffff)

GUICtrlCreateInput("", 50, 80+87,284,20,-1,0) ; <== Transparent / Can not Cursor and Can not Clicked!!!
GUIctrlSetBkColor(-1,0x003842)
GUICtrlSetFont(-1, 11, 400, 0, $mFontname, 4)
GUICtrlSetColor(-1,0xffffff)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")


While 1
 Sleep(10)
WEnd

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $BackGroundGUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST


Func _WinAPI_AddFontResourceEx($sFont, $iFlag = 0, $fNotify = 0)
    Local $Ret = DllCall('gdi32.dll', 'int', 'AddFontResourceExW', 'wstr', $sFont, 'dword', $iFlag, 'ptr', 0)
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    If $fNotify Then
        DllCall('user32.dll', 'none', 'SendMessage', 'hwnd', 0xFFFF, 'uint', 0x001D, 'wparam', 0, 'lparam', 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_AddFontResourceEx

Func _WinAPI_GetFontResourceInfo($sFont, $fForce = 0)
    If $fForce Then
        If Not _WinAPI_AddFontResourceEx($sFont, 0x20) Then
            Return SetError(1, 0, '')
        EndIf
    EndIf
    Local $Ret = DllCall('gdi32.dll', 'int', 'GetFontResourceInfoW', 'wstr', $sFont, 'dword*', 4096, 'wstr', '', 'dword', 0x01)
    If (@error) Or (Not $Ret[0]) Then
        $Ret = 0
    EndIf
    If $fForce Then
        _WinAPI_RemoveFontResourceEx($sFont, 0x20)
    EndIf
    If Not IsArray($Ret) Then
        Return SetError(1, 0, '')
    EndIf
    Return $Ret[3]
EndFunc   ;==>_WinAPI_GetFontResourceInfo


Func _WinAPI_RemoveFontResourceEx($sFont, $iFlag = 0, $fNotify = 0)
    Local $Ret = DllCall('gdi32.dll', 'int', 'RemoveFontResourceExW', 'wstr', $sFont, 'dword', $iFlag, 'ptr', 0)
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    If $fNotify Then
        DllCall('user32.dll', 'none', 'SendMessage', 'hwnd', 0xFFFF, 'uint', 0x001D, 'wparam', 0, 'lparam', 0)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_RemoveFontResourceEx

Func _Exit()
    Exit
EndFunc

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local Const $AC_SRC_ALPHA = 1
    Local Const $ULW_ALPHA = 2
    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

; not Transparent Input Can Cursor and Can Clicked!!!
 
how to can  Transparent ?

Edited by davidkim

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

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...