Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

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

reidar
New User
791 Views

 

 

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?

 

0 Kudos
3 Replies
Paul_Curtis
Valued Contributor I
791 Views
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: [fortran] CASE (WM_KEYDOWN) SELECT CASE (wParam) CASE (VK_UP) updn = -1 CASE (VK_DOWN) updn = 1 CASE DEFAULT updn = 0 END SELECT [/fortran] The listbox part is simply to get and re-assign the current selection highlight (0-based index): [fortran] 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 [/fortran] 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).
0 Kudos
reidar
New User
791 Views
Thank you for your answer. I will try to implement what you are suggesting..
0 Kudos
reidar
New User
791 Views

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.

0 Kudos
Reply