Jump to content

Recommended Posts

Posted (edited)

Hi there,

I'm building a script where I have a GUI with a ListView in it (created using _GUICtrlListView_Create()).

I also need to know which row a user clicks in the ListView, so I can update a series of GUI controls with information regarding that row.

So I registered the WM_NOTIFY callback function after creating the ListView: GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY").

It would seem to me that whatever I need to do when a row is clicked - either get row information or set other controls - would have to be coded inside WM_NOTIFY.

But while I was experimenting with it, it happened that calling _ArrayDisplay() inside WM_NOTIFY causes the script to freeze.

I'd be grateful for your input as to what would be the correct approach to the callback function:

- Is it safe to call other functions from within WM_NOTIFY? (apart from some exceptions such as _ArrayDisplay?)

- Or should I be using a different approach?

Thanks in advance,

footswitch

Edited by footswitch
Posted

_ArrayDisplay() is simply a debugging function and should not be used as part of a script. Just create your own ListView Control and use that instead.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

  • Moderators
Posted

footswitch,

The big problem with calling _ArrayDisplay within the handler is that it is a blocking function - i.e. it waits for user input before letting the script continue. :)

As you can read in the Help file for GUIRegisterMsg:

"Warning: blocking of running user functions which executes window messages with commands such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!"

If you want to use such a function, set a flag within the handler and then call the blocking function from within your main script. The GUIRegisterMsg tutorial in the Wiki shows how to do this - and offers an alternative solution. ;)

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

 

Posted

Oh! I believe you guys have a point there. Didn't remember to take a look at GUIRegisterMsg() in the helpfile. My bad.

Nevertheless, I was actually using _ArrayDisplay() for debugging :)

So, you'd say it's best (a.k.a. safest) to use flags and look for them in the main loop, rather thank including the control update functions and SQLite Queries inside the callback function, right? Because at times that could take a second or two.

Thank you kindly for your advice.

footswitch

  • Moderators
Posted

footswitch,

use flags and look for them in the main loop [...] Because at times that could take a second or two

You must have a very slow loop! ;)

I use the flag technique regularly and I have not noticed any serious delays. Certainly I try and keep the code inside the handler to an absolute minimum - I take the "as fast as possible"suggestion very seriously. :)

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

 

Posted

No, not the main loop! I meant the SQLite Query that I need to call when I click a row takes some time to return its result :)

It's a fairly big database with tens of thousands of rows. Loads of compound queries, table joins and conditions.

But that's a whole 'nother matter ;)

Got it, as fast as possible.

Thanks a lot, you guys are the best [place "praise" emoticon here]

  • Moderators
Posted

footswitch,

Sorry, I completely misread your comment! ;)

I was just wondering what size of loop you had! :)

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

 

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
  • Recently Browsing   0 members

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