Jump to content

Whole GUI flicker on resize


mpower
 Share

Go to solution Solved by binhnx,

Recommended Posts

Hi peeps, are you able to please help me out with reducing/eliminating the flicker when the GUI is being resized?

The example is attached. 

Reason for zip is that I'm using a couple of UDFs (namely: Ribbon bar and ModernMenuRaw so I've included them in the attached archive).

Source here:

#Region ### includes ###
#include-once
#NoTrayIcon
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Ribbonsbar.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#EndRegion ### includes ###

Opt("GUIResizeMode", 802)
Global $appname = 'Example App', $appver = '1.0', $additemsgui_W = 400, $additemsgui_H = 150

#Region ### $maingui ###
$maingui = GUICreate($appname & ' ' & $appver, @DesktopWidth, 600, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
$hBar = _RibbonsBar_Create($maingui, 0, 0, 0, 0, 'blue')
$hTab_Home = _RibbonsBar_Create_Tab($hBar, 'Home')
$hItem_FileOps = _RibbonsBar_Create_TabItem($hTab_Home, 'File operations' , 225 )
$hGrandButton_New = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',412,'New',52, True )
_RibbonsBar_GrandButtons_Enable($hGrandButton_New, 0)
$hDropDownNew = _RibbonsBar_Create_ContextMenu($hGrandButton_New)
$hDropDownNew_1 = _GUICtrlCreateODMenuItem("Standard ...", $hDropDownNew, "smallIcons.dll", 261)
$hDropDownNew_2 = _GUICtrlCreateODMenuItem("Manual ...", $hDropDownNew, "smallIcons.dll", 382)
$hGrandButton_Open = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',453,'Open',52, False )
_RibbonsBar_GrandButtons_Enable($hGrandButton_Open, 0)
$hGrandButton_Save = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',514,'Save',52, True )
_RibbonsBar_GrandButtons_Enable($hGrandButton_Save, 0)
$hDropDownSave = _RibbonsBar_Create_ContextMenu($hGrandButton_Save)
$hDropDownSave_1 = _GUICtrlCreateODMenuItem("Save", $hDropDownSave, "smallIcons.dll", 287)
$hDropDownSave_2 = _GUICtrlCreateODMenuItem("Save As ...", $hDropDownSave, "smallIcons.dll", 286)
$hGrandButton_Export = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',337,'Export',62, True )
_RibbonsBar_GrandButtons_Enable($hGrandButton_Export, 0)
$hDropDownExport = _RibbonsBar_Create_ContextMenu($hGrandButton_Export)
$hDropDownExport_1 = _GUICtrlCreateODMenuItem("To Excel", $hDropDownExport, "smallIcons.dll", 1243)
$hItem_ItemOps = _RibbonsBar_Create_TabItem ( $hTab_Home, 'Item operations' , 393 )
$hGrandButton_AddItems = _RibbonsBar_Create_GrandButton($hItem_ItemOps,'',301,'Add item(s)',72, True )
$hDropDownAddItems = _RibbonsBar_Create_ContextMenu($hGrandButton_AddItems)
_RibbonsBar_GrandButtons_Enable($hGrandButton_AddItems, 0)
$hDropDownAddItems_1 = _GUICtrlCreateODMenuItem("From Catalogue", $hDropDownAddItems, "smallIcons.dll", 173)
$hDropDownAddItems_2 = _GUICtrlCreateODMenuItem("From Quote", $hDropDownAddItems, "smallIcons.dll", 143)
$hDropDownAddItems_3 = _GUICtrlCreateODMenuItem("Paste", $hDropDownAddItems, "smallIcons.dll", 9)
$hGrandButton_DelItems = _RibbonsBar_Create_GrandButton($hItem_ItemOps,'',615,'Delete item(s)',82, False )
_RibbonsBar_GrandButtons_Enable($hGrandButton_DelItems, 0)
$SmallButton_Undo = _RibbonsBar_Create_SmallButton($hItem_ItemOps,'',728,1,'Undo (Test: click to enable grand buttons)',230)
$SmallButton_Redo = _RibbonsBar_Create_SmallButton($hItem_ItemOps,'',194,2,'Redo (Test: click to disable grand buttons)',230)
_RibbonsBar_SmallButtons_Enable($SmallButton_Redo, 0)
$hTab_Help = _RibbonsBar_Create_Tab( $hBar, 'Help' )
$hItem_Information = _RibbonsBar_Create_TabItem ( $hTab_Help, 'Information' , 120 )
$hGrandButton_About = _RibbonsBar_Create_GrandButton($hItem_Information,'',631,'Help','',False)
$hGrandButton_About = _RibbonsBar_Create_GrandButton($hItem_Information,'',644,'About','',False)
_RibbonsBar_Tab_SetState($hTab_Home)
GUISwitch($maingui)
WinMove($maingui, "", Default, Default, 800, Default)
$wPos = WinGetPos($maingui)
WinMove($maingui, "", @DesktopWidth/2 - $wPos[2]/2, @DesktopHeight/2 - $wPos[3]/2, Default, Default)
$wPos = WinGetPos($maingui)
$mainlistview = GUICtrlCreateListView('Col 1|Col 2|Col 3|Col 4|Col 5|Col 6', -2, 120, _
                $wPos[2], $wPos[3], Default)
_GUICtrlListView_SetExtendedListViewStyle($mainlistview, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_FLATSB))
_GUICtrlListView_SetColumnWidth($mainlistview, 0, 120)
_GUICtrlListView_SetColumnWidth($mainlistview, 1, 250)
_GUICtrlListView_SetColumnWidth($mainlistview, 2, 50)
_GUICtrlListView_SetColumnWidth($mainlistview, 3, 100)
_GUICtrlListView_SetColumnWidth($mainlistview, 4, 100)
_GUICtrlListView_SetColumnWidth($mainlistview, 5, 50)
#EndRegion ### $additemsgui ###

#Region ### $additemsgui ###
$additemsgui = GUICreate('Add item(s) from Catalogue', $additemsgui_W, $additemsgui_H, 0, 0, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_MDICHILD, $maingui)
GUISetBkColor(0xf2f8ff)
GUISetFont(10, 400)
$additems_addlabel = GUICtrlCreateLabel('Start typing below to add item(s) from catalogue (min 2 chars):', 10, 15, $additemsgui_W - 20, 21)
$additemsinput = GUICtrlCreateInput('', 10, 45, $additemsgui_W - 20, Default)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, False, 'Enter an item number here')
$additemsbn_add = GUICtrlCreateButton('Add', 10, 85, 110, 40)
#EndRegion ### $additemsgui ###


GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") ; Register WM_GETMINMAXINFO
GUISetState(@SW_SHOW, $maingui)

GUICtrlSetResizing($mainlistview, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKTOP))

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $maingui
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $hDropDownAddItems_1
                    GUISetState(@SW_DISABLE, $maingui)
                    $mPos = WinGetPos($maingui)
                    WinMove($additemsgui, '', $mPos[0] + (($mPos[2]/2) - ($additemsgui_W/2)), $mPos[1] + (($mPos[3]/2) - ($additemsgui_H/2)))
                    GUICtrlSetData($additemsinput, '')
                    GUISetState(@SW_SHOW, $additemsgui)
                    _WinAPI_SetFocus(ControlGetHandle('', '', $additems_addlabel))
                Case $hDropDownNew_1
                    ConsoleWrite('Clicked "New" menu item 1'&@CRLF)
                Case $hDropDownNew_2
                    ConsoleWrite('Clicked "New" menu item 2'&@CRLF)
            EndSwitch
        Case $additemsgui
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    GUISetState(@SW_ENABLE, $maingui)
                    GUISetState(@SW_HIDE, $additemsgui)
            EndSwitch
    EndSwitch
    Switch _RibbonsBar_GetMsg()
        Case $hGrandButton_Open
            ConsoleWrite('open...'&@CRLF)
        Case $SmallButton_Undo
            _RibbonsBar_GrandButtons_Enable($hGrandButton_New, 1)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_Save, 1)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_Export, 1)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_AddItems, 1)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_DelItems, 1)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_Open, 1)
            If _RibbonsBar_SmallButtons_GetState($SmallButton_Undo) = 1 Then
                ConsoleWrite('undo...'&@CRLF)
            EndIf
        Case $SmallButton_Redo
            _RibbonsBar_GrandButtons_Enable($hGrandButton_New, 0)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_Save, 0)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_Export, 0)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_AddItems, 0)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_DelItems, 0)
            _RibbonsBar_GrandButtons_Enable($hGrandButton_Open, 0)
            If _RibbonsBar_SmallButtons_GetState($SmallButton_Redo) = 1 Then
                ConsoleWrite('redo...'&@CRLF)
            EndIf
        Case $hTab_Home
            _RibbonsBar_Tab_SetState($hTab_Home)
        Case $hGrandButton_Export
            _RibbonsBar_ContextMenu_SetState($hDropDownExport)
        Case $hGrandButton_Save
            _RibbonsBar_ContextMenu_SetState($hDropDownSave)
        Case $hGrandButton_AddItems
            _RibbonsBar_ContextMenu_SetState($hDropDownAddItems)
        Case $hGrandButton_New
            _RibbonsBar_ContextMenu_SetState($hDropDownNew)
        Case $hTab_Help
            _RibbonsBar_Tab_SetState($hTab_Help)
    EndSwitch
WEnd

Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    If $hWnd = $maingui Then
        $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
        DllStructSetData($tagMaxinfo, 7,  800) ; W (min size)
        DllStructSetData($tagMaxinfo, 8,  600) ; H (min size)
        Return 0
    EndIf
EndFunc   ;==>WM_GETMINMAXINFO

Thanks heaps in advance!

example.zip

Edited by mpower
Link to comment
Share on other sites

I see that your main control is a listview. Some GUI styles can reduce listview flicker significantly.

Here is an example with a lot of flicker:

#Include <GuiListView.au3>
#Include <WindowsConstants.au3>
#Include <GUIConstantsEx.au3>

$maingui = GUICreate('Test', @DesktopWidth/2, @DesktopHeight/2, _
  @DesktopWidth/2 - (@DesktopWidth/2)/2, @DesktopHeight/2 - (@DesktopHeight/2)/2, _
  BitOR($WS_SIZEBOX,$WS_TABSTOP,$WS_MINIMIZEBOX))

$maingui_lv = GUICtrlCreateListView('Col 1|Col 2|Col 3|Col 4|Col 5|Col 6|Col 7|Col 8|Col 9', _
  0, 0, @DesktopWidth/2, @DesktopHeight/2 - 23, _
  BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))

_GUICtrlListView_SetExtendedListViewStyle($maingui_lv, _
  BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES))

GUICtrlSetResizing($maingui_lv, $GUI_DOCKBORDERS) ; Prevents horizontal scrollbar

For $i = 0 To 100
  GUICtrlCreateListViewItem( _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) , $maingui_lv)
Next

GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
  Local $iWidth
  $iWidth = BitAND($lParam, 0xFFFF) ; _WinAPI_LoWord
  _GUICtrlListView_SetColumnWidth($maingui_lv, 0, ($iWidth-17)*0.20)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 1, ($iWidth-17)*0.30)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 2, ($iWidth-17)*0.03)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 3, ($iWidth-17)*0.08)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 4, ($iWidth-17)*0.07)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 5, ($iWidth-17)*0.07)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 6, ($iWidth-17)*0.10)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 7, ($iWidth-17)*0.10)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 8, ($iWidth-17)*0.05)
  Return $GUI_RUNDEFMSG
EndFunc

Here is the same example with $WS_CLIPCHILDREN style on the GUI and $WS_EX_COMPOSITED on the listview.

#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

$maingui = GUICreate('Test', @DesktopWidth/2, @DesktopHeight/2, _
  @DesktopWidth/2 - (@DesktopWidth/2)/2, @DesktopHeight/2 - (@DesktopHeight/2)/2, _
  $WS_OVERLAPPEDWINDOW + $WS_CLIPCHILDREN)

; $WS_CLIPCHILDREN and $WS_EX_COMPOSITED reduces flicker
; $WS_EX_COMPOSITED is not compatible with a header

$maingui_lv = GUICtrlCreateListView('Col 1|Col 2|Col 3|Col 4|Col 5|Col 6|Col 7|Col 8|Col 9', _
  0, 0, @DesktopWidth/2, @DesktopHeight/2, _
  BitOR($LVS_NOCOLUMNHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS), _
  $WS_EX_COMPOSITED)

_GUICtrlListView_SetExtendedListViewStyle($maingui_lv, _
  BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES))

GUICtrlSetResizing($maingui_lv, $GUI_DOCKBORDERS) ; Prevents horizontal scrollbar

For $i = 0 To 100
  GUICtrlCreateListViewItem( _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) &"|"& _
  Random(0 ,1000000, 1) , $maingui_lv)
Next

_GUICtrlListView_SetColumnWidth($maingui_lv, 0, (@DesktopWidth/2 - 17) * 0.20)
_GUICtrlListView_SetColumnWidth($maingui_lv, 1, (@DesktopWidth/2 - 17) * 0.30)
_GUICtrlListView_SetColumnWidth($maingui_lv, 2, (@DesktopWidth/2 - 17) * 0.03)
_GUICtrlListView_SetColumnWidth($maingui_lv, 3, (@DesktopWidth/2 - 17) * 0.08)
_GUICtrlListView_SetColumnWidth($maingui_lv, 4, (@DesktopWidth/2 - 17) * 0.07)
_GUICtrlListView_SetColumnWidth($maingui_lv, 5, (@DesktopWidth/2 - 17) * 0.07)
_GUICtrlListView_SetColumnWidth($maingui_lv, 6, (@DesktopWidth/2 - 17) * 0.10)
_GUICtrlListView_SetColumnWidth($maingui_lv, 7, (@DesktopWidth/2 - 17) * 0.10)
_GUICtrlListView_SetColumnWidth($maingui_lv, 8, (@DesktopWidth/2 - 17) * 0.05)

GUISetState()
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_SIZE($hWnd, $msg, $wParam, $lParam)
  Local $iHeight, $iWidth
  $iWidth = BitAND($lParam, 0xFFFF) ; _WinAPI_LoWord
  $iHeight = BitShift($lParam, 16) ; _WinAPI_HiWord
  _GUICtrlListView_SetColumnWidth($maingui_lv, 0, ($iWidth - 17) * 0.20)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 1, ($iWidth - 17) * 0.30)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 2, ($iWidth - 17) * 0.03)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 3, ($iWidth - 17) * 0.08)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 4, ($iWidth - 17) * 0.07)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 5, ($iWidth - 17) * 0.07)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 6, ($iWidth - 17) * 0.10)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 7, ($iWidth - 17) * 0.10)
  _GUICtrlListView_SetColumnWidth($maingui_lv, 8, ($iWidth - 17) * 0.05)
  _WinAPI_MoveWindow($maingui_lv, 0, 0, $iWidth, $iHeight)
  Return $GUI_RUNDEFMSG
EndFunc
Because of _WinAPI_MoveWindow in WM_SIZE function this example is more CPU/GPU intensive while you are resizing.

Unfortunately $WS_EX_COMPOSITED is not compatible with a header. If you need a header, you can add a header control, or you can add an empty listview with only the header. In both cases you have to take care of synchronization.

But this will not help at the flicker in the toolbar.

The easiest way to get rid of all flicker is probably to use a resizing technique, where you only see the window border, while you are resizing with the mouse. The window is resized when you release the mouse button. Take a look at the green post in this thread.

Link to comment
Share on other sites

  • Solution

@LarsJ: It's not the main problem. The OP's script is perfect, all the wrong belong to AutoIt!

@mpower: Luckily, we can fix it!

The first problem:

Not sure why AutoIt throw CS_HREDRAW and CS_VREDRAW style flag into its class "AutoIt v3 GUI". Those flags force the GUI repaint every time you resize it, and every controls of it must be repainted too.

This line will fix it:

_WinAPI_SetClassLongEx($maingui, $GCL_STYLE, BitAND(_WinAPI_GetClassLongEx($maingui, $GCL_STYLE), BitNOT(1), BitNOT(2)))

1 and 2 is the value of CS_HREDRAW and CS_VREDRAW. So the above line will unset those flags.

Be sure to include <WinAPI.au3> or you will get error messages.

The second problem:

The resizing handling of AutoIt is terrible. If implemented right, your controls and GUI should not flickring. But it was done wrong. So you have 2 options:

1. Do as @LarsJ sugguest, add $WS_CLIPCHILDREN when you create the $maingui. It should work immediately, all the GUI, and the listview no longer flicker. 

But, when you resize, you can see, some part near the top-right corner of the listview is not repainted, now welcome to the tearing problem.

Since the GUI now don't take care of painting its children, if you resize GUI fast enough, the region which the GUI marks that it should not paint and leave for controls, in our case, is the listview, is not same as the position of the listview. If good, it's smaller. If bad, it's larger, and some part of the GUI is not painted by both the GUI, and the listview. 

2. Bypass AutoIt auto resize, manually resize yourself. By intercept the WM_SIZE message. Since your script has only a control (the listview) need to be resized, everything should be simple. (The ribbon is resize automatically so we don't need to care)

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, _WinAPI_LoWord($lParam), _WinAPI_HiWord($lParam)-120, _
                BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    Return 1
EndFunc

Now, the GUI is no longer flickering, but the listview is still. Strange?

You can add a flag: $SWP_NOREDRAW to make the listview not repaint itself. But again, you met the tearing guy, since your control is not painted correctly. To solve that, you need to read the third problem

The third problem:

One more time, AutoIt do an odd strange thing: throw the $WS_EX_TRANSPARENT into the ex-style of the listview.

This flag, while it cannot make the control (in our case, the listview) transparent, but can make transparent is possible, if you do right. You can read about this flag in http://blogs.msdn.com/b/oldnewthing/archive/2012/12/17/10378525.aspx

Beside being painted after all the non WS_EX_TRANSPARENT siblings, it also make the parent is painted before, compare with after in normal case.

So, the parent paint itself. Because we have not $WS_EX_CLIPCHILDREN flag, it also ask for it controls paint. The listview also be painted.

After that, the listview is painted, twice, because it has WS_EX_TRANSPARENT! And we get flickering!

So, manually set the ex-style of the listview instead of leaving default. It should be:

$mainlistview = GUICtrlCreateListView('Col 1|Col 2|Col 3|Col 4|Col 5|Col 6', 0, 120, _
                $wPos[2], $wPos[3] - 120, -1, 0x200)

Everything should be OK now. Cheer!

Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

Listviews in autoit do NOT have WS_EX_TRANSPARENT set by default, that is a Window style setting, not a listview style setting. ListViews use the same value as WS_EX_TRANSPARENT set by default, but that setting is for $LVS_EX_FULLROWSELECT which is a ListView extended style setting. Just because the values are the same does not mean the results are the same.

Also, I'm not sure where you got the CS_HREDRAW and CS_VREDRAW idea from but according to the help file the only style that is forced for a GUI is $WS_EX_WINDOWEDGE and the value of that is 0x00000100, and not 0x00000003, and also according to the help file you can disable that by using -1 in the Extended Style parameter of GUICreate.

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

@BrewmanNH:

1. A simple script may make everything clear that AutoIt did or did not:

GUICreate("TEST")
GUICtrlCreateListView("1|2", 0, 0, 350, 350)

While GUIGetMsg() <> -3
  Sleep(10)
WEnd

Check the style. I agree that WS_EX_TRANSPARENT and LVS_EX_FULLROWSELECT has the same value of Hex(0x20) = Int(32), but it's not the same. Window Style/ExStyle is set when creating the window, the control is a window, in Win32 too. It can also be set with SetWindowLong

LVS_EX_FULLROWSELECT is specific style to the listview only, and it cannot be set with SetWindowLong, but using a specified window message, LVM_SETEXTENDEDLISTVIEWSTYLE, and be wrapped in AutoIt by 

_GUICtrlListView_SetExtendedListViewStyle

The OP did everything correctly, but get the un-expected result

2. CS_HREDRAW and CS_VREDRAW is class style, not window style. It cannot be set when creating a window, but when registering the class. So any AutoIt window with class name "AutoIt v3 GUI" should have the same class style. And it actually has the same class style, except you manually re-set it, as I did

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

So, you agree with me that you're wrong about WS_EX_TRANSPARENT? Good, glad we're on the same page. ListViews use LV style settings and GUIs use WS style settings and they don't affect each other. So setting a Listview with the FullRowSelect style has nothing whatsoever to do with WS_EX_TRANSPARENT.

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

@BrewmanNH: Sadly that not :((

OK, I guess I need to clarify more details about this.

First, every window (GUI) or control, with Windows, should be one window, managed by a window handle (HWND)

Any window does have Style, ExStyle. You can get it with GetWindowLong(A/W) in Windows 32bit and GetWindowLongPtr(A/W) in Windows 64bit. That functions lives in user32.dll. AutoIt wrap it in WinAPI.au3, both, as _WinAPI_GetWindowLong. Similarly, SetWindowLong(A/W) (32bit) and SetWindowLongPtr(A/W) (64bit) are wrapped to _WinAPI_SetWindowLong. All that share style/ex-style have the same prefix $WS_... (with style) and $WS_EX_... (with ex-style). So everywindow, as the word of Win32, or every GUI and control, as the word of AutoIt can have $WS_... style and $WS_EX_... ex-style

Any window can have a specified set of style, like buttons have a set of $BS_..., a listviews have a set of $LVS_... This is normal style and can be set by Get/SetWindowLong function.

Beside that, some specified control, such as ListView, has its set of specific ex-style. This is not related to the normal Window style/ex-style, and also cannot using the Set/GetWindowLong function to deal with it. To set/get that ex-style, you send a specified message to the specified control. AutoIt also wrap it it GUIListView.au3. Open that file, and scroll to the _GUICtrlListView_SetExtendedListViewStyle and GUICtrlListView_GetExtendedListViewStyle functions, you will see how it is implemented.

$WS_EX_TRANSPARENT is totally different with $LVS_EX_FULLROWSELECT. You using SetWindowLong() to set $WS_EX_TRANSPARENT, and GetWindowLong() to get the ex-style, bitor to see it has the flag or not. But $LVS_EX_FULLROWSELECT cannot be retrieved with that. You can only use 

GUICtrlListView_GetExtendedListViewStyle () to get either or not that flag is set. So if you use GetWindowLong(), and see that 0x20 is set, it definitely that you set the $WS_EX_TRANSPARENT. Similarly, when you use GUICtrlListView_GetExtendedListViewStyle () and see that 0x20, you can say anything about $WS_EX_TRANSPARENT but sure that $LVS_EX_FULLROWSELECT is set.

Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

What has any of that got to do with what you stated?

You said the listview had WS_EX_TRANSPARENT set, it does not, you are wrong. You can try and bullshit around it with pseudo knowledge, but in the end you're still wrong. You won't admit you're wrong, but anyone who reads this can try and show me where I am wrong and I'll admit it. Setting a ListView with FULLROWSELECT does not set window transparency on the listview, it sets it so that the full row of the listview is selected when you click on it. 

This is a simple binary question to you, there are 2 answers, yes and no. Does setting FULLROWSELECT on a ListView control cause it to have WS_EX_TRANSPARENT set on it as well? Your answer will tell us whether you know what you're talking about or not. I don't need another word-wall of text trying to explain what you think, I need a yes or no.

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

Simple, NO.

Setting LVS_EX_FULLROWSELECT will not make WS_EX_TRANSPARENT to be set.

Setting WS_EX_TRANSPARENT also will not make LVS_EX_FULLROWSELECT to be set.

>This should be a proof. Melba comment also give some information.

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

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

×
×
  • Create New...