Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 25 NOV 2003 06:52:34AM Richard Channer wrote:

Hi guys,

I am sure I used to have a code snippet to achieve this but I cannot find it!

I wish to disable a listbox on the fly, but still allow use of the scroll bars. Anyone have a bit of code to do it?

Cheers!


At 25 NOV 2003 08:21AM Oystein Reigem wrote:

Richard,

If your question were about an edit control (edit line, edit box) I could have helped you. Edit controls have a read-only property/style bit that can be set programmatically or at design time. A read-only edit box will allow scrolling but no changes.

However - I don't know of any such property for list boxes. (Surely there ought to be a read-only property for list boxes?)

Here's a workaround. It's not too elegant since the user can select a different value, but the value will be changed back:

- Let the list box have a user defined property @READONLY that tells if the list box is read-only or not

- Change the @READONLY property to true$ when you need the list box read-only, and to false$ when you need normal behaviour

- Let the list box's GOTFOCUS handler remember the list box's selected value or selected position (TEXT or SELPOS property). E.g, use user-defined properties @TEXT or @SELPOS to remember the TEXT or SELPOS value

- Let the list box's CHANGED or LOSTFOCUS handler check if the @READONLY property is true$, and in case set the list box's TEXT or the SELPOS property back to the remembered value.

The user will be able to select a different value, but the value will be changed back, either immediately (if you use the CHANGED handler) or when the user leaves the list box (if you use the LOSTFOCUS handler).

I can supply the code if you need it.

- Oystein -


At 26 NOV 2003 05:41AM Richard Channer wrote:

Hi Oystein,

I was hoping I wouldn't have to do the 'dirty' solution! The bit of code I had was probably for editbox/line then I guess. Probably why I can't find it!

Will do the dirty method and see what it looks like…

Cheers, Richard


At 26 NOV 2003 05:49AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

Richard,

What exactly do you mean by disable? Listboxes by design cannot be edited so I'm curious as to what behaviour you are after.

The Sprezzatura Group

World leaders in all things RevSoft


At 26 NOV 2003 08:01AM Oystein Reigem wrote:

Sprezzatura,

Richard wants the list box to be scrollable. He wants the user to be able to see all items, even if the user isn't allowed to select anything.

His problem is very similar to the one you get if you disable an edit box (with lots of text in it). One can't scroll a disabled edit box. The solution for the edit box is to set the edit box read-only.

- Oystein -


At 26 NOV 2003 08:05AM Oystein Reigem wrote:

Richard,

Here's a different dirty method: Have two versions of the list box - one for normal use, and one for read-only. Switch between normal and read-only by changing the VISIBLE property of the two controls. As the read-only version use a read-only edit box or edit table.

- Oystein -


At 26 NOV 2003 08:36AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

Well in that case there *is* a way to do it but it's a bit messy…

There's a listbox style setting called LBS_NOSEL that you can set but you can't just alter the Listbox's style property to set it - you either have to create and destroy the control at runtime (which may have OI licensing implications), OR you could alter the setting in the actual window structure record (SYSREPOSWINS) by editing it 'by hand'.

LBS_NOSEL$ is 0x4000

The Sprezzatura Group

World leaders in all things RevSoft


At 26 NOV 2003 10:31AM Donald Bakke wrote:

…you either have to create and destroy the control at runtime (which may have OI licensing implications)…

My understanding is that destroying a control and then re-creating that control is okay. We are only prohibited from creating new controls.

dbakke@srpcs.com

SRP Computer Solutions, Inc.


At 27 NOV 2003 08:33AM The Sprezzatura Group wrote:

Or…since it's protected, just use an edittable which allows a readonly setting and will look just like a listbox once the grid is removed and the row and column headings hidden.

The Sprezzatura Group

World Leaders in all things RevSoft


At 04 DEC 2003 01:10PM Richard Guise wrote:

Here's my really dirty inelegant solution which I've used for a while for various controls which don't offer the "read-only" setting!

On CHAR or CHANGED event (or both) call a routine which simply stuffs back the GOTFOCUS_VALUE.

I've got some more sophisticated variations on the theme - e.g. to use the dropdown button to call a popup and put the resulting value into the prompt but protect it. The DROPDOWN call puts the new value in the prompt and also in a property (e.g. @whatever or MISC). The CHAR event restores from this property but, if not there, uses the gotfocus value.

As I say, messy, horrible, ooh-ahh - but it's simple to set up and adjust and it works.

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/d3c72016d5ebe97b85256de900413ce1.txt
  • Last modified: 2023/12/28 07:40
  • by 127.0.0.1