GetWndHandle (hbuf)

Returns a window handle for the front-most window that displays the file buffer specified by hbuf. GetWnd­Handle returns hNil if the file buffer is not in a window.  

Since a file buffer may appear in more than one window, GetWndHandle searches through all windows in front-to-back order. So if the specified file buffer is the current buffer in the active window, the handle for that window is always returned.