Jump to content
Sign in to follow this  
AuToItItAlIaNlOv3R

Search on .ini file

Recommended Posts

Jos

...only a question...now if i write for example England...it give me also the name of the section [England] how i can exclude that result?...

Not for me. When I change BBC to England, nothing is shown... as it should.

Show how you have integrated my code in your script.


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

Unfurtnately i don't know why but now your script dont work...scite five me this error with this code...

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
; Read INI into a single array
Global $AllIniSec = IniReadSectionNames("station.ini")
Dim $AllStations[100][3]
$AllStationsCount = 0
If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $s = 1 To $AllIniSec[0]
        $var = IniReadSection("station.ini", $AllIniSec[$s])
        If @error Then
            MsgBox(4096, "", "Error occurred, probably no INI file.")
        Else
            For $i = 1 To $var[0][0]
                $AllStations[$AllStationsCount][0] = $AllIniSec[$s] ; Country
                $AllStations[$AllStationsCount][1] = $var[$i][0] ; Key
                $AllStations[$AllStationsCount][2] = $var[$i][1] ; Value
                $AllStationsCount += 1
            Next
        EndIf
    Next
EndIf
; Print all stations containing BBC
For $x = 0 To $AllStationsCount - 1
    If StringInstr($AllStations[$x][1],"BBC") Then
        ConsoleWrite("Country=")
        ConsoleWrite($AllStations[$x][0])
        ConsoleWrite("   Radioname=")
        ConsoleWrite($AllStations[$x][1])
        ConsoleWrite("   Link info=")
        ConsoleWrite($AllStations[$x][2])
        ConsoleWrite(@CRLF)
    EndIf
Next

This is the error :

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$AllStations[$AllStationsCount][0] = $AllIniSec[$s]

Why? Another question why you put this array to 100?

Dim $AllStations[100][3]

@EDIT

I fix it, i've increased this Dim $AllStations[100][3]...how i can set this variable with the right numer of radio station...because the radio station are increasing whit the time and there is a possible error to have a range exceed :x

Edited by AuToItItAlIaNlOv3R

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

Ok i write the script, there are only other 2 problems :x...Your help was very precious.

I've this code :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>

#Region //GUI
Local $hGUI = GUICreate("Form2", 581, 348, 275, 147)
Local $hComboBox = _GUICtrlComboBox_Create($hGUI, "", 152, 8, 185, 25)
$Label1 = GUICtrlCreateLabel("Search your preferite radio:", 8, 8, 131, 17)
Local $ListView = GUICtrlCreateListView("Name|Streaming|Web Site|Genere", 0, 32, 577, 313)
Local $hListView = GUICtrlGetHandle($ListView)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 120)
GUISetState(@SW_SHOW)
#EndRegion //GUI

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")


Global $AllIniSec = IniReadSectionNames("station.ini")
Dim $AllStations[5000][3]
$AllStationsCount = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem

    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)

    Switch $hWndFrom
        Case $hComboBox
            Switch $iCode
                Case $CBN_EDITCHANGE
                    $sText = _GUICtrlComboBox_GetEditText($hComboBox)

                    If $sText <> "" Then
                        _UpdateListView($sText)
                    Else
                        _GUICtrlListView_DeleteAllItems($hListView)
                    EndIf
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Func _UpdateListView($sText)
    _GUICtrlListView_BeginUpdate($hListView)
    _GUICtrlListView_DeleteAllItems($hListView)
    For $s = 1 To $AllIniSec[0]
        $var = IniReadSection("station.ini", $AllIniSec[$s])
        If @error Then
            MsgBox(4096, "", "Error occurred, probably no INI file.")
        Else
            For $i = 1 To $var[0][0]
                $AllStations[$AllStationsCount][0] = $AllIniSec[$s] ; Country
                $AllStations[$AllStationsCount][1] = $var[$i][0] ; Key
                $AllStations[$AllStationsCount][2] = $var[$i][1] ; Value
                $AllStationsCount += 1
            Next
        EndIf
    Next
    For $x = 0 To $AllStationsCount - 1
        If StringInStr($AllStations[$x][1], $sText) Then
            GUICtrlCreateListViewItem($AllStations[$x][1] & "|" & $AllStations[$x][1] & "|" & $AllStations[$x][1] & "|" & $AllStations[$x][1], $ListView)
        EndIf
    Next
    _GUICtrlListView_EndUpdate($hListView)
EndFunc   ;==>_UpdateListView

The script work only if i insert in combobox only one letter, if i want insert for example this string "bbc" it give me this error:

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$AllStations[$AllStationsCount][0] = $AllIniSec[$s]

I think that was a problem in func "_UpdateListView", but i dont know where is the error and how to fix that. :shifty:

And other question...now i've thos array where are all link of searched radio: $AllStations[$x][2], this contain straming link and web site link. I try to split it without succes...how i can split that for inserct the right data in listview?...becouse how u can wath in list view now show only name of radio in all listview column.

Thank's for help :P

Edited by AuToItItAlIaNlOv3R

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

up

Share this post


Link to post
Share on other sites
Melba23

AuToItItAlIaNlOv3R,

Your code does not error for me, but I can see why it might. :nuke:

You are continually adding found radio stations to your array, which could therefore fill pretty quickly. You need to reset the array count as well as empty the ListView each time you refill it - see the code below. :x

As to splitting the data - I showed you how to do that on the previous page. You do look at what we post I hope! :lol:

This amended _UpdateListView function should do the trick: :P

Func _UpdateListView($sText)
    _GUICtrlListView_BeginUpdate($hListView)
    _GUICtrlListView_DeleteAllItems($hListView)

    $AllStationsCount = 0 ; Reset the count each time <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    For $s = 1 To $AllIniSec[0]
        $var = IniReadSection("station.ini", $AllIniSec[$s])
        If @error Then
            MsgBox(4096, "", "Error occurred, probably no INI file.")
        Else
            For $i = 1 To $var[0][0]
                $AllStations[$AllStationsCount][0] = $AllIniSec[$s] ; Country
                $AllStations[$AllStationsCount][1] = $var[$i][0] ; Key
                $AllStations[$AllStationsCount][2] = $var[$i][1] ; Value
                $AllStationsCount += 1
            Next
        EndIf
    Next
    For $x = 0 To $AllStationsCount - 1
        If StringInStr($AllStations[$x][1], $sText) Then
            $aData = StringSplit($AllStations[$x][2], "|") ; Split the value on the delimiter <<<<<<<<<<<<<<<<<<<<<
            $sItemText = $AllStations[$x][1]
            For $a = 1 To $aData[0]
                $sItemText &= "|" & $aData[$a] ; Add the items to the Item text <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Next
            GUICtrlCreateListViewItem($sItemText, $ListView)
        EndIf
    Next
    _GUICtrlListView_EndUpdate($hListView)
EndFunc   ;==>_UpdateListView

The <<<<<<<<<<<<< lines show where I have amended the code.

All clear? :shifty:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

@Melba

Thank's a lot Melba23 your function work very well, but it's slow :x

The ultimate bug to fix...i've added a control to reproduce the selected radio...but now with this function the search function give me a "fake result":

Now it's my code :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>

#Region //GUI
Local $hGUI = GUICreate("Form2", 581, 348, 275, 147)
Local $hComboBox = _GUICtrlComboBox_Create($hGUI, "", 152, 8, 185, 25)
$Label1 = GUICtrlCreateLabel("Search your preferite radio:", 8, 8, 131, 17)
Local $ListView = GUICtrlCreateListView("Name|Streaming|Web Site|Genere", 0, 32, 577, 313)
Local $hListView = GUICtrlGetHandle($ListView)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 120)
GUISetState(@SW_SHOW)
#EndRegion //GUI

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
$gMediaObject = _CreateWMPlayer()
Global $AllIniSec = IniReadSectionNames("station.ini")
Dim $AllStations[5000][3]
$AllStationsCount = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)

    Switch $hWndFrom
        Case $hComboBox
            Switch $iCode
                Case $CBN_EDITCHANGE
                    $sText = _GUICtrlComboBox_GetEditText($hComboBox)

                    If $sText <> "" Then
                        _UpdateListView($sText)
                    Else
                        _GUICtrlListView_DeleteAllItems($hListView)
                    EndIf
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Func _UpdateListView($sText)
    _GUICtrlListView_BeginUpdate($hListView)
    _GUICtrlListView_DeleteAllItems($hListView)

    $AllStationsCount = 0 ; Reset the count each time <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    For $s = 1 To $AllIniSec[0]
        $var = IniReadSection("station.ini", $AllIniSec[$s])
        If @error Then
            MsgBox(4096, "", "Error occurred, probably no INI file.")
        Else
            For $i = 1 To $var[0][0]
                $AllStations[$AllStationsCount][0] = $AllIniSec[$s] ; Country
                $AllStations[$AllStationsCount][1] = $var[$i][0] ; Key
                $AllStations[$AllStationsCount][2] = $var[$i][1] ; Value
                $AllStationsCount += 1
            Next
        EndIf
    Next
    For $x = 0 To $AllStationsCount - 1
        If StringInStr($AllStations[$x][1], $sText) Then
            $aData = StringSplit($AllStations[$x][2], "|") ; Split the value on the delimiter <<<<<<<<<<<<<<<<<<<<<
            $sItemText = $AllStations[$x][1]
            For $a = 1 To $aData[0]
                $sItemText &= "|" & $aData[$a] ; Add the items to the Item text <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Next
            GUICtrlCreateListViewItem($sItemText, $ListView)
        EndIf
    Next
    _GUICtrlListView_EndUpdate($hListView)
EndFunc   ;==>_UpdateListView

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $I
    Global $hWndFrom, $iCode, $tNMHDR, $hWndListView, $lParam
    $hWndListView = $ListView
    $hWnd1 = $hGUI
    If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_ITEMACTIVATE
                    Local $nmia = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    $I = DllStructGetData($nmia, "Index")
                    $SomeVariablex = _GUICtrlListView_GetItemTextArray($ListView)
                    $gMediaObject.URL = $SomeVariablex[2]
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

Func _CreateWMPlayer()
    $Object = ObjCreate("WMPlayer.OCX.7")
    $Object.URL = ""
    Return $Object
EndFunc   ;==>_CreateWMPlayer

How you can see i've added the "_WM_NOTIFY" function...this function work, it give me the correct selected item and reproduce the selected radio, but now the result of search give me a fake result :P...see this picture for example :shifty:

Posted Image

You know how to fix that?...Thank's for all

Happt new year :nuke:

Edited by AuToItItAlIaNlOv3R

Share this post


Link to post
Share on other sites
Melba23

AuToItItAlIaNlOv3R,

As far as I can tell everything is working correctly. Please post the file you are using so I can test on that. :x

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

The error with "_WM_NOTIFY" function active seems to be when the .ini (~600Kb) file is big...with a tiny station.ini file all work with well. But all work good if i don't include "_WM_NOTIFY".

This is my code with "_WM_NOTIFY"...and if i include this function i've this error...it give me fake result as you can see on the image that i've posted.

This is my code

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>

#Region //GUI
Local $hGUI = GUICreate("Form2", 581, 348, 275, 147)
Local $hComboBox = _GUICtrlComboBox_Create($hGUI, "", 152, 8, 185, 25)
$Label1 = GUICtrlCreateLabel("Search your preferite radio:", 8, 8, 131, 17)
Local $ListView = GUICtrlCreateListView("Name|Streaming|Web Site|Genere", 0, 32, 577, 313)
Local $hListView = GUICtrlGetHandle($ListView)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 120)
GUISetState(@SW_SHOW)
#EndRegion //GUI

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
$gMediaObject = _CreateWMPlayer()
Global $AllIniSec = IniReadSectionNames("station.ini")
Dim $AllStations[5000][3]
$AllStationsCount = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)

    Switch $hWndFrom
        Case $hComboBox
            Switch $iCode
                Case $CBN_EDITCHANGE
                    $sText = _GUICtrlComboBox_GetEditText($hComboBox)

                    If $sText <> "" Then
                        _UpdateListView($sText)
                    Else
                        _GUICtrlListView_DeleteAllItems($hListView)
                    EndIf
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Func _UpdateListView($sText)
    _GUICtrlListView_BeginUpdate($hListView)
    _GUICtrlListView_DeleteAllItems($hListView)

    $AllStationsCount = 0 ; Reset the count each time <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    For $s = 1 To $AllIniSec[0]
        $var = IniReadSection("station.ini", $AllIniSec[$s])
        If @error Then
            MsgBox(4096, "", "Error occurred, probably no INI file.")
        Else
            For $i = 1 To $var[0][0]
                $AllStations[$AllStationsCount][0] = $AllIniSec[$s] ; Country
                $AllStations[$AllStationsCount][1] = $var[$i][0] ; Key
                $AllStations[$AllStationsCount][2] = $var[$i][1] ; Value
                $AllStationsCount += 1
            Next
        EndIf
    Next
    For $x = 0 To $AllStationsCount - 1
        If StringInStr($AllStations[$x][1], $sText) Then
            $aData = StringSplit($AllStations[$x][2], "|") ; Split the value on the delimiter <<<<<<<<<<<<<<<<<<<<<
            $sItemText = $AllStations[$x][1]
            For $a = 1 To $aData[0]
                $sItemText &= "|" & $aData[$a] ; Add the items to the Item text <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Next
            GUICtrlCreateListViewItem($sItemText, $ListView)
        EndIf
    Next
    _GUICtrlListView_EndUpdate($hListView)
EndFunc   ;==>_UpdateListView

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $I
    Global $hWndFrom, $iCode, $tNMHDR, $hWndListView, $lParam
    $hWndListView = $ListView
    $hWnd1 = $hGUI
    If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_ITEMACTIVATE
                    Local $nmia = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    $I = DllStructGetData($nmia, "Index")
                    $SomeVariablex = _GUICtrlListView_GetItemTextArray($ListView)
                    $gMediaObject.URL = $SomeVariablex[2]
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

Func _CreateWMPlayer()
    $Object = ObjCreate("WMPlayer.OCX.7")
    $Object.URL = ""
    Return $Object
EndFunc   ;==>_CreateWMPlayer

My real radio file is very big...i can't send you that :x...it's "_WM_NOTIFY" func the problem...becouse without that all work good even on large .ini files.

Hi and thank's to help

Share this post


Link to post
Share on other sites
Melba23

AuToItItAlIaNlOv3R,

As I said before, it all works for me with the small ini file you posted above. If you do not post a larger version which gives the error so that I can test it and reproduce the problem, then I cannot really help further. :P

It is only a text file - what size does it reduce to if you zip it? :x

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

This is a part of my station.ini...you can donwload it here...with this code try to search for example "asd":

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>

#Region //GUI
Local $hGUI = GUICreate("Form2", 581, 348, 275, 147)
Local $hComboBox = _GUICtrlComboBox_Create($hGUI, "", 152, 8, 185, 25)
$Label1 = GUICtrlCreateLabel("Search your preferite radio:", 8, 8, 131, 17)
Local $ListView = GUICtrlCreateListView("Name|Streaming|Web Site|Genere", 0, 32, 577, 313)
Local $hListView = GUICtrlGetHandle($ListView)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 120)
GUISetState(@SW_SHOW)
#EndRegion //GUI

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
$gMediaObject = _CreateWMPlayer()
Global $AllIniSec = IniReadSectionNames("station.ini")
Dim $AllStations[5000][3]
$AllStationsCount = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)

    Switch $hWndFrom
        Case $hComboBox
            Switch $iCode
                Case $CBN_EDITCHANGE
                    $sText = _GUICtrlComboBox_GetEditText($hComboBox)

                    If $sText <> "" Then
                        _UpdateListView($sText)
                    Else
                        _GUICtrlListView_DeleteAllItems($hListView)
                    EndIf
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Func _UpdateListView($sText)
    _GUICtrlListView_BeginUpdate($hListView)
    _GUICtrlListView_DeleteAllItems($hListView)

    $AllStationsCount = 0 ; Reset the count each time <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    For $s = 1 To $AllIniSec[0]
        $var = IniReadSection("station.ini", $AllIniSec[$s])
        If @error Then
            MsgBox(4096, "", "Error occurred, probably no INI file.")
        Else
            For $i = 1 To $var[0][0]
                $AllStations[$AllStationsCount][0] = $AllIniSec[$s] ; Country
                $AllStations[$AllStationsCount][1] = $var[$i][0] ; Key
                $AllStations[$AllStationsCount][2] = $var[$i][1] ; Value
                $AllStationsCount += 1
            Next
        EndIf
    Next
    For $x = 0 To $AllStationsCount - 1
        If StringInStr($AllStations[$x][1], $sText) Then
            $aData = StringSplit($AllStations[$x][2], "|") ; Split the value on the delimiter <<<<<<<<<<<<<<<<<<<<<
            $sItemText = $AllStations[$x][1]
            For $a = 1 To $aData[0]
                $sItemText &= "|" & $aData[$a] ; Add the items to the Item text <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Next
            GUICtrlCreateListViewItem($sItemText, $ListView)
        EndIf
    Next
    _GUICtrlListView_EndUpdate($hListView)
EndFunc   ;==>_UpdateListView

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $I
    Global $hWndFrom, $iCode, $tNMHDR, $hWndListView, $lParam
    $hWndListView = $ListView
    $hWnd1 = $hGUI
    If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_ITEMACTIVATE
                    Local $nmia = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    $I = DllStructGetData($nmia, "Index")
                    $SomeVariablex = _GUICtrlListView_GetItemTextArray($ListView)
                    $gMediaObject.URL = $SomeVariablex[2]
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

Func _CreateWMPlayer()
    $Object = ObjCreate("WMPlayer.OCX.7")
    $Object.URL = ""
    Return $Object
EndFunc   ;==>_CreateWMPlayer

How u can see it give a fake result...try to disable wm_notify function and all work fine...why?...how i can fix that?

Thank's :x

Share this post


Link to post
Share on other sites
Melba23

AuToItItAlIaNlOv3R,

Using the code you have just posted and the full downloaded ini file I am afraid that I cannot reproduce your problem. I get just the 5 valid entries you highlighted in the ListView when I search for "asd" - whether the _WM_NOTIFY handler is enabled or disabled.

As I said earlier, I do not see anything in the code which would cause the search function to return invalid files - your problem must lie elsewhere. :x

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

It's a mistake...what os you use?...i'm uploading a demostration video :P

EDIT:

You can donwload the file video here

Any suggestion?...why do that only on my pc? O.O...it's the same code with the same file ini! Help :x

Thank's

Edited by AuToItItAlIaNlOv3R

Share this post


Link to post
Share on other sites
Melba23

AuToItItAlIaNlOv3R,

It's a mistake

No, it is what happens when I run the code. There is no need for a video, I believe you when you say you get an error - but you also have to believe me when I say I do not. :P

I am running Vista HP SP2 - but I do not think that it is the OS that is causing the problem. Perhaps someone else can try the code and see if they can reproduce your problem. :x

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

There are anyway to do enable the play of streaming of radio with double mouse click on listview element?...without using wm_notify?... this function is the problem, without it work well :x...any suggestion?...

P.S. see the video...it's very funny...real mistake now :shifty:

Thank's :P

Share this post


Link to post
Share on other sites
guinness

Windows 7 x64 and I get the same result as in the picture, but when I comment out GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") (Line 27) it works as expected.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
AuToItItAlIaNlOv3R

Windows 7 x64 and I get the same result as in the picture, but when I comment out GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") (Line 27) it works as expected.

Thank's for your tests...i don't know why the program do that...and it's incredible how the Melba23's pc run it well (I believe you, don't worry :x )...any person with Windows Vista can test it?...

Any possible soluction?, I want to solve this mystery x)

Hi and thank's autoit community!

Share this post


Link to post
Share on other sites
guinness

I have had a look and can't see any reason why it would be doing this. I even resorted to this...

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
; Blank
EndFunc   ;==>_WM_NOTIFY

and for some reason it still creates the problem. But the INI File is huge :x , don't forget that with IniReadSectionNames() - Only the first 32767 chars are taken in account in an section due to Win9x compatibility.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Melba23

Deathbringer,

Melba23 [...] seems to never be able to reproduce anyone's errors

Rather uncalled for in my opinion. Particularly as I have reproduced the error and can offer a couple of solutions. :nuke:

AuToItItAlIaNlOv3R,

Firstly, an explanation of why the error was occurring. I could reproduce it by entering the "asd" characters into the combo faster than the ListView was updating - if I waited until the update was complete before entering the next character the list appeared as it should. When the characters were entered very quickly, the WM_COMMAND handler was firing the update function again before the previous update was complete and this led to the false finds as the updates competed in filling the ListView. This is one reason why I try never to run longish functions within message handlers. :lol:

Quite why the WM_NOTIFY seemed to interfere I have no idea. :shifty:

Now, how to fix it? :P

Possibility 1: (My preferred solution) Use a flag within the WM_COMMAND handler and action the update within the main loop like this:

Global $fComboChange = False ; Declare the flag <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If $fComboChange Then ; If the flag is set, run the update <<<<<<<<<<<<<<<<<<<<<<<<<<
        $fComboChange = False ; Reset the flag so we can detect the next change <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        $sText = _GUICtrlComboBox_GetEditText($hComboBox)
        If $sText <> "" Then
             _UpdateListView($sText)
        Else
            _GUICtrlListView_DeleteAllItems($hListView)
        EndIf
    EndIf

WEnd

Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)

    Switch $hWndFrom
        Case $hComboBox
            Switch $iCode
                Case $CBN_EDITCHANGE
                    $fComboChange = True ; Set the flag here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

This way the update function will end before any subsequent setting of the flag and so there will not be competing updates. In fact if you do enter the characters fast, you often skip an update as you only search for the most recent combination and so skip any intermediate steps - try adding a ConsoleWrite($sText & @CRLF) after reading the combo edit text to see what I mean. :(

Possibility 2: Just read the combo directly and do not use a WM_COMMAND handler at all:

$sCurrCombo = "" ; Initial combo state <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If _GUICtrlComboBox_GetEditText($hComboBox) <> $sCurrCombo Then ; Has combo state changed <<<<<<<<<<<<<<<<<<<<<<<<<
        $sText = _GUICtrlComboBox_GetEditText($hComboBox)
        If $sText <> "" Then
            _UpdateListView($sText)
        Else
            _GUICtrlListView_DeleteAllItems($hListView)
        EndIf
        $sCurrCombo = $sText ; Set new combo state <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    EndIf

WEnd

Both of those work for me without problem regardless of the speed with which I enter the characters into the combo. :x

Moral of the story: Do NOT use longish functions within message handlers. The help file says "the return to the system should be as fast as possible !!!" for a good reason. :D

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×