Title: Automatically detecting when a row in ListBox is being de-selected ?
Question: A pragmatic approach to instantaneously detecting when a ListBox has been de-selected .( Delphi's OnSelCount doesn't effectively work when the focus transfers to another object / component ).
Answer:
{ ************************************************************************** }
{ * * }
{ * Distribute as pleased................ * }
{ * * }
{ * Just give the author appropriate credits ;P * }
{ * * }
{ * ---------------------------------------------------------------------- * }
{ * * }
{ * Willy Yeo * }
{ * will81@rocketmail.com * }
{ * * }
{ ************************************************************************** }
// On the form's OnPaint() procedure, add this snippet of code to it :
{ ** Alternatively, you could place a TTimer component on the form and have
it programmatically execute the statement below ( Depending in the area
of use / functionality of the application you are writing..... ). **
}
// Detects if the label has been de-selected everytime the form is painted
If ( sendMessage( ListBox1.Handle, LB_GETCURSEL, 0, 0 ) = LB_ERR ) Then
Begin
MessageDlg( 'ListBox de-select detected!!!', mtConfirmation, [MBOK], 0 );
// Do stuff(s) here...........
// ...........................etc
End;