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

    • Jibberish
      By Jibberish
      Hi,
      I am automating the testing of a video player. I search a file for ".mp4" and want to create a GUI with radio buttons to select what video to play. The number of videos can change based on the user's library so this must be created automatically.  I have searched for how to accomplish this and there are several posts out there that help a little but I can't figure out the solution. I pulled the offending code from my main script and created the file below to make this easier to read. I am sure one of our experts here can help!
      #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <array.au3> #include <File.au3> #include <GUIConstantsEx.au3> Local $sMediaFile = "D:\MediaFiles\MediaFiles.txt" Local $iStrReturn = 0 Local $aText Local $aArrayFile Local $iMax = 6 ;Default number of Videos - 1 for the array counter Local $aVideoName[$iMax] = [0] Local $sCheckBox1 Local $iT = 0, $iVideoCount = 0, $iCount Local $ix = 0 Local $iy = 0 Local $idClose1 Const $iL = 10 ; Count from Left for GUI so all buttons line up ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Read a list of video file names and create a GUI with Radio Buttons to select a single video. ; Problem: We don't know how many video names will be in the text file, so we can't hard code Case Statements & their variables ; Put the Video File Names into an Array _FileReadToArray($sMediaFile, $aArrayFile) For $a = 1 To $aArrayFile[0] ; Step through the array looking for .mp4 If StringInStr($aArrayFile[$a], ".mp4") Then $iVideoCount = $iVideoCount + 1 $aText = StringSplit($aArrayFile[$a],"\\") ; This video player reads double backslashes For $a1 = 1 to $aText[0] ; Check that the array is big enough If StringInStr($aText[$a1], ".mp4") Then ;MsgBox(0,"","Video is " & $aText[$a1]) If UBound($aVideoName) = $iVideoCount Then ; Resize the array when $iCount is equal to the element count in the array to prevent subscript error ReDim $aVideoName[$aVideoName[0] + $iMax] EndIf $aVideoName[$iVideoCount] = $aText[$a1]; add data to new index element $aVideoName[0] = $a1 ; update the index count for future reference ; The idea is to create a GUI width to accommodate long video file names $it = StringLen($aVideoName[$iVideoCount]) If $iT > $ix Then $ix = $iT EndIf EndIf Next EndIf Next ; Move backwards through the array deleting blank rows For $iCount = UBound($aVideoName) - 1 To 0 Step -1 If $aVideoName[$iCount] = "" Then _ArrayDelete($aVideoName, $iCount) EndIf Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Create the GUI - Names and Radio Button counts will vary - How do I do this? ; ;_ArrayDisplay($aVideoName) ;Local $aVarName[$aVideoName[0]] Local $iRows = UBound($aVideoName, $UBOUND_ROWS) $iRows = $iRows -1 $aVideoName[0] = $iRows ; Prep the GUI to display the FileNames with Radio Buttons - Can only select one at a time. $a = 0 $ix = $ix + 200 $iy = ($aVideoName[0] * 30) + 60 $hGUI = GUICreate("Videos", $ix, $iy) ;$iT = $iT+30 ; Create the variable names for the Case statement - Video count may change so Video Names displayed and GUICtrlCreateRadio count may change. ;~ For $a = 1 to $aVarName[0] ;~ If UBound($aVarName) = $aVarName Then ;~ ; Resize the array when $iCount is equal to the element count in the array to prevent subscript error ;~ ReDim $aVarName[$aVarName[0] + $iMax] ;~ EndIf ;~ Assign("$bVideoName" & $a, $a) ;~ Local $aVarName[$a] = Eval($bVideoName[$a]) ;~ ; $aVarName[$a] = GUICtrlCreateRadio($aVarName[$a], $iL, $iT) ;~ Next $iCount = 1 ;MsgBox(0,"","VideoName[0] is "&$aVideoName[0]) ;_ArrayDisplay($aVideoName) Local $bVideoName1 If $iCount < $aVideoName[0] Then $bVideoName1 = GUICtrlCreateRadio($aVideoName[$iCount], $iL, $iT) GUICtrlSetState($bVideoName1, $GUI_CHECKED) $iT = $iT+30 EndIf $iCount = $iCount + 1 If $iCount <= ($aVideoName[0]) Then Local $bVideoName2 = GUICtrlCreateRadio($aVideoName[$iCount],$iL,$iT) $iT = $iT+30 EndIf $iCount = $iCount + 1 If $iCount <= ($aVideoName[0]) Then Local $bVideoName3 = GUICtrlCreateRadio($aVideoName[$iCount],$iL,$iT) $iT = $iT+30 EndIf $iCount = $iCount + 1 If $iCount <= ($aVideoName[0]) Then Local $bVideoName4 = GUICtrlCreateRadio($aVideoName[$iCount],$iL,$iT) $iT = $iT+30 EndIf $iCount = $iCount + 1 If $iCount <= ($aVideoName[0] -1) Then Local $bVideoName5 = GUICtrlCreateRadio($aVideoName[$iCount],$iL,$iT) $iT = $iT+30 EndIf $iCount = $iCount + 1 If $iCount <= ($aVideoName[0] -1) Then Local $bVideoName6 = GUICtrlCreateRadio($aVideoName[$iCount],$iL,$iT) $iT = $iT+30 EndIf $iCount = $iCount + 1 If $iCount <= ($aVideoName[0] -1) Then Local $bVideoName7 = GUICtrlCreateRadio($aVideoName[$iCount],$iL,$iT) $iT = $iT+30 EndIf $iT = $iT + 30 $idClose1 = GUICtrlCreateButton("Go!", $iL, $iT) GUISetState(@SW_SHOW) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Switch Statement ; ;Local $nMsg = "" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $bVideoName1 Case $bVideoName2 Case $bVideoName3 Case $bVideoName4 Case $bVideoName5 ;Case $bVideoName6 <- Fails because there are only 5 videos - Need variable $bVideoNames ;Case $bVideoName7 <- Fails because there are only 5 videos Case $idClose1 $bVideoName1 = GUICtrlRead($bVideoName1) $bVideoName2 = GUICtrlRead($bVideoName2) $bVideoName3 = GUICtrlRead($bVideoName3) $bVideoName4 = GUICtrlRead($bVideoName4) $bVideoName5 = GUICtrlRead($bVideoName5) ;$bVideoName6 = GUICtrlRead($bVideoName6) ;$bVideoName7 = GUICtrlRead($bVideoName7) ExitLoop EndSwitch WEnd GUIDelete($nMsg) MsgBox(0,"","Case " & $nMsg & " was selected.") ; Always returns 8. ??? This is the "MediaFiles.txt" file I am reading:
      D:\\MediaFiles\\BigBuckBunny.mp4 D:\\MediaFiles\\BigBuckBunny60fps.mp4 D:\\MediaFiles\\Sintel.mp4 D:\\MediaFiles\\sintel-2048-surround.mp4 D:\\MediaFiles\\TearsOfSteel.mp4 D:\\MediaFiles\\tearsofsteel_4K.mp4 I'm sure I have several mistakes (or poor coding methods) in my AutoIt file.
    • TheDcoder
      By TheDcoder
      Hello, I recently opened a bug report without reading the Helpfile... My bad . After @Melba23's gentle reminder, I was curious about why it was like that.
      It is about SetError's behaviour. This is the example from the bug report:
      Example() If @error Then ConsoleWrite("Error" & @CRLF) Else ConsoleWrite("No Error" & @CRLF) EndIf Func Example() SetError(1) Sleep(1000) EndFunc What I tried to do is set Example's (my user defined function's) @error value to 1... but the value set by SetError is cleared after calling a function, I wonder why? Why should calling to an external function effect my function's @error which is set when my function returns.
      Setting the error of a UDF in advance by using SetError makes sense... but I cannot find a reason why calling a function should clear it? Please note that I am not talking about @error, I am talking about the @error set by my function when it ends/returns!
      I hope someone can enlighten me, thanks for the answers in advance!
      P.S I tried to explain my best but my English is not very good and I didn't feel like I did a good job explaining today, so please pardon any mistakes that I have made
    • AndyS19
      By AndyS19
      I have a listview with 3 columns and I want to set the 3rd column's color based on the item's 'Param' value, but even though I set up for the 3rd column, the entire row always gets the color.
      My test code is below, but here is the pertinent code:
      Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $iDrawStage, $tCustDraw $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam) $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case BitOR(0, $CDDS_ITEMPREPAINT) ;, $CDDS_SUBITEM) setItemColor($tCustDraw, $hWndFrom) Return $CDRF_NOTIFYSUBITEMDRAW EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func setItemColor($tCustDraw, $hWnd) Local $iIndex, $color, $iSubitem $iIndex = DllStructGetData($tCustDraw, 'dwItemSpec') ; item number $color = _GUICtrlListView_GetItemParam($hWnd, $iIndex) $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') ; Here, I want to only change the color of the 3rd col, and not the 1st and 2nd cols DllStructSetData($tCustDraw, 'iSubItem', 2) ; always use the 3rd column (the 'sample' col) logmsg("+++: setItemColor($tCustDraw, 0x" & Hex($hWnd) & ") entered ... " _ & ", $iIndex = " & $iIndex & ", $iSubItem = " & $iSubitem & ", $color = " & Hex($color)) DllStructSetData($tCustDraw, 'clrText', $color) ; set the Text color DllStructSetData($tCustDraw, 'clrTextBk', bitnot($color)) ; set the background color EndFunc ;==>setItemColor Func logmsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logmsg
      Here is the full test code:
      #include-once ;#cs #NoTrayIcon #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_UseX64=N Opt("GUICloseOnESC", 1) ; ESC closes GUI? (0 = no, 1 = yes) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("_test_exit") Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GuiCtrlRead tab index Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase #include <GuiListBox.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ColorConstants.au3> Global $__MCP_obj, $__MCP_GUI_hWnd, $idListView, $hListView Global $hMainWin test() Exit Func test() $hMainWin = GUICreate("Test window", 120, 100, @DesktopWidth / 2, -1) GUICtrlCreateButton("Hwnd", 10, 10, 40, 20) GUICtrlSetOnEvent(-1, "handle_1stTEST_btn") GUICtrlCreateButton("ID", 50, 10, 40, 20) GUICtrlSetOnEvent(-1, "handle_2ndTEST_btn") GUISetOnEvent($GUI_EVENT_CLOSE, "_test_exit") GUISetState(@SW_SHOW) While (1) Sleep(17) WEnd EndFunc ;==>test Func _myColorPicker($obj) logmsg("+++: $obj = 0x" & Hex($obj) & @CRLF) Local $flags = 0 Local $ww, $wh, $x, $y, $w, $h $__MCP_obj = $obj $ww = 350 $wh = 500 $x = 200 $y = 150 $__MCP_GUI_hWnd = GUICreate("myColorPicker", $ww, $wh, $x, $y, $flags) $x = 10 $y = 10 $w = 150 $h = 20 GUICtrlCreateButton("Set caller's color", $x, $y, $w, $h) GUICtrlSetOnEvent(-1, "__MCP_handle_SetColor_btn") $y += $h + 5 $w = $ww - 25 $h = $wh - 100 $idListView = GUICtrlCreateListView("", $x, $y, $w, $h, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($idListView) $x = $ww / 2 - 50 $y = $wh - 60 $w = 100 $h = 25 GUICtrlCreateButton("Quit Popup", $x, $y, $w, $h) GUICtrlSetOnEvent(-1, "__MCP_handle_QUIT_btn") GUICtrlSetFont($idListView, 8.5, -1, -1, "courier new") _GUICtrlListView_AddColumn($idListView, "Name", 100) _GUICtrlListView_AddColumn($idListView, "Value", 100) _GUICtrlListView_AddColumn($idListView, "Sample", 100) _GUICtrlListView_SetColumnWidth($idListView, 0, 100) _GUICtrlListView_SetColumnWidth($idListView, 1, 80) logmsg("+++: $idListView = " & $idListView) logmsg("+++: $hListView = 0x" & Hex($hListView)) __MCP_populateListView($hListView) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW, $__MCP_GUI_hWnd) EndFunc ;==>_myColorPicker Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $iDrawStage, $tCustDraw $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam) $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case BitOR(0, $CDDS_ITEMPREPAINT) ;, $CDDS_SUBITEM) setItemColor($tCustDraw, $hWndFrom) Return $CDRF_NOTIFYSUBITEMDRAW EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func setItemColor($tCustDraw, $hWnd) Local $iIndex, $color, $iSubitem $iIndex = DllStructGetData($tCustDraw, 'dwItemSpec') ; item number $color = _GUICtrlListView_GetItemParam($hWnd, $iIndex) $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') ; Here, I want to only change the color of the 3rd col, and not the 1st and 2nd cols DllStructSetData($tCustDraw, 'iSubItem', 2) ; always use the 3rd column (the 'sample' col) logmsg("+++: setItemColor($tCustDraw, 0x" & Hex($hWnd) & ") entered ... " _ & ", $iIndex = " & $iIndex & ", $iSubItem = " & $iSubitem & ", $color = " & Hex($color)) DllStructSetData($tCustDraw, 'clrText', $color) ; set the Text color DllStructSetData($tCustDraw, 'clrTextBk', bitnot($color)) ; set the background color EndFunc ;==>setItemColor Func logmsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logmsg Func __MCP_exit() GUIDelete($__MCP_GUI_hWnd) EndFunc ;==>__MCP_exit Func __MCP_handle_SetColor_btn() If (IsHWnd($__MCP_obj)) Then GUISetBkColor($COLOR_BLUE, $__MCP_obj) Else GUICtrlSetBkColor($__MCP_obj, $COLOR_BLUE) EndIf EndFunc ;==>__MCP_handle_SetColor_btn Func __MCP_populateListView($hWnd) Local $text, $parts, $iIndex Local Static $aItems[] = [ _ "BLACK | " & $CLR_BLACK & "|" & "", _ "BLUE | " & $CLR_BLUE & "|" & "", _ "RED | " & $CLR_RED & "|" & "", _ "WHITE | " & $CLR_WHITE & "|" & "", _ "YELLOW | " & $CLR_YELLOW & "|" & "" _ ] _GUICtrlListView_BeginUpdate($hWnd) _GUICtrlListView_DeleteAllItems($hWnd) For $ndx = 0 To UBound($aItems) - 1 $text = $aItems[$ndx] $parts = StringSplit($text, "|", 2) $parts[0] = StringStripWS($parts[0], 3) $parts[2] = StringStripWS($parts[2], 3) $iIndex = _GUICtrlListView_AddItem($hWnd, $parts[0], -1, $parts[1]) _GUICtrlListView_AddSubItem($hWnd, $iIndex, Hex($parts[1]), 1) _GUICtrlListView_AddSubItem($hWnd, $iIndex, $parts[0], 2) Next _GUICtrlListView_EndUpdate($hWnd) EndFunc ;==>__MCP_populateListView Func __MCP_handle_QUIT_btn() GUIDelete($__MCP_GUI_hWnd) EndFunc ;==>__MCP_handle_QUIT_btn Func handle_1stTEST_btn() _myColorPicker($hMainWin) EndFunc ;==>handle_1stTEST_btn Func handle_2ndTEST_btn() _myColorPicker(@GUI_CtrlId) EndFunc ;==>handle_2ndTEST_btn Func _test_exit() Exit EndFunc ;==>_test_exit  
    • Skeletor
      By Skeletor
      Hi All,
      I know many newbies search for this feature.
      I decided to share this piece of code with everyone.
      Basically its a "splash screen" that has a transparent image.
      In a nutshell - Gui with a transparent gif.
      Enjoy...
      Download attachment....
       
      Splash Screen GUI.zip
    • Skeletor
      By Skeletor
      Hi Developers,
       
      While trying to find a way to actually style/skin the GUICtrlCreateTabItem, I read the help file and stated:
      My question to you guys is will this be updated? or am I hoping for something that will never come to pass?
      I've seen scripts between 2007 to 2009 allowing the tabs to be modified
      Reason for my question is I'm trying to make my GUI Tabs look more modern.
      Thanks in advance for reading my post.