A stock may be subject to short sale restrictions for various reasons, including trading halts, an inability of the broker to locate shares to borrow beforehand and SEC Rule 201 (uptick rule).
To determine whether a short sale restriction exists for a given security prior to entering an order, you would need to first add the symbol to a quote line on the TWS. Restrictions associated with trading halts and the inability to secure a locate can be determined by adding the Shortable column to the TWS display. This column is color-coded to denote status and, if red, a short sale order will not be accepted. Instructions for configuring the TWS to display this column are available here: How do I see whether a stock is shortable on TWS?
In the case of shares which are restricted from short sales due to the uptick rule, the TWS will automatically display a tool tip icon alongside the stock symbol and if you drag your mouse over that icon, it will refer to this restriction. See KB1432 for details on SEC Rule 201.