RagsRevenge Posted August 10, 2009 Share Posted August 10, 2009 (edited) Hi, I'm creating an AutoIt script to put an overlay over a non-unicode program, to provide the ability to put unicode text over it. I have successfully created labels and buttons on this overlay. However, now I need to create a listview and listviewitems. The first problem (and less important) is that the code to create the listviewitems is dead slow in my program. I ran it in a standalon program and the exact same listviewItem creation code zips along. But the main problem I have is that the GUI is acting very unpredictably and I've chased the problems down to the way I create the second GUI in my code (this is the GUI where I place the controls for overlaying on top of the program underneath), with the line... $gui2 = GUICreate("child", 1280, 1024, 0, 0, $WS_POPUP, BitOR(0x2000000, $WS_EX_LAYERED, $WS_EX_TOOLWINDOW));$WS_EX_COMPOSITED = 0x2000000 and especially the extended styles, seemingly creating the problems. I can get the GUI to behave if I remove the Ex styles: 0x2000000, $WS_EX_LAYERED, but unfortunately, I lose the transparency. Here's an excerpt from the code whcih should display the problems, I'm having. Thanks for any advice you can give me. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info Opt("GUIDataSeparatorChar","|") ;"|" is the default Global $lvSchedule ;Maintenance Schedule Listview Global $msg Global $editInfo ;edit Box for Maintenance info const $TransparentColour = 0xABCDEF ;any element this colour will be transparent ;notWorkingCreateGui() WorkingCreateGui() $lvSchedule = GUICtrlCreateListView("1 Column", 110, 10, 100, 100) GUICtrlCreateListViewItem("test1", $lvSchedule) GUICtrlSetState($lvSchedule, $Gui_Show) $editInfo = GUICtrlCreateEdit("", 10, 10, 100, 100) GUICtrlSetData($editInfo, "hello") GUICtrlSetState($editInfo, $Gui_Show) Do $msg = GUIGetMsg() Until GUIGetMsg() = $GUI_EVENT_CLOSE func WorkingCreateGui() ;Program nearly works as expected if the Guis are created in the following manner, except transparency is lost. $gui1 = GUICreate("test", 300,300,0,0, BitOR($WS_MAXIMIZEBOX,$WS_POPUP,$WS_TABSTOP),BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetState() $gui2 = GUICreate("test 2", 300,300,300,300, $WS_POPUP, $WS_EX_TOOLWINDOW);, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW)) GUISetBkColor($TransparentColour) _API_SetLayeredWindowAttributes($gui2, $TransparentColour, 255);set special colour fully transparent GUISetState() WinSetTrans($gui1,"",0) ;Makes underlying GUI totally transparent WinSetOnTop($gui2,'',1) EndFunc func notWorkingCreateGui() $gui1 = GUICreate("Parent GUI", 1280, 1024, 0, 0, BitOR($WS_MAXIMIZEBOX,$WS_POPUP,$WS_TABSTOP),BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetFont(6) GUISetState() $gui2 = GUICreate("child", 1280, 1024, 0, 0, $WS_POPUP, BitOR(0x2000000, $WS_EX_LAYERED, $WS_EX_TOOLWINDOW));$WS_EX_COMPOSITED = 0x2000000 GUISetBkColor($TransparentColour) _API_SetLayeredWindowAttributes($gui2, $TransparentColour, 255);set special colour fully transparent GUISetState() WinSetTrans($gui1,"",0) ;Makes underlying GUI totally transparent WinSetOnTop($gui2,'',1) EndFunc ;=============================================================================== ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ;=============================================================================== Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc ;==>_API_SetLayeredWindowAttributes Edited August 10, 2009 by RagsRevenge Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2009 Share Posted August 13, 2009 Hi! In the func WorkingCreateGui(), replace $gui2 = GUICreate("test 2", 300,300,300,300, $WS_POPUP, $WS_EX_TOOLWINDOW) by $gui2 = GUICreate("test 2", 300,300,300,300, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW)) Link to comment Share on other sites More sharing options...
RagsRevenge Posted August 13, 2009 Author Share Posted August 13, 2009 Hi! In the func WorkingCreateGui(), replace $gui2 = GUICreate("test 2", 300,300,300,300, $WS_POPUP, $WS_EX_TOOLWINDOW) by $gui2 = GUICreate("test 2", 300,300,300,300, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW)) Wow. Thanks. I had implemented a workaround by simply creating a non-transparent GUI for the listviews. It isn't ideal, and when I get a chance, I'll go back to refactor in this fix. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now