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 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

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:


CASE (WM_KEYDOWN)

	SELECT CASE (wParam)

	CASE (VK_UP)

		updn = -1

	CASE (VK_DOWN)

                updn = 1

        CASE DEFAULT

                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)

END IF

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.

Anlagen: 

AnhangGröße
Herunterladen callbackplotgraph.f9020.56 KB

Melden Sie sich an, um einen Kommentar zu hinterlassen.