How to move /scroll up down in a list-box.

How to move /scroll up down in a list-box.



I have a MDI application that uses list-boxes in a modeless dialog.

To make a selection in a list-box I have to point with the mouse and click

and to change the selection, point and click.

How  could it be arranged to change  the selection with the Up/Down  keys?


4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

What you are asking involves two separate steps: first to detect up/dn keystrokes, and second to send your listbox messages to reposition the selection highlight. All of this requires that you are directly processing all opsys messages for your program, and particularly that you are running your own proc function for the dialog that contains the listbox control (ie, this level of solution will likely not be available in Quickwin or similar psuedo-gui programming abstraction layers).

To act on specific keystrokes, your dialog proc's message handling loop needs to process WM_KEYDOWN messages:




		updn = -1


                updn = 1


                updn = 0

        END SELECT

The listbox part is simply to get and re-assign the current selection highlight (0-based index):

IF (updn /= 0) THEN

    idx = SendControlMessage (hwnd, controlId, LB_GETCURSEL, 0, 0)

    idx = MIN0(MAX0(idx + updn, 0), max_items -1)

    iret = SendControlMessage (hwnd, controlId, LB_SETCURSEL, idx, 0)


where hwnd is the handle of the dialog window and controlId specifies the listbox.

Upon further investigation, listboxes should (do) contain internal handling which automatically translates up/dn keystrokes into highlight movement up and down the set of entries. The above code, however, would enable (or force) this behavior in cases where the parent dialog has the focus, but not the listbox itself (presuming there is only one listbox).

Thank you for your answer. I will try to implement what you are suggesting..

Well, I have followed the advise given, thank you Tom. However, the problem is that the WM_KEYDOWN is not trapped.

Mouse-clicks work when clicking outside the list boxes, and when selecting items in the list-boxes, but it is not possible

to"scroll" in a list box with the Up/Down arrow keys.

I have set the notify switch = .true. for both the dialog and the listbox.

(I am using IVF10.026 and VS2005)

To give a closer explanation, I attach the callback routine. I hope somebody will advise.


Downloadapplication/octet-stream callbackplotgraph.f9020.56 KB

Leave a Comment

Please sign in to add a comment. Not a member? Join today