Jump to content

WS_EX_COMPOSITED style problem


Recommended Posts

Heya!

I have a problem: if I create window with the $WS_EX_COMPOSITED style, then the window starts to lag badly, and does not respond anymore to the events (like $GUI_EVENT_CLOSE).

If I remove the ListView from the window it just works well.

Can somebody tell me, what I am doing wrong? (I would need both the style and the listview)

Can somebody solve this problem?

Ps. Take care, the script can be stoped only with CTRL+Break or CTRL+ALT+DEL :mellow:

Greetz, CyRius

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

Global $iGUI_CLOSE = 0
Global $listContent,$treeView,$labelTable

AutoItSetOption('GUIOnEventMode',1)

$hGUI = GUICreate('Window',600,320,Default,Default,Default,$WS_EX_COMPOSITED)
GUISetFont(Default,Default,Default,'Tahoma')
GUICtrlCreateMenu('File')

$treeView = GUICtrlCreateTreeView(0,0,150,300,BitOR(0x0001,0x0002,0x0004,0x0010,0x0020),$WS_EX_CLIENTEDGE)

$labelTable = GUICtrlCreateLabel('Label',150,0,450,20,BitOR(0x0200,0x0001))
GUICtrlSetFont($labelTable,Default,1200)
GUICtrlSetBkColor($labelTable,0xCCCCCC)

$listContent = GUICtrlCreateListView('',149,20,452,280)
_GUICtrlListView_SetExtendedListViewStyle($listContent,BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES))

GUISetOnEvent($GUI_EVENT_CLOSE,'_OnClose')
GUIRegisterMsg($WM_NOTIFY,'WM_NOTIFY')
GUISetState(@SW_SHOW)

While $iGUI_CLOSE = 0
    Sleep(100)
WEnd

Func WM_NOTIFY($hGUI,$iMsg,$wParam,$lParam)
    $tNMHDR = DllStructCreate($tagNMHDR,$lParam)
    $iCode = DllStructGetData($tNMHDR,'Code')
    If $iCode = $NM_DBLCLK Then
        $tInfo = DllStructCreate($tagNMITEMACTIVATE,$lParam)
        $iIndex = DllStructGetData($tInfo,'Index')
        Switch DllStructGetData($tNMHDR,'IDFrom')
            Case $listContent
            Case $treeView
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func _OnClose()
    $iGUI_CLOSE = 1
EndFunc
Edited by CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Link to comment
Share on other sites

This sounds like a familiar problem. I'm fairly sure I have concluded in the past that you can't use WS_EX_COMPOSITED with a listview.

Why do you want that style? (Perhaps there is another way.)

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hmm, I never read that I can't use this style with a listview control ^^

I need it, because resizing/moving the window makes it blinking. It is not important, just it looks so lame without this style.

I know there is a function which enables you to "hide the content of the window during move/resize", but I never liked it:)

Do you say, that is impossible to make it work together?

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Link to comment
Share on other sites

Martin, I did not know that the problem is known. I made a bugreport 3 weeks ago.

http://www.autoitscript.com/trac/autoit/ticket/1492

I wanted to try to reduce flickering while resizing the gui.

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Martin, I did not know that the problem is known. I made a bugreport 3 weeks ago.

http://www.autoitscript.com/trac/autoit/ticket/1492

I wanted to try to reduce flickering while resizing the gui.

Well I think I mentioned the problem in the Koda thread once but it doesn't mean it has been reported as a bug.

If I create a form in Delphi with a listView and run the program the form and the listview resize with no flicker. If I get the extended style of the form it is 0x00010100. I don't know what 0x10000 is but if I try that in AutoIt it stops the script working.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@martin

Is there any other way to by-pass the "flickering"?

Edited by CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Link to comment
Share on other sites

@martin

Is there any other way to by-pass the "flickering"?

Simplest, but possibly not acceptable, way is

#include <ListViewConstants.au3>
#include <StructureConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <constants.au3>
Global $iGUI_CLOSE = 0
Global $listContent,$treeView,$labelTable

AutoItSetOption('GUIOnEventMode',1)

$hGUI = GUICreate('Window',600,320,Default,Default,BitOr($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX));,$WS_EX_COMPOSITED)
GUISetFont(Default,Default,Default,'Tahoma')
GUICtrlCreateMenu('File')
$listContent = GUICtrlCreateListView('34te4t',149,20,452,280)
_GUICtrlListView_SetExtendedListViewStyle($listContent,BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES))
$treeView = GUICtrlCreateTreeView(0,0,150,300,BitOR(0x0001,0x0002,0x0004,0x0010,0x0020),$WS_EX_CLIENTEDGE)

$labelTable = GUICtrlCreateLabel('Label',150,0,450,20,BitOR(0x0200,0x0001))
GUICtrlSetFont($labelTable,Default,1200)
GUICtrlSetBkColor($labelTable,0xCCCCCC)


;GUICtrlSetState($listContent,$GUI_DISABLE)

GUISetOnEvent($GUI_EVENT_CLOSE,'_OnClose')
GUIRegisterMsg($WM_NOTIFY,'WM_NOTIFY')
Global Const $WM_ENTERSIZEMOVE = 0x231, $WM_EXITSIZEMOVE = 0x232

GUIRegisterMsg($WM_ENTERSIZEMOVE,"EnterSM")
GUIRegisterMsg($WM_EXITSIZEMOVE,"ExitSM")
GUISetState(@SW_SHOW)

While $iGUI_CLOSE = 0
    Sleep(100)
WEnd

Func WM_NOTIFY($hGUI,$iMsg,$wParam,$lParam)
    $tNMHDR = DllStructCreate($tagNMHDR,$lParam)
    $iCode = DllStructGetData($tNMHDR,'Code')
    If $iCode = $NM_DBLCLK Then
    $tInfo = DllStructCreate($tagNMITEMACTIVATE,$lParam)
    $iIndex = DllStructGetData($tInfo,'Index')
    Switch DllStructGetData($tNMHDR,'IDFrom')
    Case $listContent
    Case $treeView
    EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func _OnClose()
    $iGUI_CLOSE = 1
EndFunc

Func EnterSM($hW,$iM,$wP,$lP)
    guictrlsetstate($listContent,$GUI_HIDE)
    Local $estate = _winapi_setwindowlong($hGui,$GWL_EXSTYLE,$WS_EX_COMPOSITED)

EndFunc


Func ExitSM($hW,$iM,$wP,$lP)
    guictrlsetstate($listContent,$GUI_SHOW)
    Local $estate = _winapi_setwindowlong($hGui,$GWL_EXSTYLE,0)


EndFunc

EDIT: removed a daft idea:>

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@martin

Hehe, this looks crappy, but thank you very much xD

I will use this code until, somebody will fix this bug (if it can be fixed)

This way the problem is solved (temporary) ^^

Greetings, CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Link to comment
Share on other sites

@martin

Hehe, this looks crappy, but thank you very much xD

I will use this code until, somebody will fix this bug (if it can be fixed)

This way the problem is solved (temporary) ^^

Greetings, CyRius

Yes, crappy is true :mellow:

A listbox doesn't have this problem so if you could use one instead it might be a better solution.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I can't use it because I have more columns (changing).. And I am pretty sure about ListBox control cannot handle multiple columns.

I wonder what is causing this bug using both the style and the control? (why it is incompatible with ListView?)

Edited by CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Link to comment
Share on other sites

  • 2 weeks later...

SOLUTION:

If we remove the header (the column names) of the ListViews the $WS_ES_COMPOSITED style works very well:P

Edited by CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Link to comment
Share on other sites

This is no solution for me. I need the header for sorting the columns.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

This is no solution for me. I need the header for sorting the columns.

@Cryius - Interesting to know that.

@funkey. You could now improve the "crappy" solution I posted but improved with this knowledge.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <listviewconstants.au3>
#include <winapi.au3>

Opt('MustDeclareVars', 1)
Global $listview0, $Gui
Example()

Func Example()
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg
    Opt("GuiResizeMode", $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT)
    $Gui = GUICreate("listview items", 220, 350, 100, 200, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
    GUISetBkColor(0x00E0FFFF) ; will change background color

    GUICtrlCreateLabel("", 11, 11, 198, 16)
    GUICtrlSetBkColor(-1, 0xEEEEEE)
    GUICtrlCreateLabel("", 10, 10, 200, 18)
    GUICtrlSetBkColor(-1, 0x9999BB)
    $listview0 = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 18)
    $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 27, 200, 140, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER));,$LVS_SORTDESCENDING)
    
    $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
    $item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
    $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
    $input1 = GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState()
    GUIRegisterMsg(0x0231, "EnterSM");$WM_ENTERSIZEMOVE
    GUIRegisterMsg(0x0232, "ExitSM");$WM_EXITSIZEMOVE
    Sleep(2000)
    
    GUICtrlSetData($item2, "ITEM1")
    GUICtrlSetData($item3, "||COL33")
    GUICtrlDelete($item1)

    Do
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $button
                MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2)
            Case $msg = $listview
                MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example

Func EnterSM($hW, $iM, $iW, $iP)
    GUICtrlSetState($listview0, $GUI_HIDE)
    _WinAPI_SetWindowLong ($Gui, $GWL_EXSTYLE, $WS_EX_COMPOSITED)
    
EndFunc ;==>EnterSM

Func ExitSM($hW, $iM, $iW, $iP)
    _WinAPI_SetWindowLong ($Gui, $GWL_EXSTYLE, 0)
    GUICtrlSetState($listview0, $GUI_SHOW)
EndFunc ;==>ExitSM

And you could get the information on the column widths to only use labels and not need the dummy header. I think compared to your tab udf that would be quite easy.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Good idea martin! I will have a look on it.

You could also lock the gui during resizing.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <listviewconstants.au3>
#include <winapi.au3>

Opt('MustDeclareVars', 1)
Global $listview0, $Gui
Example()

Func Example()
 Local $listview, $button, $item1, $item2, $item3, $input1, $msg
 Opt("GuiResizeMode", $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT)
 $Gui = GUICreate("listview items", 220, 350, 100, 200, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
 GUISetBkColor(0x00E0FFFF) ; will change background color

 $listview0 = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 18)
 $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 27, 200, 140, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER));,$LVS_SORTDESCENDING)

 $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
 $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
 $item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
 $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
 $input1 = GUICtrlCreateInput("", 20, 200, 150)
 GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
 GUISetState()
 GUIRegisterMsg(0x0231, "EnterSM");$WM_ENTERSIZEMOVE
 GUIRegisterMsg(0x0232, "ExitSM");$WM_EXITSIZEMOVE
 Sleep(2000)

 GUICtrlSetData($item2, "ITEM1")
 GUICtrlSetData($item3, "||COL33")
 GUICtrlDelete($item1)

 Do
  $msg = GUIGetMsg()

  Select
   Case $msg = $button
    MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2)
   Case $msg = $listview
    MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
  EndSelect
 Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func EnterSM($hW, $iM, $iW, $iP)
 GUISetState(@SW_LOCK)
 GUICtrlSetState($listview0, $GUI_HIDE)
 _WinAPI_SetWindowLong($Gui, $GWL_EXSTYLE, $WS_EX_COMPOSITED)

EndFunc   ;==>EnterSM

Func ExitSM($hW, $iM, $iW, $iP)
 _WinAPI_SetWindowLong($Gui, $GWL_EXSTYLE, 0)
 GUICtrlSetState($listview0, $GUI_SHOW)
 GUISetState(@SW_UNLOCK)
EndFunc   ;==>ExitSM

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Good idea martin! I will have a look on it.

You could also lock the gui during resizing.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <listviewconstants.au3>
#include <winapi.au3>

Opt('MustDeclareVars', 1)
Global $listview0, $Gui
Example()

Func Example()
 Local $listview, $button, $item1, $item2, $item3, $input1, $msg
 Opt("GuiResizeMode", $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT)
 $Gui = GUICreate("listview items", 220, 350, 100, 200, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
 GUISetBkColor(0x00E0FFFF) ; will change background color

 $listview0 = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 18)
 $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 27, 200, 140, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER));,$LVS_SORTDESCENDING)

 $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
 $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
 $item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
 $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
 $input1 = GUICtrlCreateInput("", 20, 200, 150)
 GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
 GUISetState()
 GUIRegisterMsg(0x0231, "EnterSM");$WM_ENTERSIZEMOVE
 GUIRegisterMsg(0x0232, "ExitSM");$WM_EXITSIZEMOVE
 Sleep(2000)

 GUICtrlSetData($item2, "ITEM1")
 GUICtrlSetData($item3, "||COL33")
 GUICtrlDelete($item1)

 Do
 $msg = GUIGetMsg()

 Select
 Case $msg = $button
 MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2)
 Case $msg = $listview
 MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
 EndSelect
 Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example

Func EnterSM($hW, $iM, $iW, $iP)
 GUISetState(@SW_LOCK)
 GUICtrlSetState($listview0, $GUI_HIDE)
 _WinAPI_SetWindowLong($Gui, $GWL_EXSTYLE, $WS_EX_COMPOSITED)

EndFunc ;==>EnterSM

Func ExitSM($hW, $iM, $iW, $iP)
 _WinAPI_SetWindowLong($Gui, $GWL_EXSTYLE, 0)
 GUICtrlSetState($listview0, $GUI_SHOW)
 GUISetState(@SW_UNLOCK)
EndFunc ;==>ExitSM

That works well but I would prefer it if there was a frame which showed the window extremes while you resized.

I notice there is a listview extended style $LVS_EX_DOUBLEBUFFER which I thought might be a better solution than using $WS_EX_COMPOSITED for the window. I tried it but it doesn't reduce the flicker for me.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I notice there is a listview extended style $LVS_EX_DOUBLEBUFFER which I thought might be a better solution than using $WS_EX_COMPOSITED for the window. I tried it but it doesn't reduce the flicker for me.

It's not supposed to. That style reduces flicker when you resize columns, not the whole listview.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...