Sign in to follow this  
Followers 0
mpower

Whole GUI flicker on resize

13 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

lots of downloads already..... just wondering if anyone had any problems in getting it to run or anything? any ideas on how to reduce/eliminate the flicker?

Edited by mpower

Share this post


Link to post
Share on other sites

no luck?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@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
1 person likes this

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@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!

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

binhnx, that's perfect thank you for your solution! :D

Share this post


Link to post
Share on other sites

Indeed, it's not perfect yet :)

Finally, You also still need to add $WS_CLIPCHILDREN to the GUI to make things perfect :)


99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


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
Sign in to follow this  
Followers 0

  • Similar Content

    • Skeletor
      By Skeletor
      MS Splash Screens
      The office 2016/17 office suite has made many people turn heads with its functions and especially their splash screen.
      I now present to you, the MS Style Splash Screen. For Rookies, Novices and anyone who wants a ready made splash screen for your gui application.

      You can now download it and also try it out yourself.
      You have three colors to choose from:
      Blue
      Red
      Green
      All three colours are from the famous programs.
      I also included the KODA form to you can have freedom with this splash screen.
      Note: the KODA form does not have the three colours as well as the correct blue. 

      Have fun and enjoy.
      Note:
      I will update the splash to add the automated 3 dots animation at a later stage. 
       
       
    • Skeletor
      By Skeletor
      A gui splash screen. Themed after the famous MS Office Suite.
      Three colours to choose from, Red, Blue and Green.
      You can change the labels to your own application.

      Also bundled with this is the KODA form. So you can open up and see the basic structure of this splash screen.
       
      Splash Screen GUI.zip
    • BlazerV60
      By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian
    • SteveJM
      By SteveJM
      I have a working program currently driven largely through menu selections. I would like to add a toolbar where most of the tollbar button actions are basically the same as menu items, but quicker to access. I have been wading around in toolbar examples, MSDN pages etc, it's clearly going to be a bit of a slog to get everything right, including tooltips etc. I thought I would start with something simple to prove the principle.
      Using bits from the help file examples I have a small program that successfully displays a toolbar. However, what seemed like the most elegant way to deal with the button commands does not seem to work. My understanding was that a toolbar button fires a WM_COMMAND message, with the command Id set by the second parameter in the call to
      _GUICtrlToolbar_AddButton ( $hWnd, $iID, $iImage)
      so I though it would be a good idea to set this Id to the same value as my menu item Id; then it would run the same task which is what I wanted. This did not work. I am using message loop mode and would like to stick with this because some of my scripts run hardware at the same time as the gui; it is easier if I don't have to worry about code being interrupted with the hardware in an unknown state . So I added a handler for WM_COMMAND, with some cribbed display code to try and see why. The toolbar button defintely fired a WM_COMMAND message and the Id looked the same, so no explanation there.
      I guess the issue is with GUIGetMsg() which may be constructed to ignore all but a limited number of control handles, i.e. those made with the GuiCtrlCreate... commands; this is speculation.
      I would dearly love to find a tidy way to get around this. Having some controls handled in the message loop and some in a WM_COMMAND handler, performing the same task, feels ugly. I would be very grateful for further insight from someone experienced with handling a toolbar. Perhaps I should be trying to fire the menu item. I have attached a code snippet to try and illustrate the issue.
       
       
       
      ToolbarTrial.au3
    • XinYoung
      By XinYoung
      Hello all,
      I've been working on 4 standalone scripts. They each have their own GUI and are now independent .exe's. But instead of having 4 separate icons on my computer, is it possible to put them all together into one .exe?
      What I want is one interface with tabs. Each script's GUI would be on their own respective tab. Is this possible?
      The different scripts don't need to communicate with one another. I just want them all in one .exe.
      I can't find this anywhere... Any help would be greatly appreciated. Thank you!