Jump to content
Sign in to follow this  
mpower

Whole GUI flicker on resize

Recommended Posts

mpower

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
mpower

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
mpower

no luck?

Share this post


Link to post
Share on other sites
LarsJ

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
binhnx

@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
  • Like 1

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
BrewManNH

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
binhnx

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

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
binhnx

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

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
binhnx

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
mpower

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

Share this post


Link to post
Share on other sites
binhnx

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  

  • Similar Content

    • TheSaint
      By TheSaint
      Here is the bare bones of a UDF I have started work on.
      Mostly just a proof of concept at this stage, and still need to add some functions and dress the UDF up a bit ... to look like a UDF ... though it has my own distinct styling, especially as I have never really developed a UDF before now .... used plenty and modified plenty though. I've even invented my own UDF variable naming convention, which I am sure some of you will be aghast at. I work with what feels best for me, but others are free to adapt if they wish.
      The idea is to emulate the simplicity of INI files, but gain the benefits of SQL.
      Two scripts are provided.
      (1) The UDF, a work in progress - SimpleSQL_UDF.au3
      (2) An example or testing script - UDF_Test.au3
      Another first for me, is creating a 2D array from scratch, never done that before, that I can recall ... never had a need, and even for 1 dimension arrays, for a long time now, I have just used _StringSplit to create them. So I needed a bit of a refresher course, which my good buddy @TheDcoder assisted me with ... not without some angst I might add. LOL
      SimpleSQL_UDF.zip
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      Hopefully the usage is self-evident ... just change the Job number variable in the UDF_Test.au3 file to check the existing functions out.
      Enjoy!
      P.S. This is also related to a new program I have just finished and uploaded - INItoSQL DB
    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • nacerbaaziz
      By nacerbaaziz
      hi dears, i have an question please if you can help me.
      i maked an program to do some functions
      and this program works with the global hot keys
      i added an option to the users to change the hot keys
      when i searched about how to do that i found this UDF
      GUIHotkey.au3
      http://www.autoitscript.com/forum/index.php?showtopic=107965
      but the problem here that this UDF cant be detect the win key.
      can you help me to add it, or if there are any others UDFSS wich do that work please give me some.
      i hope that my question is clear for you.
      thanks in advance
    • Silas
      By Silas
      Hello everyone,
      I have a radio button ($Radio1), which I want to disable as soon as another one get's checked (Radio5). (The system fails if the radio button i'm troubling with also gets checked).
      I know how to disable him:
      If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_DISABLE) Then GUICtrlSetState($Radio5, 128) But if i try to enable $Radio5 again, after $Radio1 isn't checked anymore, it fails:
      If GUICtrlRead($Radio1)=Not 1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_ENABLE) Then GUICtrlSetState($Radio5, 64)  
      Anyone knows why?
    • marcoauto
      By marcoauto
      Ciao
      I would like to control an ATEM Video Mixer from autoit. I downloaded his SDK which is written in c ++ and I found the sequences to interface, but I was not able to convert the script to self.
      The instructions say to follow this sequence:
      and to connectTo with C++ is:
      string address = "192.168.1.240"; _BMDSwitcherConnectToFailure failureReason = 0; IBMDSwitcher switcher = null; var discovery = new CBMDSwitcherDiscovery(); discovery.ConnectTo(address, out switcher, out failureReason); From Blackmagic SDK:
      IBMDSwitcherDiscovery::ConnectTo method
      The ConnectTo method connects to the specified switcher and returns an IBMDSwitcher object interface for the switcher.
      Syntax HRESULT ConnectTo (string deviceAddress, IBMDSwitcher** switcherDevice, BMDSwitcherConnectToFailure* failReason); Parameters: deviceAddress in Network hostname or IP address of switcher to connect to. switcherDevice out IBMDSwitcher object interface for the connected switcher. failReason out Reason for connection failure as a BMDSwitcherConnectToFailure value. So, I have I tried these solutions but with non success:
      $DllName =@ScriptDir&"\BMDSwitcherAPI.dll" $result = DllCall($DllName, "none", "IBMDSwitcherDiscovery::ConnectTo" & @CRLF) ConsoleWrite("DLLCall Result: " & $result & @CRLF) and I have tried also create an Object (That I think is the best way solution):
      #include <MsgBoxConstants.au3> $oSwitcher=ObjCreate("IBMDSwitcher") If IsObj($oSwitcher) Then MsgBox(64, "", "Object $oSwitcher created successfully") EndIf $oAtem=ObjCreate("IBMDSwitcherDiscovery") If IsObj($oAtem) Then MsgBox(64, "", "Object $oAtem created successfully") EndIf $failureReason =ObjCreate("_BMDSwitcherConnectToFailure") If IsObj($failureReason) Then MsgBox(64, "", "Object $failureReason created successfully") EndIf $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler Global $errore,$oSwitcher1 $oAtem.ConnectTo("192.168.1.36",$oSwitcher,$failureReason); ; This is the custom error handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription & @CRLF & _ "Source is: " & $oMyError.source & @CRLF & _ "Description is: " & $oMyError.description & @CRLF & _ "Helpfile is: " & $oMyError.helpfile & @CRLF & _ "Helpcontext is: " & $oMyError.helpcontext & @CRLF & _ "Lastdllerror is: " & $oMyError.lastdllerror & @CRLF & _ "Scriptline is: " & $oMyError.scriptline) EndFunc ;==>MyErrFunc But the result is:
      We intercepted a COM Error !
      Number is: 000000A9
      Windescription is: Variable must be of type 'Object'.
      Source is: 
      Description is: 
      Helpfile is: 
      Helpcontext is: 
      Lastdllerror is: 0
      Scriptline is: 17
      The BMDSwitcherAPI.dll is registered in system. Can someone help me?
      Grazie
      Marco
×