Jump to content

Search Text Dialog


Recommended Posts

This set of VIs implements a standard text search prompt as seen in most text editors. To use it, all you need to do is pass it a reference to the text control you wish to search.

The following features are provided:

1. Search in both directions.

2. Remembers past search strings from each session.

3. Can choose to match case or not.

4. Opens centered on caller. (Can override if necessary)

There are some issues with this version. I could use help in improving in these areas:

1. Speed (it is slow for large amounts of text). By using the Get Nth Line function, I can support a text control with any font. I think this could be improved by doing a binary search algorithm, but I would need to know how many lines a text control contains. This is not easy and requires counting <CR> and word wraps.

2. To make sure it does not get lost, I need to make it floating. But, for some reason, you cannot bring a floating window to the front programmatically. So, when it first appears, you must click in the window before you can type anything.

3. In order to make the text in the original control appear highlighted, that window must be front most. So, after it finds something, it has to set the caller's window front most. This means each time you wish to do another search, you must select the dialog window again. Any ideas on this?

4. I am using a combo box to allow it to remember past searches. For some reason, if you type the very first entry into the combo box and then press return to toggle the find button, it will not see this entry when it reads the string from the combo box. So, instead, I had to force the user to click on the Find button.

I hope this incarnation is useful to you and with help, we can make this even better.

-John

Download File:post-2411-1222064807.zip

Link to comment

QUOTE (jlokanis @ Sep 23 2008, 12:48 AM)

To make sure it does not get lost, I need to make it floating. But, for some reason, you cannot bring a floating window to the front programmatically.

I haven't tried, but what happens if you make the window modal and then programmatically change it to be floating?

Link to comment

QUOTE (Yair @ Sep 23 2008, 09:49 AM)

I haven't tried, but what happens if you make the window modal and then programmatically change it to be floating?

I didn't try that but I did find that it would work as required by letting it be floating but not hiding it when LabVIEW was not the active window.

I didn't know you chould change a dialog from modal to floating while it was running. I will look into this as well. Thanks for the idea.

Link to comment

QUOTE (jlokanis @ Sep 21 2008, 11:29 PM)

There are some issues with this version. I could use help in improving in these areas:

1. Speed (it is slow for large amounts of text). By using the Get Nth Line function, I can support a text control with any font. I think this could be improved by doing a binary search algorithm, but I would need to know how many lines a text control contains. This is not easy and requires counting <CR> and word wraps.

2. To make sure it does not get lost, I need to make it floating. But, for some reason, you cannot bring a floating window to the front programmatically. So, when it first appears, you must click in the window before you can type anything.

3. In order to make the text in the original control appear highlighted, that window must be front most. So, after it finds something, it has to set the caller's window front most. This means each time you wish to do another search, you must select the dialog window again. Any ideas on this?

4. I am using a combo box to allow it to remember past searches. For some reason, if you type the very first entry into the combo box and then press return to toggle the find button, it will not see this entry when it reads the string from the combo box. So, instead, I had to force the user to click on the Find button.

1. Speed fixed. Uses binary search. One caveat: it will only work with single font string controls. So, no mixing fonts or adding modifiers (bold, etc). If you can find a way around this, please let me know.

2. By setting it to float and always visable (do not hide when LV not active), I was able to make it be the top window when it is activated.

3. Still no improvment here.

4. Needed to set the button to both toggle and grab focus when <CR> pressed. This way, the data being entered into the combo box becomes 'active'.

Thanks to everyone who helped improve this code. If you have any other ideas or suggestions, please post them and I will see if I can improve it more.

-John

http://lavag.org/old_files/post-2411-1222277716.zip'>Download File:post-2411-1222277716.zip

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.