Opened 16 years ago

Closed 16 years ago

#104 closed Bug (Fixed)

Problem with _GUICtrlListView_RegisterSortCallBack and WM_NOTIFY

Reported by: Wooltown <sven.ullstad@…> Owned by: Gary
Milestone: Component: AutoIt
Version: Severity:
Keywords: Cc:


If you in the same script use _GUICtrlListView_RegisterSortCallBack and WM_NOTIFY just one of them will work, the latest in the code will work.
In the attached example if I put _GUICtrlListView_RegisterSortCallBack first, then WM_NOTIFY will work, if I put WM_NOTIFY first then _GUICtrlListView_RegisterSortCallBack will work. Is there a solution for this ?
Running AutoIt on English Windows 2000 SP4

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)


Func _Example1()
	Local $hImage, $hListView, $aIcons[3] = [0, 3, 6]

	GUICreate("ListView Register Sort Callback", 300, 200)

	$hListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
	_GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle)

	; Load images
	$hImage = _GUIImageList_Create(18, 18, 5, 3)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
	_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
	_GUICtrlListView_SetImageList($hListView, $hImage, 1)

	_AddRow($hListView, "ABC|000666|10.05.2004", $aIcons)
	_AddRow($hListView, "DEF|444|11.05.2005", $aIcons, 1)
	_AddRow($hListView, "CDE|555|12.05.2004", $aIcons, 2)

	GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
	;GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

	While 1
		Switch GUIGetMsg()

EndFunc   ;==>_Example1

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
	#forceref $hWndGUI, $MsgID, $wParam
	Local $tagNMHDR, $event
	$tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
	If @error Then Return
	$event = DllStructGetData($tagNMHDR, 3)
			Switch $event
				Case $NM_RCLICK

Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
	Local $aItem = StringSplit($sItem, "|")
	Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
	_GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

	For $x = 2 To $aItem[0]
		_GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
		_GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
EndFunc   ;==>_AddRow

Attachments (0)

Change History (4)

comment:1 Changed 16 years ago by Gary

  • Owner set to Gary
  • Status changed from new to assigned

I made this for those that have no knowledge of how to use WM_NOTIFY or callbacks and Simple Sort wasn't enough.

If you need to use WM_NOTIFY for other things then don't use _GUICtrlListView_RegisterSortCallBack.

If this becomes to much of a problem I can always remove it.

comment:2 Changed 16 years ago by Gary

There may be another way to have both, If I can work it out it'll be in the next.

comment:3 Changed 16 years ago by Wooltown <sven.ullstad@…>

Found this solution, I don't know about the performance, but it seems simple.

comment:4 Changed 16 years ago by Gary

  • Milestone set to
  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Gary.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.