Jump to content

WindowEx setting background color to transparent.


samm
 Share

Recommended Posts

Hi,

I'm using the following code:

#include <WinAPI.au3>
#include <WindowsConstants.au3>



Global Const $WC_LINK = "SysLink"
Global Const $WC_LINKA = $WC_LINK
Global Const $WC_LINKW = $WC_LINK

$g_hLink = _WinAPI_CreateWindowEx(0, $WC_LINK, _
'Test, [url="http://www.microsoft.com"]click here[/url], [url="http://www.microsoft.com"]here[/url] or [url=""]here[/url]', _
BitOR($WS_VISIBLE , $WS_CHILD , $WS_TABSTOP), _
10,10, 300, 60, $Form2)
GUIRegisterMsg($WM_NOTIFY,"MY_LINK_NOTIFY")


Func MY_LINK_NOTIFY($hWnd, $Msg, $wParam, $lParam)
Local Const $tagNMLINK = $tagNMHDR & ";" & "UINT mask; int iLink; UINT state; UINT stateMask; WCHAR szID[48]; WCHAR szUrl[2083];"
Local $NMHDR = DllStructCreate($tagNMHDR,$lParam)
Local $hwndFrom = DllStructGetData($NMHDR,"hwndFrom");
Switch $hwndFrom
Case $g_hLink
switch DllStructGetData($NMHDR,"code")
case $NM_CLICK
ContinueCase
case $NM_RETURN
$NMHDR = DllStructCreate($tagNMLINK,$lParam)
Local $iLink = DllStructGetData($NMHDR,"iLink")
Local $szURL = DllStructGetData($NMHDR,"szURL")
Local $szID = DllStructGetData($NMHDR,"szID")

if $szURL <> "" Then
ShellExecute($szURL, "", "", "open",@SW_SHOW);
EndIf
EndSwitch
EndSwitch
EndFunc

To make my syslinks clickable:

Posted Image

The problem is that I want it to display only the text... and set this white/gray background to transparent.

How can I do this?

Link to comment
Share on other sites

You can create the GUI with the $WS_EX_LAYERED extended style set, use the $WS_POPUP in the style parameter, that will create a GUI that you can make transparent.

Here's some code I stripped out of an old script of mine that I modified to show what I mean.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $URL[4]
_Credits()
While 1
    Sleep(10)
WEnd
Func _Credits()
    Local $Func[4]
    $URL[0] = "http://www.autoitscript.com/forum/index.php?showtopic=83481"
    $URL[1] = "http://www.autoitscript.com/forum/index.php?showtopic=43950"
    $URL[2] = "http://www.autoitscript.com/forum/index.php?showtopic=120154&view=findpost&p=835800"
    $URL[3] = "http://www.autoitscript.com/forum/index.php?showtopic=109096"
    Local $Text = "This program could not have been successfully completed without the amazing people" & _
            " on the AutoItScript forums, even those that didn't know that they helped me. The program is mostly original " & _
            "code with a sprinkling of code that was found in various threads on the forums." & @LF & @LF & _
            "I have also used the following UDFs in the creation of this script and I would like to give credit where credit is due: "
    $Func[0] = "Bass.au3" & @TAB & @TAB & "by BrettF"
    $Func[1] = "ID3.au3" & @TAB & @TAB & "by joeyb1275"
    $Func[2] = "RecFileListToArray" & @TAB & "by Melba23"
    $Func[3] = "ExtMsgBox" & @TAB & @TAB & "by Melba23"
    $Temp = GUICreate("", 500, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
    GUISetBkColor(0xFFFFFF)
    GUICtrlCreatePic(@ScriptDir & "White.bmp", 0, 0, 0, 0)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_TempClose")
    GUISetBkColor(0x0FFFFFF, $Temp)
    GUICtrlCreateLabel($Text, 40, 10, 750, 100)
    GUICtrlSetFont(-1, 10, 800, -1, "Consolas")
    GUICtrlSetColor(-1, 0x0000000)
    GUICtrlCreateButton(" Close ", 360, 230, -1)
    GUICtrlSetOnEvent(-1, "_TempClose")
    For $I = 0 To 3
        GUICtrlCreateLabel($Func[$I], 40, 130 + ($I * 20), 200, 20)
        GUICtrlSetColor(-1, 0x000000)
        GUICtrlSetFont(-1, 9, 400, 0)
    Next
    GUICtrlCreateLabel($URL[0], 260, 130, 400, 20)
    GUICtrlSetOnEvent(-1, "_BassURL")
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetColor(-1, 0x00000FF)
    GUICtrlSetFont(-1, 9, 400, 4)
    GUICtrlCreateLabel($URL[1], 260, 150, 400, 20)
    GUICtrlSetOnEvent(-1, "_ID3URL")
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetColor(-1, 0x00000FF)
    GUICtrlSetFont(-1, 9, 400, 4)
    GUICtrlCreateLabel($URL[2], 260, 170, 348, 20)
    GUICtrlSetOnEvent(-1, "_RFLTAURL")
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetColor(-1, 0x00000FF)
    GUICtrlSetFont(-1, 9, 400, 4)
    GUICtrlCreateLabel($URL[3], 260, 190, 400, 20)
    GUICtrlSetOnEvent(-1, "_EMBURL")
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetColor(-1, 0x00000FF)
    GUICtrlSetFont(-1, 9, 400, 4)
    GUISetState()
EndFunc   ;==>_Credits
Func _TempClose()
    Exit
EndFunc
Func _BassURL()
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $URL[0] = ' & $URL[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    ShellExecute($URL[0])
EndFunc   ;==>_BassURL
Func _ID3URL()
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $URL[1] = ' & $URL[1] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    ShellExecute($URL[1])
EndFunc   ;==>_ID3URL
Func _RFLTAURL()
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $URL[2] = ' & $URL[2] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    ShellExecute($URL[2])
EndFunc   ;==>_RFLTAURL
Func _EMBURL()
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $URL[3] = ' & $URL[3] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    ShellExecute($URL[3])
EndFunc   ;==>_EMBURL

You will need a pure white bmp file and call it white.bmp, and place it in the same folder as the script to make this transparent. You can easily create a white bmp in paint, make it any size as it won't affect the size of the GUI.

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

There is also Yashied's SysLinks UDF too >>

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

But I do create the GUI using the

_WinAPI_CreateWindowEx
function, instead of the
GUICreate
.

Anyway, I have tried adding those additional styles: $WS_EX_LAYERED and $WS_POPUP , but the GUI disappeared.

$g_hLink = _WinAPI_CreateWindowEx(0, $WC_LINK, _ 
        'Test, <A HREF="http://www.microsoft.com" ID="LInkIDURL+ID">click here</A>, <a href="http://www.microsoft.com">here</a> or <A ID="idInfo">here</A>', _
        BitOR($WS_VISIBLE , $WS_CHILD , $WS_TABSTOP, $WS_POPUP, $WS_EX_LAYERED), _
        10,10, 300, 60, $Form2)
Edited by samm
Link to comment
Share on other sites

There is also Yashied's SysLinks UDF too >>

I can not get it working with my code... when I click the syslink, nothing happends plus I can not make it transparent too, so its working just like the problem I had before.

$Text = 'The SysLink controls provides a convenient way to embed hypertext links in a window. For more information, click [url="http://msdn.microsoft.com/en-us/library/bb760706(VS.85).aspx"]here[/url].' & @CRLF & @CRLF & _
'To learn how to use the SysLink controls in AutoIt, click [url="http://www.autoitscript.com/forum/"]here[/url].'
$hSysLink = _GUICtrlSysLink_Create($Form2, $Text, 10, 10, 408, 54)
$Dummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Dummy
ShellExecute(_GUICtrlSysLink_GetItemUrl($hSysLink, GUICtrlRead($Dummy)))
EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
Local $hFrom = DllStructGetData($tNMLINK, "hWndFrom")
Local $ID = DllStructGetData($tNMLINK, "Code")

Switch $hFrom
Case $hSysLink
Switch $ID
Case $NM_CLICK, $NM_RETURN
GUICtrlSendToDummy($Dummy, DllStructGetData($tNMLINK, "Link"))
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Link to comment
Share on other sites

But I do create the GUI using the

_WinAPI_CreateWindowEx
function, instead of the
GUICreate
.

Why do you use that to create the GUI? Is there some special reason to use it that GUICreate won't allow? Did you read the post I made, you need a white.bmp to make it transparent, and this is using OnEvent mode to activate the links, if you're using message loop mode you'll need to change the script to make use of that. Edited by BrewManNH

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

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