I want to put some things in a ListBox and highlight multiple items via program control. I have that working with a
SENDMESSAGE( HWND_FORM1_LISTPROGVER, %LB_SETSEL, 1, r)
I don't want to allow a user to click a row and highlight it. Short of DISABLING the control how can I catch the mouse click and handle NOT selecting the row? I tried setting the control to read only (had to do a SENDMESSAGE since that property is not in the propery box) but it made no difference.
I did this to simply catch a mouse click and change the selection state back to the way it was before the click.
FUNCTION FORM1_LISTPROGVER_LBN_SELCHANGE ( _
ControlIndex AS LONG, _ ' index in Control Array
hWndForm AS DWORD, _ ' handle of Form
hWndControl AS DWORD, _ ' handle of Control
idListBox AS DWORD _ ' identifier of listbox
) AS LONG
DIM r AS LONG
DIM s AS LONG
r = SENDMESSAGE( HWND_FORM1_LISTPROGVER, %LB_GETCURSEL, 0, 0)
s = SENDMESSAGE( HWND_FORM1_LISTPROGVER, %LB_GETSEL, r, 0)
IF s = 0 THEN
SENDMESSAGE( HWND_FORM1_LISTPROGVER, %LB_SETSEL, 1, r)
ELSE
SENDMESSAGE( HWND_FORM1_LISTPROGVER, %LB_SETSEL, 0, r)
END IF
END FUNCTION
The only other problem is a strange one --- If you drag and drop a row on to another one it toggles the dropped row on release of the mouse. I really was not trying to drag and drop but it happend accidentally when I was testing.