Jump to content

Annoying ListView thing ! (SOLVED!)


Recommended Posts

I recently managed to make a ListView sort correctly by clicking on it's columns, it does sort items very well but there's a very annoying thing >_< : every time after the items are sorted out, an item gets focused ! After I click a column, one item gets blue'd, like when its selected, even if its not !

Note that this happens only becuase of this function : _GUICtrlListView_SimpleSort

Instead, the _GUICtrlListView_SortItems function is not doing this , but because of my luck,I must use _GUICtrlListView_SimpleSort :( ( but it is faster :) )

Here's my script to test to see what I mean:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
$Form1 = GUICreate("Form1", 383, 307, 192, 124)
$ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
$ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1)
GUISetState(@SW_SHOW)
Global $toggle = 1
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ListView1
_GUICtrlListView_SimpleSort($ListView1, $toggle, GUICtrlGetState($ListView1))
EndSwitch
WEnd

How could I get rid of this item focus ?

Edited by Rickname
Link to comment
Share on other sites

If there aren't many items, i would use and array and then

_GUICtrlListView_GetItemFocused($hWnd, $iIndex)

if true then

_GUICtrlListView_SetItemFocused($hWnd, $iIndex, False)

Or

_GUICtrlListView_GetItemCount($hWnd)

and unfocus all

_GUICtrlListView_SetItemFocused($hWnd, $iIndex, False)

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

@careca, I tried this and it doesn't work! The _GUICtrlListView_SetItemFocused function doesn't make any effect ! The interesting part is, the function is returning 'True' , but that item still remains blue o_o !

Here's the script :

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
$Form1 = GUICreate("Form1", 383, 307, 192, 124)
$ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
$ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1)
GUISetState(@SW_SHOW)
Global $toggle = 1
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ListView1
_GUICtrlListView_SimpleSort($ListView1, $toggle, GUICtrlGetState($ListView1))
$index = _GUICtrlListView_GetSelectedIndices($Listview1, True) ; get the idex of the selected item from the ListView
;MsgBox(0,"",$index[1])
ConsoleWrite(_GUICtrlListView_SetItemFocused($Listview1, $index[1], False)) ; Unfocus it and display the result
EndSwitch
WEnd
Edited by Rickname
Link to comment
Share on other sites

I don't think you can remove the focus color.

The reason why you see the blue line after sorting and before you even touched any row in the Listview is that the focus is put to the first row by default.

I guess that not showing the Blue bar by default on Row 1 is more of an issue.

I have an 'ugly' quick fix to remove the blue focus bar, but...

Case $ListView1
_GUICtrlListView_SimpleSort($ListView1, $toggle, GUICtrlGetState($ListView1))
$cursor = MouseGetCursor()
GUISetCursor(16, 1)
$aMousePos = MouseGetPos()
MouseClick("left", 320,300, 1, 1)
MouseMove ( $aMousePos[0], $aMousePos[1] , 1 )
GUISetCursor($cursor)

...I must admit that i would never do that myself... :shifty:

GreenCan

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

mikell,

Far much better than my mousemove...

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

Thats it, I finally solved it :)

Here's what I did : after the sorting command, I added this : _GUICtrlListView_SetItemSelected($Listview1, $index[1], False,False) This unselects and unfocuses the selected item from the listview.

Here's all the source code :)

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>

$Form = GUICreate("Form", 383, 307, 192, 124)
$Listview = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)

GUICtrlCreateListViewItem("1|5|6", $Listview)
GUICtrlCreateListViewItem("2|7|8", $Listview)
GUICtrlCreateListViewItem("3|9|10", $Listview)
GUICtrlCreateListViewItem("4|11|12", $Listview)
GUISetState(@SW_SHOW)

Global $toggle = 1

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Listview ; sorting function
_GUICtrlListView_SimpleSort($Listview, $toggle, GUICtrlGetState($Listview))

If _GUICtrlListView_GetSelectedCount($Listview) Then ; if is there any item(s) selected, then :
$index = _GUICtrlListView_GetSelectedIndices($Listview, True) ; get the idex of the selected item(s) from the ListView control
For $i = 1 To $index[0]
_GUICtrlListView_SetItemSelected($listview, $index[$i], False,False) ; Unselect them :)
Next
Endif

Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Edited by Rickname
Link to comment
Share on other sites

I don't think you understood what i wrote,

i said, in an array, to go thru all items, use: GETItem

_GUICtrlListView_GetItemFocused($hWnd, $iIndex)

if it retrieves true, means it has the focus then SETItem

_GUICtrlListView_SetItemFocused($hWnd, $iIndex, False)

Unfocus it.

Anyway, im glad you sorted it out. :)

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Yes , I did that too, but hadn't work !

Also my method is better, it gets exactly the items that are focused, no need to 'ask' every item from the list if is focused or not :)

Edited by Rickname
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

×
×
  • Create New...