I'm using a panel to display a document. I want to know when the vertical scroll bar has reached the either of the sides( the top-most position - where you cannot scroll up any more. and the bottom-most position - where you cannot scroll down any more)
If your scrollbar widget defers to your code in order to perform the actual scrolling (that is, the scrollbar handles only its own position and percentage done), in that case you should know when the scrolling reaches the minimum or maximum.
Otherwise, pretty much all scrollbars need keep minimum, maximum and current values in order to be able to redraw themselves and handle scrolling. Depending on the GUI toolkit, how you access these values varies. Win32 code can get the values through a SCROLLBARINFO
struct while Qt offers minimum(), maximum() and value() methods for example.
Without more information on where your scrollbar comes from, that's all we can say. Either search for yourself or add more information to your question so we can provide better and more accurate information.